using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("DoubleGates")] [assembly: AssemblyConfiguration("Release2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DoubleGates")] [assembly: AssemblyTitle("DoubleGates")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DoubleGates { [BepInPlugin("rowe.valheim.doublegates", "Rowe's Double Gates", "1.0.0")] public class DoubleGatesPlugin : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("ru.rowes.valheim.doublegates"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Double Gates loaded"); } } [HarmonyPatch(typeof(Door), "Interact")] public static class DoorPatch { private static bool _busy; private static readonly FieldInfo NViewField = AccessTools.Field(typeof(Door), "m_nview"); private static readonly MethodInfo SetStateMethod = AccessTools.Method(typeof(Door), "SetState", (Type[])null, (Type[])null); private static void Postfix(Door __instance, Humanoid character, bool hold, bool alt) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (_busy || hold) { return; } try { _busy = true; Door val = FindPair(__instance); if ((Object)(object)val == (Object)null) { return; } ZNetView val2 = (ZNetView)NViewField.GetValue(__instance); ZNetView val3 = (ZNetView)NViewField.GetValue(val); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { return; } int num = val2.GetZDO().GetInt(ZDOVars.s_state, 0); float num2 = Vector3.Dot(((Component)__instance).transform.forward, ((Component)val).transform.forward); bool flag = num2 < -0.95f; int num3 = num; if (flag) { switch (num) { case 1: num3 = -1; break; case -1: num3 = 1; break; } } int num4 = val3.GetZDO().GetInt(ZDOVars.s_state, 0); if (num4 != num3) { val3.GetZDO().Set(ZDOVars.s_state, num3, false); SetStateMethod?.Invoke(val, new object[1] { num3 }); Debug.Log((object)$"[DoubleGates] Source={num} Target={num3} Mirrored={flag}"); } } finally { _busy = false; } } private static Door FindPair(Door source) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Door result = null; float num = float.MaxValue; Door[] array = Object.FindObjectsByType((FindObjectsSortMode)0); string text = ((Object)source).name.Replace("(Clone)", ""); Door[] array2 = array; foreach (Door val in array2) { if ((Object)(object)val == (Object)(object)source) { continue; } string text2 = ((Object)val).name.Replace("(Clone)", ""); if (!(text != text2)) { float num2 = Vector3.Distance(((Component)source).transform.position, ((Component)val).transform.position); if (!(num2 < 1.7f) && !(num2 > 2.3f) && !(Mathf.Abs(((Component)source).transform.position.y - ((Component)val).transform.position.y) > 0.2f) && num2 < num) { num = num2; result = val; } } } return result; } } }