Decompiled source of WesleysInteriorsAddon v1.1.0

com.github.zehsteam.WesleysInteriorsAddon.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using com.github.zehsteam.WesleysInteriorsAddon.Dependencies;
using com.github.zehsteam.WesleysInteriorsAddon.MonoBehaviours;
using com.github.zehsteam.WesleysInteriorsAddon.NetcodePatcher;
using com.github.zehsteam.WesleysInteriorsAddon.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.WesleysInteriorsAddon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("This is an addon mod for WesleysInteriors. Adds a few new features")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+5571c5c252dce891b004be674bf697b3c332d3ee")]
[assembly: AssemblyProduct("WesleysInteriorsAddon")]
[assembly: AssemblyTitle("com.github.zehsteam.WesleysInteriorsAddon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 com.github.zehsteam.WesleysInteriorsAddon
{
	internal static class ConfigHelper
	{
		public static void SetModIcon(Sprite sprite)
		{
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.SetModIcon(sprite);
			}
		}

		public static void SetModDescription(string description)
		{
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.SetModDescription(description);
			}
		}

		public static void SkipAutoGen()
		{
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.SkipAutoGen();
			}
		}

		public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, bool requiresRestart, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (configFile == null)
			{
				configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
			}
			ConfigEntry<T> configEntry = ((acceptableValues == null) ? configFile.Bind<T>(section, key, defaultValue, description) : configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())));
			if (settingChanged != null)
			{
				configEntry.SettingChanged += delegate
				{
					settingChanged?.Invoke(configEntry.Value);
				};
			}
			if (LethalConfigProxy.Enabled)
			{
				if (acceptableValues == null)
				{
					LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart);
				}
				else
				{
					LethalConfigProxy.AddConfigSlider<T>(configEntry, requiresRestart);
				}
			}
			return configEntry;
		}

		public static void AddButton(string section, string name, string description, string buttonText, Action callback)
		{
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.AddButton(section, name, description, buttonText, callback);
			}
		}
	}
	internal class ConfigManager
	{
		public ConfigEntry<bool> ExtendedLogging;

		public ConfigEntry<bool> ToyStoreNutcracker_Enabled;

		public ConfigEntry<int> ToyStoreNutcracker_MaxSpawnCount;

		public ConfigEntry<bool> ToyStoreNutcracker_SpawnNearPlayers;

		public ConfigEntry<float> ToyStoreNutcracker_MinInitialSpawnDelay;

		public ConfigEntry<float> ToyStoreNutcracker_MaxInitialSpawnDelay;

		public ConfigEntry<float> ToyStoreNutcracker_MinSpawnDelay;

		public ConfigEntry<float> ToyStoreNutcracker_MaxSpawnDelay;

		public ConfigManager()
		{
			BindConfigs();
			ClearUnusedEntries();
		}

		private void BindConfigs()
		{
			ConfigHelper.SkipAutoGen();
			ExtendedLogging = ConfigHelper.Bind("General Settings", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging.");
			string section = "Toy Store Nutcracker Settings";
			ToyStoreNutcracker_Enabled = ConfigHelper.Bind(section, "Enabled", defaultValue: true, requiresRestart: false, "If enabled, the Nutcracker statues will slowly awaken after the apparatus has been pulled.");
			ToyStoreNutcracker_MaxSpawnCount = ConfigHelper.Bind(section, "MaxSpawnCount", 50, requiresRestart: false, "The max amount of Nutcracker statues that can awaken.");
			ToyStoreNutcracker_SpawnNearPlayers = ConfigHelper.Bind(section, "SpawnNearPlayers", defaultValue: true, requiresRestart: false, "If enabled, the Nutcracker statues will awaken near players.");
			ToyStoreNutcracker_MinInitialSpawnDelay = ConfigHelper.Bind(section, "MinInitialSpawnDelay", 5f, requiresRestart: false, "The min delay in seconds before the Nutcracker statues start to awaken after the apparatus has been pulled.");
			ToyStoreNutcracker_MaxInitialSpawnDelay = ConfigHelper.Bind(section, "MaxInitialSpawnDelay", 20f, requiresRestart: false, "The max delay in seconds before the Nutcracker statues start to awaken after the apparatus has been pulled.");
			ToyStoreNutcracker_MinSpawnDelay = ConfigHelper.Bind(section, "MinSpawnDelay", 5f, requiresRestart: false, "The min delay in seconds between Nutcracker statue activations.");
			ToyStoreNutcracker_MaxSpawnDelay = ConfigHelper.Bind(section, "MaxSpawnDelay", 25f, requiresRestart: false, "The max delay in seconds between Nutcracker statue activations.");
		}

		private void ClearUnusedEntries()
		{
			ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config;
			PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null);
			dictionary.Clear();
			config.Save();
		}
	}
	internal static class Content
	{
		public static GameObject NetworkHandlerPrefab;

		public static void Load()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			try
			{
				AssetBundle val = LoadAssetBundle("wesleysinteriorsaddon_assets");
				NetworkHandlerPrefab = val.LoadAsset<GameObject>("NetworkHandler");
				NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
				Plugin.logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
			catch (Exception arg)
			{
				Plugin.logger.LogError((object)$"Failed to load assets from AssetBundle.\n\n{arg}");
			}
		}

		private static AssetBundle LoadAssetBundle(string fileName)
		{
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
			string text = Path.Combine(directoryName, fileName);
			return AssetBundle.LoadFromFile(text);
		}
	}
	internal static class EnemyHelper
	{
		public static void SpawnNutcrackerOnServer(Vector3 position, float yRot)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkUtils.IsServer)
			{
				Plugin.logger.LogError((object)"Only the host can spawn enemies.");
			}
			else
			{
				SpawnEnemyOnServer("Nutcracker", position, yRot);
			}
		}

		public static void SpawnEnemyOnServer(string enemyName, Vector3 position, float yRot)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkUtils.IsServer)
			{
				Plugin.logger.LogError((object)"Only the host can spawn enemies.");
				return;
			}
			EnemyType enemyType = GetEnemyType(enemyName);
			if ((Object)(object)enemyType == (Object)null)
			{
				Plugin.logger.LogError((object)("Failed to find EnemyType \"" + enemyName + "\"."));
				return;
			}
			RoundManager.Instance.SpawnEnemyGameObject(position, yRot, -1, enemyType);
			Plugin.Instance.LogInfoExtended($"Spawned \"{enemyType.enemyName}\" at position: ({position.x}, {position.y}, {position.z}), yRot: {yRot}");
		}

		public static EnemyType GetEnemyType(string enemyName)
		{
			foreach (EnemyType enemyType in GetEnemyTypes())
			{
				if (enemyType.enemyName == enemyName)
				{
					return enemyType;
				}
			}
			try
			{
				EnemyType val = Resources.FindObjectsOfTypeAll<EnemyType>().Single((EnemyType x) => x.enemyName == enemyName);
				if (IsValidEnemyType(val) && NetworkUtils.IsNetworkPrefab(val.enemyPrefab))
				{
					Plugin.Instance.LogInfoExtended("Found EnemyType \"" + val.enemyName + "\" from Resources.");
					return val;
				}
			}
			catch
			{
			}
			return null;
		}

		public static List<EnemyType> GetEnemyTypes()
		{
			HashSet<EnemyType> hashSet = new HashSet<EnemyType>(new EnemyTypeComparer());
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				IEnumerable<EnemyType> enumerable = (from e in val.Enemies.Concat(val.DaytimeEnemies).Concat(val.OutsideEnemies)
					select e.enemyType).Where(IsValidEnemyType);
				foreach (EnemyType item in enumerable)
				{
					hashSet.Add(item);
				}
			}
			return hashSet.ToList();
		}

		public static bool IsValidEnemyType(EnemyType enemyType)
		{
			if ((Object)(object)enemyType == (Object)null)
			{
				return false;
			}
			if (string.IsNullOrWhiteSpace(enemyType.enemyName))
			{
				return false;
			}
			if ((Object)(object)enemyType.enemyPrefab == (Object)null)
			{
				return false;
			}
			return true;
		}
	}
	public class EnemyTypeComparer : IEqualityComparer<EnemyType>
	{
		public bool Equals(EnemyType x, EnemyType y)
		{
			if ((Object)(object)x == (Object)null || (Object)(object)y == (Object)null)
			{
				return false;
			}
			return x.enemyName == y.enemyName;
		}

		public int GetHashCode(EnemyType obj)
		{
			return obj.enemyName?.GetHashCode() ?? 0;
		}
	}
	internal static class InteriorHelper
	{
		public static string GetDungeonName()
		{
			string dungeonName;
			return TryGetDungeonName(out dungeonName) ? dungeonName : string.Empty;
		}

		public static bool TryGetDungeonName(out string dungeonName)
		{
			dungeonName = string.Empty;
			try
			{
				ExtendedDungeonFlow currentExtendedDungeonFlow = DungeonManager.CurrentExtendedDungeonFlow;
				if ((Object)(object)currentExtendedDungeonFlow == (Object)null)
				{
					return false;
				}
				dungeonName = currentExtendedDungeonFlow.DungeonName;
				return true;
			}
			catch
			{
				Plugin.logger.LogError((object)"Failed to get dungeon name.");
				return false;
			}
		}

		public static bool IsToyStoreInterior()
		{
			string dungeonName = GetDungeonName();
			if (dungeonName.Equals("ToystoreFlow", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (dungeonName.Equals("Toy Store", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}
	}
	internal static class NetworkUtils
	{
		public static bool IsServer
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return false;
				}
				return NetworkManager.Singleton.IsServer;
			}
		}

		public static bool IsHost
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return false;
				}
				return NetworkManager.Singleton.IsHost;
			}
		}

		public static ulong GetLocalClientId()
		{
			return NetworkManager.Singleton.LocalClientId;
		}

		public static bool IsLocalClientId(ulong clientId)
		{
			return clientId == GetLocalClientId();
		}

		public static bool IsNetworkPrefab(GameObject prefab)
		{
			foreach (NetworkPrefab prefab2 in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs)
			{
				if ((Object)(object)prefab2.Prefab == (Object)(object)prefab)
				{
					return true;
				}
			}
			return false;
		}
	}
	internal static class PlayerUtils
	{
		public static PlayerControllerB GetLocalPlayerScript()
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return null;
			}
			return GameNetworkManager.Instance.localPlayerController;
		}

		public static bool IsLocalPlayer(PlayerControllerB playerScript)
		{
			return (Object)(object)playerScript == (Object)(object)GetLocalPlayerScript();
		}

		public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.actualClientId == clientId)
				{
					return val;
				}
			}
			return null;
		}

		public static List<PlayerControllerB> GetPlayerScripts()
		{
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.isInHangarShipRoom || val.isInsideFactory || val.isInElevator)
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static PlayerControllerB GetRandomPlayerScript(bool onlyAlivePlayers = true, bool onlyPlayersInsideFactory = true)
		{
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			foreach (PlayerControllerB playerScript in GetPlayerScripts())
			{
				if ((!onlyAlivePlayers || !playerScript.isPlayerDead) && (!onlyPlayersInsideFactory || playerScript.isInsideFactory))
				{
					list.Add(playerScript);
				}
			}
			if (list.Count == 0)
			{
				return null;
			}
			return list[Random.Range(0, list.Count)];
		}
	}
	[BepInPlugin("com.github.zehsteam.WesleysInteriorsAddon", "WesleysInteriorsAddon", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.github.zehsteam.WesleysInteriorsAddon");

		internal static Plugin Instance;

		internal static ManualLogSource logger;

		internal static ConfigManager ConfigManager;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = Logger.CreateLogSource("com.github.zehsteam.WesleysInteriorsAddon");
			logger.LogInfo((object)"WesleysInteriorsAddon has awoken!");
			harmony.PatchAll(typeof(GameNetworkManagerPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(LungPropPatch));
			ConfigManager = new ConfigManager();
			Content.Load();
			NetcodePatcherAwake();
		}

		private void NetcodePatcherAwake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		public void OnLocalDisconnect()
		{
			ToyStore.Reset();
		}

		public void OnFinishGeneratingLevel()
		{
			ToyStore.FindNutcrackerStatues();
		}

		public void OnShipHasLeft()
		{
			ToyStore.Reset();
		}

		public void OnApparatusRemoved()
		{
			logger.LogInfo((object)"Apparatus was pulled.");
			ToyStore.OnApparatusRemoved();
		}

		public void LogInfoExtended(object data)
		{
			if (ConfigManager.ExtendedLogging.Value)
			{
				logger.LogInfo(data);
			}
		}
	}
	internal static class ToyStore
	{
		private static List<GameObject> _nutcrackerObjects = new List<GameObject>();

		private static Coroutine _activateNutcrackerStatuesOnServerCoroutine = null;

		public static void Reset()
		{
			_nutcrackerObjects = new List<GameObject>();
			if (_activateNutcrackerStatuesOnServerCoroutine != null)
			{
				((MonoBehaviour)StartOfRound.Instance).StopCoroutine(_activateNutcrackerStatuesOnServerCoroutine);
			}
		}

		public static void FindNutcrackerStatues()
		{
			if (InteriorHelper.IsToyStoreInterior())
			{
				_nutcrackerObjects = GetNutcrackerStatues();
				Plugin.logger.LogInfo((object)$"Found {_nutcrackerObjects.Count} Nutcracker statues.");
			}
		}

		public static void OnApparatusRemoved()
		{
			if (NetworkUtils.IsServer && InteriorHelper.IsToyStoreInterior() && Plugin.ConfigManager.ToyStoreNutcracker_Enabled.Value)
			{
				_activateNutcrackerStatuesOnServerCoroutine = ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(ActivateNutcrackerStatuesOnServerCoroutine());
			}
		}

		private static IEnumerator ActivateNutcrackerStatuesOnServerCoroutine()
		{
			Plugin.logger.LogInfo((object)"Started Nutcracker spawn coroutine");
			if (!NetworkUtils.IsServer)
			{
				Plugin.logger.LogError((object)"Ended Nutcracker spawn coroutine. You are not the host!");
				yield break;
			}
			if (!Plugin.ConfigManager.ToyStoreNutcracker_Enabled.Value)
			{
				Plugin.logger.LogWarning((object)"Ended Nutcracker spawn coroutine. Nutcracker spawning is disabled in the config settings.");
				yield break;
			}
			if (_nutcrackerObjects == null || _nutcrackerObjects.Count == 0)
			{
				Plugin.logger.LogWarning((object)"Ended Nutcracker spawn coroutine. No Nutcracker statues were found.");
				yield break;
			}
			float minInitialSpawnDelay = Plugin.ConfigManager.ToyStoreNutcracker_MinInitialSpawnDelay.Value;
			float maxInitialSpawnDelay = Plugin.ConfigManager.ToyStoreNutcracker_MaxInitialSpawnDelay.Value;
			float initialSpawnDelay = Mathf.Max(Random.Range(minInitialSpawnDelay, maxInitialSpawnDelay), 0f);
			Plugin.Instance.LogInfoExtended($"Initial spawn delay: {initialSpawnDelay} seconds.");
			yield return (object)new WaitForSeconds(initialSpawnDelay);
			Plugin.Instance.LogInfoExtended("Started awakening Nutcracker statues.");
			int amount = _nutcrackerObjects.Count;
			int spawnCount = 0;
			for (int i = 0; i < amount; i++)
			{
				if (!Plugin.ConfigManager.ToyStoreNutcracker_Enabled.Value)
				{
					Plugin.Instance.LogInfoExtended("Nutcracker spawning has been disabled in the config settings.");
					break;
				}
				int maxSpawnCount = Plugin.ConfigManager.ToyStoreNutcracker_MaxSpawnCount.Value;
				if (spawnCount >= maxSpawnCount)
				{
					Plugin.Instance.LogInfoExtended($"The max Nutcracker spawn count of {maxSpawnCount} has been reached.");
					break;
				}
				int index = GetNutcrackerStatueIndex();
				if (index < 0)
				{
					Plugin.logger.LogError((object)"Invalid Nutcracker statue index received.");
					break;
				}
				ActivateNutcrackerStatueOnServer(_nutcrackerObjects[index]);
				_nutcrackerObjects.RemoveAt(index);
				spawnCount++;
				float minSpawnDelay = Plugin.ConfigManager.ToyStoreNutcracker_MinSpawnDelay.Value;
				float maxSpawnDelay = Plugin.ConfigManager.ToyStoreNutcracker_MaxSpawnDelay.Value;
				float spawnDelay = Mathf.Max(Random.Range(minSpawnDelay, maxSpawnDelay), 0.25f);
				yield return (object)new WaitForSeconds(spawnDelay);
			}
			Plugin.logger.LogInfo((object)$"Nutcracker spawn coroutine has ended. Spawned {spawnCount}/{amount} Nutcrackers.");
		}

		private static int GetNutcrackerStatueIndex()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (_nutcrackerObjects == null || _nutcrackerObjects.Count == 0)
			{
				return -1;
			}
			if (Plugin.ConfigManager.ToyStoreNutcracker_SpawnNearPlayers.Value)
			{
				PlayerControllerB randomPlayerScript = PlayerUtils.GetRandomPlayerScript();
				if ((Object)(object)randomPlayerScript == (Object)null)
				{
					return GetRandomNutcrackerStatueIndex();
				}
				return GetNutcrackerStatueIndexNearPosition(((Component)randomPlayerScript).transform.position);
			}
			return GetRandomNutcrackerStatueIndex();
		}

		private static int GetRandomNutcrackerStatueIndex()
		{
			if (_nutcrackerObjects == null || _nutcrackerObjects.Count == 0)
			{
				return -1;
			}
			return Random.Range(0, _nutcrackerObjects.Count);
		}

		private static int GetNutcrackerStatueIndexNearPosition(Vector3 position)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (_nutcrackerObjects == null || _nutcrackerObjects.Count == 0)
			{
				return -1;
			}
			int result = -1;
			float num = float.PositiveInfinity;
			for (int i = 0; i < _nutcrackerObjects.Count; i++)
			{
				if (!((Object)(object)_nutcrackerObjects[i] == (Object)null))
				{
					float num2 = Vector3.Distance(_nutcrackerObjects[i].transform.position, position);
					if (num2 < num)
					{
						result = i;
						num = num2;
					}
				}
			}
			return result;
		}

		private static void ActivateNutcrackerStatueOnServer(GameObject nutcrackerObject)
		{
			//IL_001a: 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_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_0048: 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)
			if (NetworkUtils.IsServer)
			{
				PluginNetworkBehaviour.Instance.HideNutcrackerStatueClientRpc(nutcrackerObject.transform.position);
				HideNutcrackerStatueOnLocalClient(nutcrackerObject.transform.position);
				Vector3 position = nutcrackerObject.transform.position;
				float y = nutcrackerObject.transform.eulerAngles.y;
				EnemyHelper.SpawnNutcrackerOnServer(position, y);
			}
		}

		public static void HideNutcrackerStatueOnLocalClient(Vector3 position)
		{
			//IL_0020: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			foreach (GameObject nutcrackerObject in _nutcrackerObjects)
			{
				if (Vector3.Distance(nutcrackerObject.transform.position, position) <= 0.25f)
				{
					val = nutcrackerObject;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.logger.LogError((object)$"Failed to hide Nutcracker statue. Could not find Nutcracker statue at position: ({position.x}, {position.y}, {position.z})");
			}
			else
			{
				val.SetActive(false);
			}
		}

		private static List<GameObject> GetNutcrackerStatues()
		{
			List<GameObject> list = new List<GameObject>();
			foreach (GameObject item in from _ in Object.FindObjectsByType<Tile>((FindObjectsSortMode)0)
				select ((Component)_).gameObject)
			{
				list.AddRange(GetNutcrackerStatuesInTile(item));
			}
			return list;
		}

		private static List<GameObject> GetNutcrackerStatuesInTile(GameObject tileObject)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			List<GameObject> list = new List<GameObject>();
			foreach (GameObject item in from _ in tileObject.GetComponentsInChildren<LODGroup>()
				select ((Component)_).gameObject)
			{
				if (((Object)item).name.Contains("LOD0"))
				{
					GameObject gameObject = ((Component)item.transform.parent).gameObject;
					if (((Object)gameObject).name.Contains("LOD0") && !list.Contains(gameObject) && !_nutcrackerObjects.Contains(gameObject) && !(gameObject.transform.localScale != new Vector3(0.3f, 0.3f, 0.3f)))
					{
						list.Add(gameObject);
					}
				}
			}
			return list;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.WesleysInteriorsAddon";

		public const string PLUGIN_NAME = "WesleysInteriorsAddon";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace com.github.zehsteam.WesleysInteriorsAddon.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			AddNetworkPrefabs();
		}

		private static void AddNetworkPrefabs()
		{
			AddNetworkPrefab(Content.NetworkHandlerPrefab);
		}

		private static void AddNetworkPrefab(GameObject prefab)
		{
			if (!((Object)(object)prefab == (Object)null))
			{
				NetworkManager.Singleton.AddNetworkPrefab(prefab);
				Plugin.logger.LogInfo((object)("Registered \"" + ((Object)prefab).name + "\" network prefab."));
			}
		}
	}
	[HarmonyPatch(typeof(LungProp))]
	internal static class LungPropPatch
	{
		[HarmonyPatch("EquipItem")]
		[HarmonyPrefix]
		private static void EquipItemPatch(ref LungProp __instance)
		{
			if (__instance.isLungDocked)
			{
				Plugin.Instance.OnApparatusRemoved();
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal static class RoundManagerPatch
	{
		[HarmonyPatch("FinishGeneratingLevel")]
		[HarmonyPostfix]
		[HarmonyPriority(300)]
		private static void FinishGeneratingLevelPatch()
		{
			Plugin.Instance.OnFinishGeneratingLevel();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch()
		{
			SpawnNetworkHandler();
		}

		private static void SpawnNetworkHandler()
		{
			//IL_0014: 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)
			if (NetworkUtils.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(Content.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPatch("OnLocalDisconnect")]
		[HarmonyPrefix]
		private static void OnLocalDisconnectPatch()
		{
			Plugin.Instance.OnLocalDisconnect();
		}

		[HarmonyPatch("ShipHasLeft")]
		[HarmonyPostfix]
		private static void ShipHasLeftPatch()
		{
			Plugin.Instance.OnShipHasLeft();
		}
	}
}
namespace com.github.zehsteam.WesleysInteriorsAddon.MonoBehaviours
{
	internal class PluginNetworkBehaviour : NetworkBehaviour
	{
		public static PluginNetworkBehaviour Instance;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
		}

		[ClientRpc]
		public void HideNutcrackerStatueClientRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1017602883u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1017602883u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkUtils.IsServer)
				{
					ToyStore.HideNutcrackerStatueOnLocalClient(position);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PluginNetworkBehaviour()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1017602883u, new RpcReceiveHandler(__rpc_handler_1017602883));
		}

		private static void __rpc_handler_1017602883(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PluginNetworkBehaviour)(object)target).HideNutcrackerStatueClientRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PluginNetworkBehaviour";
		}
	}
}
namespace com.github.zehsteam.WesleysInteriorsAddon.Dependencies
{
	internal static class LethalConfigProxy
	{
		public const string PLUGIN_GUID = "ainavt.lc.lethalconfig";

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetModIcon(Sprite sprite)
		{
			LethalConfigManager.SetModIcon(sprite);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetModDescription(string description)
		{
			LethalConfigManager.SetModDescription(description);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SkipAutoGen()
		{
			LethalConfigManager.SkipAutoGen();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			if (!(configEntry is ConfigEntry<string> val))
			{
				if (!(configEntry is ConfigEntry<bool> val2))
				{
					if (!(configEntry is ConfigEntry<float> val3))
					{
						if (!(configEntry is ConfigEntry<int> val4))
						{
							throw new NotSupportedException($"Unsupported type: {typeof(T)}");
						}
						LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart));
					}
					else
					{
						LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart));
					}
				}
				else
				{
					LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart));
				}
			}
			else
			{
				LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart));
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if (!(configEntry is ConfigEntry<float> val))
			{
				if (!(configEntry is ConfigEntry<int> val2))
				{
					throw new NotSupportedException($"Slider not supported for type: {typeof(T)}");
				}
				LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart));
			}
			else
			{
				LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart));
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddButton(string section, string name, string description, string buttonText, Action callback)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate
			{
				callback?.Invoke();
			}));
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace com.github.zehsteam.WesleysInteriorsAddon.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}