Decompiled source of PressurePlate v0.10.0

PressurePlate.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using PressurePlate.Compatibility.WardIsLove;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyFileVersion("0.10.0")]
[assembly: AssemblyInformationalVersion("0.10.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PressurePlate")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyProduct("PressurePlate")]
[assembly: AssemblyTitle("PressurePlate")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.10.0.0")]
[module: UnverifiableCode]
namespace PressurePlate
{
	public class AudioBinder : MonoBehaviour
	{
		private void Awake()
		{
			((Component)this).GetComponent<AudioSource>().outputAudioMixerGroup = AudioMan.instance.m_ambientMixer;
		}
	}
	public class DoorConfig
	{
		public bool openClosedInverted;

		[Obsolete]
		public float openTime;

		private static readonly Dictionary<int, DoorConfig> specificDoors = new Dictionary<int, DoorConfig>();

		public DoorConfig(bool openClosedInverted = false, float openTime = 1f)
		{
			this.openClosedInverted = openClosedInverted;
		}

		public static bool AddDoorConfig(Door door, DoorConfig doorConfig)
		{
			DoorPowerState doorPowerState = default(DoorPowerState);
			if (!((Component)door).TryGetComponent<DoorPowerState>(ref doorPowerState))
			{
				doorPowerState = ((Component)door).gameObject.AddComponent<DoorPowerState>();
			}
			if (specificDoors.ContainsKey(doorPowerState.GetPrefabId()))
			{
				return false;
			}
			specificDoors.Add(doorPowerState.GetPrefabId(), doorConfig);
			return true;
		}

		public static bool AddDoorConfig(string prefabName, DoorConfig doorConfig)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(prefabName);
			if (specificDoors.ContainsKey(stableHashCode))
			{
				return false;
			}
			specificDoors.Add(stableHashCode, doorConfig);
			return true;
		}

		public static DoorConfig GetDoorConfig(PowerState doorPowerState)
		{
			if (specificDoors.ContainsKey(doorPowerState.GetPrefabId()))
			{
				return specificDoors[doorPowerState.GetPrefabId()];
			}
			return null;
		}
	}
	[HarmonyPatch]
	public static class DoorPatches
	{
		[HarmonyPatch(typeof(Door), "Awake")]
		[HarmonyPostfix]
		public static void DoorAwake(Door __instance)
		{
			if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<DoorPowerState>()))
			{
				((Component)__instance).gameObject.AddComponent<DoorPowerState>();
			}
		}
	}
	public class DoorPowerState : PowerState
	{
		private Door door;

		protected override void Awake()
		{
			base.Awake();
			door = ((Component)this).GetComponent<Door>();
		}

		protected override void Interact(Plate plate)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)door.m_keyItem))
			{
				Vector3 val = ((Component)plate).transform.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				bool flag = Vector3.Dot(((Component)this).transform.forward, normalized) < 0f;
				door.m_nview.InvokeRPC("UseDoor", new object[1] { flag });
			}
		}

		public override bool CanInteract(Player activator, ZDO targetArea)
		{
			return Plate.CanInteractWithDoor(activator, this, targetArea);
		}
	}
	public class Pieces
	{
		public static void Init(AssetBundle assetBundle)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Expected O, but got Unknown
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			AddPressurePlate(assetBundle, "pressure_plate Wood.prefab", "pressurePlate_PressurePlate_Items_AddPlateItem", "$pressure_plate_wood", "pressure_plate_wood_icon.png", "woodwall", (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig
				{
					Item = "Wood",
					Amount = 3,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SurtlingCore",
					Amount = 1,
					Recover = true
				}
			}, new Vector2(-0.56f, 0.12f), new Vector2(0f, 0.014f));
			AddPressurePlate(assetBundle, "pressure_plate Stone.prefab", "pressurePlate_stone_PressurePlate_Items_AddPlateItem", "$pressure_plate_stone", "pressure_plate_stone_icon.png", "stonefloor", (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig
				{
					Item = "Stone",
					Amount = 3,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SurtlingCore",
					Amount = 1,
					Recover = true
				}
			}, new Vector2(0.14f, 0.14f), new Vector2(0.28f, 0.08f));
			AddPressurePlate(assetBundle, "pressure_plate Crystal.prefab", "CrystalPressurePlate", "$pressure_plate_crystal", "pressure_plate_crystal_icon.png", "crystal_window", (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig
				{
					Item = "Crystal",
					Amount = 1,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SurtlingCore",
					Amount = 1,
					Recover = true
				}
			}, new Vector2(1.5f, 1.5f), new Vector2(0f, 0f));
			AddPressurePlate(assetBundle, "pressure_plate BlackMarble.prefab", "MS_PressurePlate_BlackMarble", "$pressure_plate_black_marble", "pressure_plate_black_marble_icon.png", "blackmarble", (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig
				{
					Item = "BlackMarble",
					Amount = 2,
					Recover = true
				},
				new RequirementConfig
				{
					Item = "SurtlingCore",
					Amount = 1,
					Recover = true
				}
			}, new Vector2(0.5f, 0.5f), new Vector2(0f, 0f));
		}

		private static void AddPressurePlate(AssetBundle assetBundle, string assetName, string newName, string tokenName, string iconName, string materialName, RequirementConfig[] requirements, Vector2 textureScale, Vector2 textureOffset)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			GameObject val = assetBundle.LoadAsset<GameObject>(assetName);
			GameObject val2 = PrefabManager.Instance.CreateClonedPrefab(newName, val);
			Sprite icon = assetBundle.LoadAsset<Sprite>(iconName);
			PieceConfig val3 = new PieceConfig
			{
				CraftingStation = CraftingStations.Workbench,
				Requirements = requirements,
				PieceTable = PieceTables.Hammer,
				Icon = icon,
				Category = PieceCategories.Misc,
				Name = tokenName
			};
			CustomPiece val4 = new CustomPiece(val2, true, val3);
			GameObject piecePrefab = val4.PiecePrefab;
			WearNTear wearNTear = piecePrefab.GetComponent<WearNTear>();
			PrefabManager.OnPrefabsRegistered += ApplyEffects;
			PieceManager.Instance.AddPiece(val4);
			void ApplyEffects()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Expected O, but got Unknown
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				PrefabManager.OnPrefabsRegistered -= ApplyEffects;
				Material prefab = Cache.GetPrefab<Material>(materialName);
				prefab = new Material(prefab);
				prefab.SetTextureScale("_MainTex", textureScale);
				prefab.SetTextureOffset("_MainTex", textureOffset);
				((Renderer)wearNTear.m_new.GetComponent<MeshRenderer>()).materials = (Material[])(object)new Material[1] { prefab };
			}
		}
	}
	public class Plate : MonoBehaviour, Hoverable, Interactable
	{
		[SerializeField]
		private GameObject plate;

		[SerializeField]
		private EffectList pressEffects = new EffectList();

		[SerializeField]
		private EffectList releaseEffects = new EffectList();

		private Piece piece;

		private MeshRenderer pieceMesh;

		private bool isPressed;

		private float pressCooldown;

		private float pressTriggerDelay;

		private float lastTime;

		private ZNetView zNetView;

		public FloatZNetProperty TriggerRadiusHorizontal { get; private set; }

		public FloatZNetProperty TriggerRadiusVertical { get; private set; }

		public FloatZNetProperty OpenRadiusHorizontal { get; private set; }

		public FloatZNetProperty OpenRadiusVertical { get; private set; }

		public FloatZNetProperty OpenTime { get; private set; }

		public FloatZNetProperty TriggerDelay { get; private set; }

		public BoolZNetProperty Invert { get; private set; }

		public BoolZNetProperty ToggleModeOption { get; private set; }

		public BoolZNetProperty IsToggledOn { get; private set; }

		public BoolZNetProperty IgnoreWards { get; private set; }

		public BoolZNetProperty AllowMobs { get; private set; }

		public IntZNetProperty MobTameInteraction { get; private set; }

		public BoolZNetProperty IsInvisible { get; private set; }

		public BoolZNetProperty OnlyOpenNotPermitted { get; private set; }

		private void InitProperties()
		{
			TriggerRadiusHorizontal = new FloatZNetProperty("pressure_plate_trigger_radius_horizontal", zNetView, 1f);
			TriggerRadiusVertical = new FloatZNetProperty("pressure_plate_trigger_radius_vertical", zNetView, 1f);
			OpenRadiusHorizontal = new FloatZNetProperty("pressure_plate_open_radius_horizontal", zNetView, 3f);
			OpenRadiusVertical = new FloatZNetProperty("pressure_plate_open_radius_vertical", zNetView, 3f);
			OpenTime = new FloatZNetProperty("pressure_plate_open_time", zNetView, 1f);
			TriggerDelay = new FloatZNetProperty("pressure_plate_trigger_delay", zNetView, 0f);
			Invert = new BoolZNetProperty("pressure_plate_invert", zNetView, defaultValue: false);
			ToggleModeOption = new BoolZNetProperty("pressure_plate_toggle_mode", zNetView, defaultValue: false);
			IsToggledOn = new BoolZNetProperty("pressure_plate_is_toggled_on", zNetView, defaultValue: false);
			IgnoreWards = new BoolZNetProperty("pressure_plate_is_public", zNetView, defaultValue: false);
			AllowMobs = new BoolZNetProperty("pressure_plate_allow_mobs", zNetView, defaultValue: false);
			MobTameInteraction = new IntZNetProperty("pressure_plate_tame_interaction", zNetView, 0);
			IsInvisible = new BoolZNetProperty("pressure_plate_invisible", zNetView, defaultValue: false);
			OnlyOpenNotPermitted = new BoolZNetProperty("pressure_plate_only_open_not_permitted", zNetView, defaultValue: false);
		}

		public void PasteData(Plate copy)
		{
			TriggerRadiusHorizontal.ForceSet(copy.TriggerRadiusHorizontal.Get());
			TriggerRadiusVertical.ForceSet(copy.TriggerRadiusVertical.Get());
			OpenRadiusHorizontal.ForceSet(copy.OpenRadiusHorizontal.Get());
			OpenRadiusVertical.ForceSet(copy.OpenRadiusVertical.Get());
			OpenTime.ForceSet(copy.OpenTime.Get());
			TriggerDelay.ForceSet(copy.TriggerDelay.Get());
			Invert.ForceSet(copy.Invert.Get());
			ToggleModeOption.ForceSet(copy.ToggleModeOption.Get());
			IgnoreWards.ForceSet(copy.IgnoreWards.Get());
			AllowMobs.ForceSet(copy.AllowMobs.Get());
			MobTameInteraction.ForceSet(copy.MobTameInteraction.Get());
			IsInvisible.ForceSet(copy.IsInvisible.Get());
			OnlyOpenNotPermitted.ForceSet(copy.OnlyOpenNotPermitted.Get());
		}

		private void Awake()
		{
			zNetView = ((Component)this).GetComponent<ZNetView>();
			piece = ((Component)this).GetComponent<Piece>();
			pieceMesh = plate.GetComponent<MeshRenderer>();
			Plugin.Instance.plateVolume.SettingChanged += SetPlateVolume;
			SetPlateVolume(null, null);
			if (zNetView.IsValid())
			{
				InitProperties();
				isPressed = CheckPress(out var _);
				pressTriggerDelay = TriggerDelay.Get();
				lastTime = Time.time;
				FixedUpdate();
			}
		}

		private void UpdateVisibility()
		{
			((Renderer)pieceMesh).enabled = !IsInvisible.Get();
		}

		private void FixedUpdate()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			if (!zNetView.IsValid())
			{
				return;
			}
			UpdateVisibility();
			float num = Time.time - lastTime;
			lastTime = Time.time;
			bool flag = isPressed;
			Player activator;
			bool flag2 = CheckPress(out activator);
			ZDO area = GetArea(((Component)this).transform.position);
			List<PowerState> list = PowerState.FindDoorsInPlateRange(this, ((Component)this).transform.position);
			if (flag2)
			{
				if (pressTriggerDelay <= 0f)
				{
					pressTriggerDelay = TriggerDelay.Get();
					isPressed = true;
					pressCooldown = Mathf.Max(new float[1] { OpenTime.Get() });
				}
				else
				{
					pressTriggerDelay -= num;
				}
			}
			else if (pressCooldown > 0f)
			{
				pressCooldown -= num;
				isPressed = true;
			}
			else
			{
				isPressed = false;
				pressTriggerDelay = TriggerDelay.Get();
			}
			bool flag3 = isPressed != flag;
			Vector3 localPosition = (isPressed ? new Vector3(0f, -0.025f, 0f) : new Vector3(0f, 0.05f, 0f));
			plate.transform.localPosition = localPosition;
			if (zNetView.IsOwner())
			{
				if (ToggleModeOption.Get())
				{
					if (flag3 && isPressed)
					{
						IsToggledOn.Set(!IsToggledOn.Get());
					}
				}
				else
				{
					IsToggledOn.Set(value: false);
				}
			}
			bool flag4 = IsPowering();
			if (flag3)
			{
				if (flag4)
				{
					pressEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				}
				else
				{
					releaseEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
				}
				foreach (PowerState item in list)
				{
					if (item.CanInteract(activator, area))
					{
						if (flag4)
						{
							item.AddPoweringPlate(this);
						}
						else
						{
							item.RemovePoweringPlate(this);
						}
					}
				}
			}
			if (!zNetView.IsOwner() || (!flag3 && !flag4))
			{
				return;
			}
			foreach (PowerState item2 in list)
			{
				if (item2.CanInteract(activator, area))
				{
					if (flag4)
					{
						item2.Open(this);
					}
					else if (item2.GetPoweringPlates().Count((Plate i) => (Object)(object)i != (Object)(object)this) <= 0)
					{
						item2.Close(this);
					}
				}
			}
		}

		private bool IsPowering()
		{
			if (ToggleModeOption.Get())
			{
				return IsToggledOn.Get();
			}
			return isPressed;
		}

		public static bool CanInteractWithDoor(Player activator, DoorPowerState door, ZDO targetArea)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)activator != (Object)null && PlayerHasAccess(activator, ((Component)door).transform.position))
			{
				return true;
			}
			return targetArea == GetArea(((Component)door).transform.position);
		}

		private bool CheckPress(out Player activator)
		{
			if (IgnoreWards.Get() && AllowMobs.Get())
			{
				activator = null;
				return CheckMobPress();
			}
			activator = CheckPlayerPress();
			return (Object)(object)activator != (Object)null;
		}

		private Player CheckPlayerPress()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (!InRange(((Component)allPlayer).transform.position) || NotOpenBecauseIsPermitted(allPlayer) || (!IgnoreWards.Get() && !PlayerHasAccess(allPlayer, ((Component)allPlayer).transform.position)))
				{
					continue;
				}
				return allPlayer;
			}
			return null;
		}

		private bool NotOpenBecauseIsPermitted(Player player)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			return IgnoreWards.Get() && OnlyOpenNotPermitted.Get() && PlayerHasAccess(player, ((Component)player).transform.position);
		}

		private bool CheckMobPress()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (!InRange(((Component)allCharacter).transform.position))
				{
					continue;
				}
				Player val = (Player)(object)((allCharacter is Player) ? allCharacter : null);
				if (val != null && NotOpenBecauseIsPermitted(val))
				{
					continue;
				}
				switch (MobTameInteraction.Get())
				{
				case 0:
					return true;
				case 1:
					if (allCharacter.IsTamed())
					{
						return true;
					}
					break;
				case 2:
					if (!allCharacter.IsTamed())
					{
						return true;
					}
					break;
				default:
					return true;
				}
			}
			return false;
		}

		public static bool PlayerHasAccess(Player player, Vector3 pos)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (WardIsLovePlugin.IsLoaded() && DoorInteract.InsideWard(pos))
			{
				return DoorInteract.CanInteract(player, pos);
			}
			foreach (PrivateArea allArea in PrivateArea.m_allAreas)
			{
				bool flag = allArea.IsEnabled();
				bool flag2 = allArea.IsInside(pos, 0f);
				bool flag3 = allArea.m_piece.GetCreator() == player.GetPlayerID() || allArea.IsPermitted(player.GetPlayerID());
				if (flag && flag2 && !flag3)
				{
					return false;
				}
			}
			return true;
		}

		public static ZDO GetArea(Vector3 pos)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (WardIsLovePlugin.IsLoaded() && DoorInteract.InsideWard(pos))
			{
				return WardMonoscriptExt.GetWardMonoscript(pos).GetZDO();
			}
			foreach (PrivateArea allArea in PrivateArea.m_allAreas)
			{
				if (allArea.IsEnabled() && allArea.IsInside(pos, 0f))
				{
					return allArea.m_nview.GetZDO();
				}
			}
			return null;
		}

		private bool InRange(Vector3 target)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			float num = TriggerRadiusHorizontal.Get();
			float num2 = TriggerRadiusVertical.Get();
			Vector3 val = ((Component)this).transform.position - target;
			Vector3 val2 = new Vector3(val.x, 0f, val.z);
			bool flag = ((Vector3)(ref val2)).sqrMagnitude <= num * num;
			bool flag2 = Mathf.Abs(val.y) <= num2;
			return flag && flag2;
		}

		private void SetPlateVolume(object sender, EventArgs args)
		{
			EffectData[] effectPrefabs = pressEffects.m_effectPrefabs;
			ZSFX val2 = default(ZSFX);
			foreach (EffectData val in effectPrefabs)
			{
				if (val.m_prefab.TryGetComponent<ZSFX>(ref val2))
				{
					float maxVol = (val2.m_minVol = 0.8f * (Plugin.Instance.plateVolume.Value / 100f));
					val2.m_maxVol = maxVol;
				}
			}
			EffectData[] effectPrefabs2 = releaseEffects.m_effectPrefabs;
			ZSFX val4 = default(ZSFX);
			foreach (EffectData val3 in effectPrefabs2)
			{
				if (val3.m_prefab.TryGetComponent<ZSFX>(ref val4))
				{
					float maxVol2 = (val4.m_minVol = 0.9f * (Plugin.Instance.plateVolume.Value / 100f));
					val4.m_maxVol = maxVol2;
				}
			}
		}

		public string GetHoverText()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!zNetView.IsValid())
			{
				return string.Empty;
			}
			if (!PlayerHasAccess(Player.m_localPlayer, ((Component)Player.m_localPlayer).transform.position))
			{
				return Localization.instance.Localize(GetHoverName() + "\n$piece_noaccess");
			}
			string empty = string.Empty;
			empty = ((!IsPowering()) ? (empty + GetHoverName() + ": $pressure_plate_powering_off\n") : (empty + GetHoverName() + ": $pressure_plate_powering_on\n"));
			empty += "[<color=yellow><b>$KEY_Use</b></color>] $piece_use";
			return Localization.instance.Localize(empty);
		}

		public string GetHoverName()
		{
			return Localization.instance.Localize(piece.m_name);
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (hold)
			{
				return false;
			}
			if (!PlayerHasAccess(Player.m_localPlayer, ((Component)Player.m_localPlayer).transform.position))
			{
				return true;
			}
			if (!PressurePlateUI.IsOpen && !PressurePlateUI.instance.IsFrameBlocked)
			{
				PressurePlateUI.instance.OpenUI(this);
			}
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		public void ResetValues()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (!zNetView.IsOwner())
			{
				zNetView.ClaimOwnership();
			}
			ZDOExtraData.ReleaseFloats(zNetView.GetZDO().m_uid);
			ZDOExtraData.ReleaseVec3(zNetView.GetZDO().m_uid);
			ZDOExtraData.ReleaseQuats(zNetView.GetZDO().m_uid);
			ZDOExtraData.ReleaseInts(zNetView.GetZDO().m_uid);
			ZDOExtraData.ReleaseLongs(zNetView.GetZDO().m_uid);
			ZDOExtraData.ReleaseStrings(zNetView.GetZDO().m_uid);
			zNetView.GetZDO().IncreaseDataRevision();
		}

		private void OnDestroy()
		{
			Plugin.Instance.plateVolume.SettingChanged -= SetPlateVolume;
		}
	}
	[BepInPlugin("com.maxsch.valheim.pressure_plate", "Pressure-Plate", "0.10.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModName = "Pressure-Plate";

		public const string ModGuid = "com.maxsch.valheim.pressure_plate";

		public const string ModVersion = "0.10.0";

		private readonly AcceptableValueRange<float> percentRange = new AcceptableValueRange<float>(0f, 100f);

		public ConfigEntry<float> plateVolume;

		private readonly Harmony harmony = new Harmony("com.maxsch.valheim.pressure_plate");

		internal static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			Instance = this;
			harmony.PatchAll(typeof(DoorPatches));
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			localization.AddJsonFile("English", AssetUtils.LoadTextFromResources("English.json"));
			localization.AddJsonFile("German", AssetUtils.LoadTextFromResources("German.json"));
			localization.AddJsonFile("Spanish", AssetUtils.LoadTextFromResources("Spanish.json"));
			localization.AddJsonFile("Portuguese_Brazilian", AssetUtils.LoadTextFromResources("Portuguese_Brazilian.json"));
			localization.AddJsonFile("Russian", AssetUtils.LoadTextFromResources("Russian.json"));
			plateVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "Plate Volume", 100f, new ConfigDescription("Volume of the press and release sound of pressure plates. Value in percent, can be changed while ingame", (AcceptableValueBase)(object)percentRange, Array.Empty<object>()));
			AssetBundle assetBundle = AssetUtils.LoadAssetBundleFromResources("pressure_plate");
			Pieces.Init(assetBundle);
			GUIManager.OnCustomGUIAvailable += delegate
			{
				PressurePlateUI.Init(assetBundle);
			};
			DoorConfig.AddDoorConfig("h_drawbridge01", new DoorConfig
			{
				openClosedInverted = true
			});
			DoorConfig.AddDoorConfig("h_drawbridge02", new DoorConfig
			{
				openClosedInverted = true
			});
		}
	}
	public abstract class PowerState : MonoBehaviour
	{
		public static readonly List<PowerState> AllStates = new List<PowerState>();

		private List<Plate> poweringPlates = new List<Plate>();

		private int prefabId = -1;

		protected virtual void Awake()
		{
			AllStates.Add(this);
		}

		protected virtual void OnDestroy()
		{
			AllStates.Remove(this);
		}

		public DoorConfig GetDoorConfig()
		{
			return DoorConfig.GetDoorConfig(this);
		}

		public int GetState()
		{
			if (!IsReallySpawned(out var zNetView))
			{
				return 0;
			}
			int num = zNetView.GetZDO().GetInt("state", 0);
			DoorConfig doorConfig = GetDoorConfig();
			if (doorConfig == null)
			{
				return num;
			}
			if (doorConfig.openClosedInverted)
			{
				num = 1 - Math.Abs(num);
			}
			return num;
		}

		public bool IsReallySpawned(out ZNetView zNetView)
		{
			zNetView = ((Component)this).GetComponent<ZNetView>();
			return (Object)(object)zNetView != (Object)null && Object.op_Implicit((Object)(object)zNetView) && zNetView.IsValid();
		}

		protected abstract void Interact(Plate plate);

		public abstract bool CanInteract(Player activator, ZDO targetArea);

		public virtual void Open(Plate plate)
		{
			if (IsReallySpawned(out var _) && !IsOpen(plate))
			{
				Interact(plate);
			}
		}

		public virtual void Close(Plate plate)
		{
			if (IsReallySpawned(out var _) && IsOpen(plate))
			{
				Interact(plate);
			}
		}

		public bool IsOpen(Plate plate)
		{
			return ((Object)(object)plate == (Object)null || !plate.Invert.Get()) ? (GetState() != 0) : (GetState() == 0);
		}

		public List<Plate> GetPoweringPlates()
		{
			poweringPlates.RemoveAll((Plate i) => (Object)(object)i == (Object)null);
			return poweringPlates;
		}

		public void AddPoweringPlate(Plate plate)
		{
			if (!GetPoweringPlates().Contains(plate))
			{
				poweringPlates.Add(plate);
			}
		}

		public void RemovePoweringPlate(Plate plate)
		{
			if (GetPoweringPlates().Contains(plate))
			{
				poweringPlates.Remove(plate);
			}
		}

		public static List<PowerState> FindDoorsInPlateRange(Plate plate, Vector3 platePos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return AllStates.FindAll((PowerState i) => i.InRange(platePos, plate.OpenRadiusHorizontal.Get(), plate.OpenRadiusVertical.Get()));
		}

		private bool InRange(Vector3 target, float rangeXZ, float rangeY)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.position - target;
			Vector3 val2 = new Vector3(val.x, 0f, val.z);
			bool flag = ((Vector3)(ref val2)).sqrMagnitude <= rangeXZ * rangeXZ;
			bool flag2 = Mathf.Abs(val.y) <= rangeY;
			return flag && flag2;
		}

		public int GetPrefabId()
		{
			if (prefabId == -1)
			{
				prefabId = StringExtensionMethods.GetStableHashCode(Utils.GetPrefabName(((Component)this).gameObject));
			}
			return prefabId;
		}
	}
	public class PressurePlateUI : MonoBehaviour
	{
		public static PressurePlateUI instance;

		[SerializeField]
		private Transform uiRoot;

		[SerializeField]
		private Text title;

		[SerializeField]
		private InputField triggerRadiusHorizontal;

		[SerializeField]
		private InputField triggerRadiusVertical;

		[SerializeField]
		private InputField openRadiusHorizontal;

		[SerializeField]
		private InputField openRadiusVertical;

		[SerializeField]
		private InputField openTime;

		[SerializeField]
		private InputField triggerDelay;

		[SerializeField]
		private Text allowMobsText;

		[SerializeField]
		private Text onlyOpenNotPermittedText;

		[SerializeField]
		private Toggle invert;

		[SerializeField]
		private Toggle toggleMode;

		[SerializeField]
		private Toggle ignoreWards;

		[SerializeField]
		private Toggle allowMobs;

		[SerializeField]
		private Dropdown mobTameInteraction;

		[SerializeField]
		private Text mobTameInteractionText;

		[SerializeField]
		private Toggle isInvisible;

		[SerializeField]
		private Toggle onlyOpenNotPermitted;

		[SerializeField]
		private Button copyButton;

		[SerializeField]
		private Button pasteButton;

		[SerializeField]
		private Button resetButton;

		private Plate target;

		private Plate copy;

		public static bool IsOpen { get; private set; }

		public bool IsFrameBlocked { get; private set; }

		public static void Init(AssetBundle assetBundle)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = assetBundle.LoadAsset<GameObject>("PressurePlateUI");
			instance = SpawnUI(prefab);
			ApplyAllComponents(instance.uiRoot);
			ApplyWoodpanel(((Component)instance.uiRoot).GetComponent<Image>());
			ApplyText(instance.title, GUIManager.Instance.AveriaSerifBold, GUIManager.Instance.ValheimOrange);
		}

		private static PressurePlateUI SpawnUI(GameObject prefab)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			GameObject val = new GameObject("inactive");
			val.SetActive(false);
			PressurePlateUI component = Object.Instantiate<GameObject>(prefab, val.transform, false).GetComponent<PressurePlateUI>();
			((Component)component.uiRoot).gameObject.SetActive(false);
			((Component)component).transform.SetParent(GUIManager.CustomGUIFront.transform, false);
			Object.Destroy((Object)(object)val);
			return component;
		}

		private void Awake()
		{
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			((UnityEvent<string>)(object)triggerRadiusHorizontal.onValueChanged).AddListener((UnityAction<string>)delegate(string i)
			{
				target.TriggerRadiusHorizontal.ForceSet(i);
			});
			((UnityEvent<string>)(object)triggerRadiusVertical.onValueChanged).AddListener((UnityAction<string>)delegate(string i)
			{
				target.TriggerRadiusVertical.ForceSet(i);
			});
			((UnityEvent<string>)(object)openRadiusHorizontal.onValueChanged).AddListener((UnityAction<string>)delegate(string i)
			{
				target.OpenRadiusHorizontal.ForceSet(i);
			});
			((UnityEvent<string>)(object)openRadiusVertical.onValueChanged).AddListener((UnityAction<string>)delegate(string i)
			{
				target.OpenRadiusVertical.ForceSet(i);
			});
			((UnityEvent<string>)(object)openTime.onValueChanged).AddListener((UnityAction<string>)delegate(string i)
			{
				target.OpenTime.ForceSet(i);
			});
			((UnityEvent<string>)(object)triggerDelay.onValueChanged).AddListener((UnityAction<string>)delegate(string i)
			{
				target.TriggerDelay.ForceSet(i);
			});
			((UnityEvent<bool>)(object)invert.onValueChanged).AddListener((UnityAction<bool>)delegate(bool i)
			{
				target.Invert.ForceSet(i);
			});
			((UnityEvent<bool>)(object)toggleMode.onValueChanged).AddListener((UnityAction<bool>)delegate(bool i)
			{
				target.ToggleModeOption.ForceSet(i);
			});
			((UnityEvent<bool>)(object)ignoreWards.onValueChanged).AddListener((UnityAction<bool>)delegate(bool i)
			{
				target.IgnoreWards.ForceSet(i);
			});
			((UnityEvent<bool>)(object)allowMobs.onValueChanged).AddListener((UnityAction<bool>)delegate(bool i)
			{
				target.AllowMobs.ForceSet(i);
			});
			((UnityEvent<int>)(object)mobTameInteraction.onValueChanged).AddListener((UnityAction<int>)delegate(int i)
			{
				target.MobTameInteraction.ForceSet(i);
			});
			((UnityEvent<bool>)(object)isInvisible.onValueChanged).AddListener((UnityAction<bool>)delegate(bool i)
			{
				target.IsInvisible.ForceSet(i);
			});
			((UnityEvent<bool>)(object)onlyOpenNotPermitted.onValueChanged).AddListener((UnityAction<bool>)delegate(bool i)
			{
				target.OnlyOpenNotPermitted.ForceSet(i);
			});
			((UnityEvent<bool>)(object)ignoreWards.onValueChanged).AddListener((UnityAction<bool>)delegate
			{
				UpdateDeactivated();
			});
			((UnityEvent<bool>)(object)allowMobs.onValueChanged).AddListener((UnityAction<bool>)delegate
			{
				UpdateDeactivated();
			});
			((UnityEvent<int>)(object)mobTameInteraction.onValueChanged).AddListener((UnityAction<int>)delegate
			{
				Localization.instance.Localize(((Component)mobTameInteraction).transform);
			});
			((UnityEvent)copyButton.onClick).AddListener((UnityAction)delegate
			{
				copy = target;
			});
			((UnityEvent)pasteButton.onClick).AddListener((UnityAction)delegate
			{
				target.PasteData(copy);
				UpdateText();
			});
			((UnityEvent)resetButton.onClick).AddListener((UnityAction)delegate
			{
				target.ResetValues();
				UpdateText();
			});
		}

		private void Update()
		{
			IsFrameBlocked = false;
			if (IsOpen && (!Object.op_Implicit((Object)(object)target) || Input.GetKeyDown((KeyCode)27) || ZInput.GetButtonDown("Use") || ZInput.GetButtonDown("Inventory")))
			{
				IsFrameBlocked = true;
				target = null;
				SetGUIState(active: false);
			}
			((Selectable)pasteButton).interactable = (Object)(object)copy != (Object)null;
		}

		public void OpenUI(Plate plate)
		{
			target = plate;
			SetGUIState(active: true);
			UpdateText();
		}

		private void UpdateText()
		{
			title.text = target.GetHoverName();
			triggerRadiusHorizontal.text = target.TriggerRadiusHorizontal.Get().ToString();
			triggerRadiusVertical.text = target.TriggerRadiusVertical.Get().ToString();
			openRadiusHorizontal.text = target.OpenRadiusHorizontal.Get().ToString();
			openRadiusVertical.text = target.OpenRadiusVertical.Get().ToString();
			openTime.text = target.OpenTime.Get().ToString();
			triggerDelay.text = target.TriggerDelay.Get().ToString();
			invert.isOn = target.Invert.Get();
			toggleMode.isOn = target.ToggleModeOption.Get();
			ignoreWards.isOn = target.IgnoreWards.Get();
			allowMobs.isOn = target.AllowMobs.Get();
			mobTameInteraction.value = target.MobTameInteraction.Get();
			isInvisible.isOn = target.IsInvisible.Get();
			onlyOpenNotPermitted.isOn = target.OnlyOpenNotPermitted.Get();
			UpdateDeactivated();
		}

		private void UpdateDeactivated()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)allowMobs).interactable = ignoreWards.isOn;
			((Graphic)allowMobsText).color = (ignoreWards.isOn ? Color.white : Color.grey);
			((Selectable)onlyOpenNotPermitted).interactable = ignoreWards.isOn;
			((Graphic)onlyOpenNotPermittedText).color = (ignoreWards.isOn ? Color.white : Color.grey);
			((Selectable)mobTameInteraction).interactable = ignoreWards.isOn && allowMobs.isOn;
			((Graphic)mobTameInteractionText).color = (((Selectable)mobTameInteraction).interactable ? Color.white : Color.grey);
			((Graphic)mobTameInteraction.captionText).color = (((Selectable)mobTameInteraction).interactable ? Color.white : Color.grey);
		}

		private void SetGUIState(bool active)
		{
			IsOpen = active;
			((Component)uiRoot).gameObject.SetActive(active);
			GUIManager.BlockInput(active);
		}

		public static void ApplyWoodpanel(Image image)
		{
			image.sprite = GUIManager.Instance.GetSprite("woodpanel_trophys");
		}

		public static void ApplyText(Text text, Font font, Color color)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			text.font = font;
			((Graphic)text).color = color;
		}

		public static void ApplyAllDarken(Transform root)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Image[] componentsInChildren = ((Component)root).GetComponentsInChildren<Image>();
			foreach (Image val in componentsInChildren)
			{
				if (((Object)((Component)val).gameObject).name == "Darken")
				{
					val.sprite = GUIManager.Instance.GetSprite("darken_blob");
					((Graphic)val).color = Color.white;
				}
			}
		}

		public static void ApplyAllSunken(Transform root)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Image[] componentsInChildren = ((Component)root).GetComponentsInChildren<Image>();
			foreach (Image val in componentsInChildren)
			{
				if (((Object)((Component)val).gameObject).name == "Sunken")
				{
					val.sprite = GUIManager.Instance.GetSprite("sunken");
					((Graphic)val).color = Color.white;
					val.type = (Type)1;
					val.pixelsPerUnitMultiplier = 1f;
				}
			}
		}

		public static void ApplyAllComponents(Transform root)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Text[] componentsInChildren = ((Component)root).GetComponentsInChildren<Text>();
			foreach (Text text in componentsInChildren)
			{
				ApplyText(text, GUIManager.Instance.AveriaSerif, new Color(73f / 85f, 73f / 85f, 73f / 85f));
			}
			InputField[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<InputField>();
			foreach (InputField val in componentsInChildren2)
			{
				GUIManager.Instance.ApplyInputFieldStyle(val, 16);
			}
			Toggle[] componentsInChildren3 = ((Component)root).GetComponentsInChildren<Toggle>();
			foreach (Toggle val2 in componentsInChildren3)
			{
				GUIManager.Instance.ApplyToogleStyle(val2);
			}
			Button[] componentsInChildren4 = ((Component)root).GetComponentsInChildren<Button>();
			foreach (Button val3 in componentsInChildren4)
			{
				GUIManager.Instance.ApplyButtonStyle(val3, 16);
			}
			Dropdown[] componentsInChildren5 = ((Component)root).GetComponentsInChildren<Dropdown>();
			foreach (Dropdown val4 in componentsInChildren5)
			{
				GUIManager.Instance.ApplyDropdownStyle(val4, 16);
			}
			ApplyAllDarken(root);
			ApplyAllSunken(root);
		}
	}
	public class PressurePlateUIRoot : MonoBehaviour
	{
		private void Start()
		{
			((Component)this).gameObject.AddComponent<Localize>();
		}
	}
	public enum TameInteraction
	{
		All,
		OnlyTames,
		OnlyNonTames
	}
	public abstract class ZNetProperty<T>
	{
		protected readonly ZNetView zNetView;

		public string Key { get; private set; }

		public T DefaultValue { get; private set; }

		protected ZNetProperty(string key, ZNetView zNetView, T defaultValue)
		{
			Key = key;
			DefaultValue = defaultValue;
			this.zNetView = zNetView;
		}

		private void ClaimOwnership()
		{
			if (!zNetView.IsOwner())
			{
				zNetView.ClaimOwnership();
			}
		}

		public void ForceSet(T value)
		{
			ClaimOwnership();
			Set(value);
		}

		public void Set(T value)
		{
			SetValue(value);
		}

		public abstract T Get();

		protected abstract void SetValue(T value);
	}
	public class BoolZNetProperty : ZNetProperty<bool>
	{
		public BoolZNetProperty(string key, ZNetView zNetView, bool defaultValue)
			: base(key, zNetView, defaultValue)
		{
		}

		public override bool Get()
		{
			return zNetView.GetZDO().GetBool(base.Key, base.DefaultValue);
		}

		protected override void SetValue(bool value)
		{
			zNetView.GetZDO().Set(base.Key, value);
		}
	}
	public class FloatZNetProperty : ZNetProperty<float>
	{
		public FloatZNetProperty(string key, ZNetView zNetView, float defaultValue)
			: base(key, zNetView, defaultValue)
		{
		}

		public override float Get()
		{
			return zNetView.GetZDO().GetFloat(base.Key, base.DefaultValue);
		}

		protected override void SetValue(float value)
		{
			zNetView.GetZDO().Set(base.Key, value);
		}

		public void ForceSet(string input)
		{
			Set(input);
		}

		public void Set(string input)
		{
			if (float.TryParse(input, out var result))
			{
				Set(result);
			}
		}
	}
	public class IntZNetProperty : ZNetProperty<int>
	{
		public IntZNetProperty(string key, ZNetView zNetView, int defaultValue)
			: base(key, zNetView, defaultValue)
		{
		}

		public override int Get()
		{
			return zNetView.GetZDO().GetInt(base.Key, base.DefaultValue);
		}

		protected override void SetValue(int value)
		{
			zNetView.GetZDO().Set(base.Key, value);
		}
	}
}
namespace PressurePlate.Compatibility
{
	public class ModCompat
	{
		public static T InvokeMethod<T>(Type type, object instance, string methodName, object[] parameter)
		{
			return (T)(type.GetMethod(methodName)?.Invoke(instance, parameter));
		}

		public static T GetField<T>(Type type, object instance, string fieldName)
		{
			return (T)(type.GetField(fieldName)?.GetValue(instance));
		}
	}
}
namespace PressurePlate.Compatibility.WardIsLove
{
	public class CustomCheck : ModCompat
	{
		public static Type ClassType()
		{
			return Type.GetType("WardIsLove.Util.CustomCheck, WardIsLove");
		}

		public static bool CheckAccess(long playerID, Vector3 point, float radius = 0f, bool flash = true)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			return ModCompat.InvokeMethod<bool>(ClassType(), null, "CheckAccess", new object[4] { playerID, point, radius, flash });
		}
	}
	public static class DoorInteract
	{
		public static bool InsideWard(Vector3 pos)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return WardIsLovePlugin.WardEnabled().Value && WardMonoscript.CheckInWardMonoscript(pos);
		}

		public static bool CanInteract(Player player, Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			return !InsideWard(pos) || CustomCheck.CheckAccess(player.GetPlayerID(), pos, 0f, flash: false) || WardMonoscriptExt.GetWardMonoscript(pos).GetDoorInteractOn();
		}
	}
	public class WardIsLovePlugin : ModCompat
	{
		private const string GUID = "azumatt.WardIsLove";

		private static readonly Version MinVersion = new Version(2, 3, 3);

		public static Type ClassType()
		{
			return Type.GetType("WardIsLove.WardIsLovePlugin, WardIsLove");
		}

		public static bool IsLoaded()
		{
			return Chainloader.PluginInfos.ContainsKey("azumatt.WardIsLove") && Chainloader.PluginInfos["azumatt.WardIsLove"].Metadata.Version >= MinVersion;
		}

		public static ConfigEntry<bool> WardEnabled()
		{
			return ModCompat.GetField<ConfigEntry<bool>>(ClassType(), null, "WardEnabled");
		}
	}
	public class WardMonoscript : ModCompat
	{
		public object targetScript;

		public static Type ClassType()
		{
			return Type.GetType("WardIsLove.Util.WardMonoscript, WardIsLove");
		}

		public WardMonoscript(object targetScript)
		{
			this.targetScript = targetScript;
		}

		public static bool CheckInWardMonoscript(Vector3 point, bool flash = false)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			return ModCompat.InvokeMethod<bool>(ClassType(), null, "CheckInWardMonoscript", new object[2] { point, flash });
		}

		public ZNetView GetZNetView()
		{
			if (targetScript == null)
			{
				return null;
			}
			return ModCompat.GetField<ZNetView>(ClassType(), targetScript, "m_nview");
		}

		public ZDO GetZDO()
		{
			ZNetView zNetView = GetZNetView();
			return ((Object)(object)zNetView != (Object)null && Object.op_Implicit((Object)(object)zNetView) && zNetView.IsValid()) ? zNetView.GetZDO() : null;
		}
	}
	public static class WardMonoscriptExt
	{
		public static Type ClassType()
		{
			return Type.GetType("WardIsLove.Extensions.WardMonoscriptExt, WardIsLove");
		}

		public static WardMonoscript GetWardMonoscript(Vector3 pos)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			object targetScript = ModCompat.InvokeMethod<object>(ClassType(), null, "GetWardMonoscript", new object[1] { pos });
			return new WardMonoscript(targetScript);
		}

		public static bool GetDoorInteractOn(this WardMonoscript wrapper)
		{
			return ModCompat.InvokeMethod<bool>(ClassType(), null, "GetDoorInteractOn", new object[1] { wrapper.targetScript });
		}
	}
}