Decompiled source of FeralCompany v1.0.10

plugins/FeralCompany/FeralCompany.dll

Decompiled 3 months ago
using System;
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.Configuration;
using BepInEx.Logging;
using FeralCompany.Core;
using FeralCompany.Core.Locale;
using FeralCompany.Core.Setting;
using FeralCompany.Core.UI;
using FeralCompany.Modules;
using FeralCompany.Modules.Map;
using FeralCompany.Modules.Map.Pointers;
using FeralCompany.Modules.Map.Targets;
using FeralCompany.Modules.SettingsMenu.UI;
using FeralCompany.Utils;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FeralCompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.10.0")]
[assembly: AssemblyInformationalVersion("1.0.10+e801a48b85d983bedd2a9410350d52a5a053c230")]
[assembly: AssemblyProduct("FeralCompany")]
[assembly: AssemblyTitle("FeralCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 FeralCompany
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("FeralCompany", "FeralCompany", "1.0.0")]
	public class Feral : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerControllerB))]
		private static class AwaitGameStart
		{
			[HarmonyPostfix]
			[HarmonyPatch("ConnectClientToPlayerObject")]
			private static void Postfix_ConnectClientToPlayerObject(PlayerControllerB __instance)
			{
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)__instance)
				{
					_instance.TriggerGame(GameNetworkManager.Instance.localPlayerController);
				}
			}
		}

		private static Feral _instance;

		private Harmony _harmony;

		private GameObject _binder;

		internal static FeralSettings Settings { get; private set; }

		internal static FeralOutput IO { get; private set; }

		internal static FeralAssets Assets { get; private set; }

		internal static FeralLocales Locales { get; private set; }

		internal static FeralEvents Events { get; private set; }

		internal static FeralBindings Bindings { get; private set; }

		internal static HUDManager HUD => HUDManager.Instance;

		internal static StartOfRound StartOfRound => StartOfRound.Instance;

		internal static PlayerControllerB Player { get; private set; }

		internal static CurrentRoundData CurrentRound { get; private set; }

		internal static GlobalData Globals { get; private set; }

		internal static FeralMap Map { get; private set; }

		internal static FeralNightVision NightVision { get; private set; }

		private void Awake()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			_instance = this;
			IO = new FeralOutput(((BaseUnityPlugin)this).Logger);
			Settings = new FeralSettings(((BaseUnityPlugin)this).Config);
			Assets = new FeralAssets();
			if (Assets.Load())
			{
				Locales = new FeralLocales();
				if (Locales.Init())
				{
					Events = new FeralEvents();
					Bindings = new FeralBindings();
					Bindings.Disable();
					_harmony = new Harmony("FeralCompany");
					_harmony.PatchAll(typeof(AwaitGameStart));
					Events.OnExitGame += Unload;
				}
			}
		}

		private void Unload()
		{
			_harmony.UnpatchSelf();
			Object.Destroy((Object)(object)_binder);
			Bindings.Disable();
			_harmony.PatchAll(typeof(AwaitGameStart));
		}

		private void TriggerGame(PlayerControllerB player)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			Bindings.Enable();
			Player = player;
			_binder = new GameObject("FeralGame");
			CurrentRound = _binder.AddComponent<CurrentRoundData>();
			Globals = _binder.AddComponent<GlobalData>();
			Map = _binder.AddComponent<FeralMap>();
			NightVision = _binder.AddComponent<FeralNightVision>();
			_harmony.PatchAll();
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_binder))
			{
				Object.Destroy((Object)(object)_binder);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FeralCompany";

		public const string PLUGIN_NAME = "FeralCompany";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace FeralCompany.Utils
{
	public class Cache<T>
	{
		[CompilerGenerated]
		private Func<T> <supplier>P;

		private T? _value;

		internal T Value => GetOrLoad();

		internal bool IsLoaded { get; private set; }

		public Cache(Func<T> supplier)
		{
			<supplier>P = supplier;
			base..ctor();
		}

		internal bool GetIfLoaded(out T? value)
		{
			if (IsLoaded)
			{
				value = _value;
				return true;
			}
			value = default(T);
			return false;
		}

		private T GetOrLoad()
		{
			if (IsLoaded)
			{
				return _value;
			}
			_value = <supplier>P();
			IsLoaded = true;
			return _value;
		}

		public static implicit operator T(Cache<T> cache)
		{
			return cache.Value;
		}
	}
	public static class FieldSearcher
	{
		private const BindingFlags StaticAttributeFilter = BindingFlags.Static | BindingFlags.Public;

		public static List<T> Search<T>(Type from)
		{
			List<T> fields = new List<T>();
			SearchInternal(from, BindingFlags.Static | BindingFlags.Public, ref fields);
			Type[] nestedTypes = from.GetNestedTypes(BindingFlags.Static | BindingFlags.Public);
			for (int i = 0; i < nestedTypes.Length; i++)
			{
				SearchInternal(nestedTypes[i], BindingFlags.Static | BindingFlags.Public, ref fields);
			}
			return fields;
		}

		private static void SearchInternal<T>(IReflect from, BindingFlags filter, ref List<T> fields)
		{
			FieldInfo[] fields2 = from.GetFields(filter);
			for (int i = 0; i < fields2.Length; i++)
			{
				if (fields2[i].GetValue(null) is T item)
				{
					fields.Add(item);
				}
			}
		}
	}
	internal static class Files
	{
		private static readonly string RootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		public static readonly string LocalePath = Path.Combine(RootPath, "Locales");
	}
	public static class Mask
	{
		internal const int Default = 1;

		internal const int TransparentFX = 2;

		internal const int IgnoreRaycast = 4;

		internal const int Player = 8;

		internal const int Water = 16;

		internal const int UI = 32;

		internal const int Props = 64;

		internal const int HelmetVisor = 128;

		internal const int Room = 256;

		internal const int InteractableObject = 512;

		internal const int Foliage = 1024;

		internal const int Colliders = 2048;

		internal const int PhysicsObject = 4096;

		internal const int Triggers = 8192;

		internal const int MapRadar = 16384;

		internal const int NavigationSurface = 32768;

		internal const int RoomLight = 65536;

		internal const int Anomaly = 131072;

		internal const int LineOfSight = 262144;

		internal const int Enemies = 524288;

		internal const int PlayerRagdoll = 1048576;

		internal const int MapHazards = 2097152;

		internal const int ScanNode = 4194304;

		internal const int EnemiesNotRendered = 8388608;

		internal const int MiscLevelGeometry = 16777216;

		internal const int Terrain = 33554432;

		internal const int PlaceableShipObjects = 67108864;

		internal const int PlacementBlocker = 134217728;

		internal const int Railing = 268435456;

		internal const int DecalStickableSurface = 536870912;

		internal const int Unused1 = 1073741824;

		internal const int Unused2 = int.MinValue;

		internal static readonly Dictionary<string, int> NameToMask = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
		{
			{ "Default", 1 },
			{ "TransparentFX", 2 },
			{ "IgnoreRaycast", 4 },
			{ "Player", 8 },
			{ "Water", 16 },
			{ "UI", 32 },
			{ "Props", 64 },
			{ "HelmetVisor", 128 },
			{ "Room", 256 },
			{ "InteractableObject", 512 },
			{ "Foliage", 1024 },
			{ "Colliders", 2048 },
			{ "PhysicsObject", 4096 },
			{ "Triggers", 8192 },
			{ "MapRadar", 16384 },
			{ "NavigationSurface", 32768 },
			{ "RoomLight", 65536 },
			{ "Anomaly", 131072 },
			{ "LineOfSight", 262144 },
			{ "Enemies", 524288 },
			{ "PlayerRagdoll", 1048576 },
			{ "MapHazards", 2097152 },
			{ "ScanNode", 4194304 },
			{ "EnemiesNotRendered", 8388608 },
			{ "MiscLevelGeometry", 16777216 },
			{ "Terrain", 33554432 },
			{ "PlaceableShipObjects", 67108864 },
			{ "PlacementBlocker", 134217728 },
			{ "Railing", 268435456 },
			{ "DecalStickableSurface", 536870912 },
			{ "Unused1", 1073741824 },
			{
				"Unused2",
				int.MinValue
			}
		};

		internal static string[] Names => NameToMask.Keys.ToArray();

		internal static int AddMask(this int mask, int other)
		{
			return mask | other;
		}

		internal static int AddMask(this int mask, params int[] others)
		{
			return others.Aggregate(mask, AddMask);
		}

		internal static int SubtractMask(this int mask, int other)
		{
			return mask & ~other;
		}

		internal static int SubtractMask(int mask, params int[] others)
		{
			return others.Aggregate(mask, SubtractMask);
		}

		internal static bool Contains(int mask, int other)
		{
			return (mask & other) == other;
		}

		internal static bool ContainsAny(int mask, params int[] others)
		{
			return others.Any((int other) => Contains(mask, other));
		}

		internal static bool ContainsAll(int mask, params int[] others)
		{
			return others.All((int other) => Contains(mask, other));
		}

		internal static int Named(string input)
		{
			if (string.IsNullOrWhiteSpace(input))
			{
				throw new ArgumentException("Mask name cannot be blank.", "input");
			}
			if (NameToMask.TryGetValue(input, out var value))
			{
				return value;
			}
			throw new ArgumentException("Unknown or invalid mask name: " + input, "input");
		}

		internal static string[] Decompress(int mask)
		{
			List<string> list = new List<string>();
			list.AddRange(NameToMask.Where<KeyValuePair<string, int>>(delegate(KeyValuePair<string, int> pair)
			{
				int mask2 = mask;
				KeyValuePair<string, int> keyValuePair2 = pair;
				return Contains(mask2, keyValuePair2.Value);
			}).Select(delegate(KeyValuePair<string, int> pair)
			{
				KeyValuePair<string, int> keyValuePair = pair;
				return keyValuePair.Key;
			}));
			return list.ToArray();
		}
	}
	internal static class Reflection
	{
		internal static void Invoke<T>(T instance, string methodName, params object[] parameters)
		{
			typeof(T).GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(instance, parameters);
		}

		internal static R Invoke<T, R>(T instance, string methodName, params object[] parameters)
		{
			object obj = typeof(T).GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(instance, parameters);
			if (obj is R)
			{
				return (R)obj;
			}
			throw new ArgumentOutOfRangeException();
		}
	}
}
namespace FeralCompany.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		private static bool _subscribed;

		[HarmonyPostfix]
		[HarmonyPatch("SubscribeToConnectionCallbacks")]
		private static void PostFix_SubscribeToConnectionCallbacks()
		{
			if (_subscribed)
			{
				NetworkManager.Singleton.OnClientConnectedCallback += Feral.Events.InvokeClientConnect;
				NetworkManager.Singleton.OnClientDisconnectCallback += Feral.Events.InvokeClientDisconnect;
				_subscribed = true;
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	public static class QuickMenuManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("LeaveGameConfirm")]
		private static void PostFix_LeaveGameConfirm()
		{
			Feral.Events.InvokeExitGame();
		}
	}
	[HarmonyPatch(typeof(RadarBoosterItem))]
	internal static class RadarBoosterItemPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("AddBoosterToRadar")]
		private static void Postfix_AddBoosterToRadar(RadarBoosterItem __instance)
		{
			Feral.Events.InvokeAddRadarBooster(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch("RemoveBoosterFromRadar")]
		private static void Postfix_RemoveBoosterFromRadar(RadarBoosterItem __instance)
		{
			Feral.Events.InvokeRemoveRadarBooster(__instance);
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public static class RoundManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("RefreshEnemiesList")]
		private static void PostFix_RefreshEnemiesList()
		{
			Feral.Events.InvokeEnterMoon();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public static class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("EndOfGame")]
		private static void PostFix_EndOfGame()
		{
			Feral.Events.InvokeExitMoon();
		}
	}
}
namespace FeralCompany.Modules
{
	public sealed class CurrentRoundData : MonoBehaviour
	{
		private readonly List<MapPointer> _pointers = new List<MapPointer>();

		internal IReadOnlyList<MapPointer> Pointers => _pointers;

		private void OnExitMoon()
		{
			foreach (MapPointer pointer in _pointers)
			{
				Object.Destroy((Object)(object)pointer.PointerObject);
			}
			_pointers.Clear();
		}

		private void OnEnterMoon()
		{
			//IL_0022: 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)
			GameObject val = GameObject.Find("CatwalkShip") ?? throw new NullReferenceException("CatwalkShip not available??");
			CreatePointer(-1, val.transform.position, entrance: false);
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
			foreach (EntranceTeleport val2 in array)
			{
				CreatePointer(val2.entranceId, val2.entrancePoint.position, val2.isEntranceToBuilding);
			}
			Feral.Events.InvokePointersCreated(_pointers.ToArray());
		}

		private void Awake()
		{
			Feral.Events.OnEnterMoon += OnEnterMoon;
			Feral.Events.OnExitMoon += OnExitMoon;
		}

		private void OnDestroy()
		{
			Feral.Events.OnEnterMoon -= OnEnterMoon;
			Feral.Events.OnExitMoon -= OnExitMoon;
		}

		private void CreatePointer(int entranceId, Vector3 destination, bool entrance)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(Feral.Assets.PrefabMapPointer);
			((Object)val).name = string.Format("Pointer_{0}_{1}", entranceId, entrance ? "Entrance" : "Exit");
			PointerController pointerController = val.AddComponent<PointerController>();
			MapPointer mapPointer = entranceId switch
			{
				-1 => new ShipPointer(val, pointerController, destination, entranceId, entrance), 
				0 => new MainEntrancePointer(val, pointerController, destination, entranceId, entrance), 
				_ => new FireExitPointer(val, pointerController, destination, entranceId, entrance), 
			};
			pointerController.Icon = mapPointer.GetIcon();
			_pointers.Add(mapPointer);
		}
	}
	public class FeralNightVision : MonoBehaviour
	{
		private Light _nearLight;

		private Light _farLight;

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = GameObject.Find("MapCamera").transform;
			((Component)this).transform.SetParent(((Component)Feral.Player.gameplayCamera).transform);
			_nearLight = new GameObject("NearLight").AddComponent<Light>();
			((Component)_nearLight).transform.SetParent(((Component)this).transform);
			((Component)_nearLight).transform.position = transform.position + Vector3.down * 80f;
			_nearLight.range = 70f;
			_nearLight.color = new Color(0.875f, 0.788f, 0.791f, 1f);
			_farLight = new GameObject("FarLight").AddComponent<Light>();
			((Component)_farLight).transform.SetParent(((Component)this).transform);
			((Component)_farLight).transform.position = transform.position + Vector3.down * 30f;
			_farLight.range = 500f;
		}

		private void Update()
		{
			if (Feral.Player.isInsideFactory)
			{
				_nearLight.intensity = (float)Feral.Settings.General.InternalNightVisionIntensity.Value * 100f;
				_farLight.intensity = (float)Feral.Settings.General.InternalNightVisionIntensity.Value * 1100f;
			}
			else
			{
				_nearLight.intensity = (float)Feral.Settings.General.ExternalNightVisionIntensity.Value * 100f;
				_farLight.intensity = (float)Feral.Settings.General.ExternalNightVisionIntensity.Value * 1100f;
			}
		}

		private void Start()
		{
			RenderPipelineManager.beginCameraRendering += BeginCameraRendering;
			RenderPipelineManager.endCameraRendering += EndCameraRendering;
		}

		private void OnDestroy()
		{
			RenderPipelineManager.beginCameraRendering -= BeginCameraRendering;
			RenderPipelineManager.endCameraRendering -= EndCameraRendering;
		}

		private void BeginCameraRendering(ScriptableRenderContext _, Camera camera)
		{
			if (!((Object)(object)Feral.Player.gameplayCamera != (Object)(object)camera))
			{
				((Behaviour)_farLight).enabled = true;
				((Behaviour)_nearLight).enabled = true;
			}
		}

		private void EndCameraRendering(ScriptableRenderContext _, Camera camera)
		{
			((Behaviour)_farLight).enabled = false;
			((Behaviour)_nearLight).enabled = false;
		}
	}
	public sealed class GlobalData : MonoBehaviour
	{
		private readonly List<MapTarget> _mapTargets = new List<MapTarget>();

		internal IReadOnlyList<MapTarget> MapTargets => _mapTargets;

		private void Awake()
		{
			PlayerControllerB[] array = Resources.FindObjectsOfTypeAll<PlayerControllerB>();
			PlayerTarget playerTarget = default(PlayerTarget);
			foreach (PlayerControllerB val in array)
			{
				if (((Component)val).gameObject.TryGetComponent<PlayerTarget>(ref playerTarget))
				{
					if (!MapTargets.Contains(playerTarget))
					{
						CollectionExtensions.AddItem<MapTarget>((IEnumerable<MapTarget>)MapTargets, (MapTarget)playerTarget);
					}
				}
				else
				{
					playerTarget = new PlayerTarget(val);
					_mapTargets.Add(playerTarget);
				}
			}
			Feral.Events.OnAddRadarBooster += AddRadarBooster;
			Feral.Events.OnRemoveRadarBooster += RemoveRadarBooster;
		}

		private void OnDestroy()
		{
			Feral.Events.OnAddRadarBooster -= AddRadarBooster;
			Feral.Events.OnRemoveRadarBooster -= RemoveRadarBooster;
		}

		private void AddRadarBooster(RadarBoosterItem item)
		{
			RadarTarget item2 = default(RadarTarget);
			if (!((Component)item).gameObject.TryGetComponent<RadarTarget>(ref item2))
			{
				item2 = new RadarTarget(item);
			}
			if (!_mapTargets.Contains(item2))
			{
				_mapTargets.Add(item2);
				_mapTargets.Sort();
			}
		}

		private void RemoveRadarBooster(RadarBoosterItem item)
		{
			RadarTarget item2 = default(RadarTarget);
			if (((Component)item).gameObject.TryGetComponent<RadarTarget>(ref item2))
			{
				_mapTargets.Remove(item2);
				_mapTargets.Sort();
			}
		}
	}
}
namespace FeralCompany.Modules.SettingsMenu
{
	public class SettingsMenu : MonoBehaviour
	{
		internal SettingsMenuUI SettingsUI;

		internal static SettingsMenu Create()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return new GameObject("FeralSettingsMenu").AddComponent<SettingsMenu>();
		}

		private void Awake()
		{
			SettingsUI.Init();
		}
	}
}
namespace FeralCompany.Modules.SettingsMenu.UI
{
	public class SettingsMenuUI : FeralUI
	{
		private TMP_Text _titleLabel;

		private GameObject _tabList;

		private GameObject _contentList;

		protected override void AfterAwake()
		{
			_titleLabel = ((Component)base.Window.Find("Settings/Title/Text")).GetComponent<TMP_Text>();
			_tabList = ((Component)base.Window.Find("Tabs")).gameObject;
			_contentList = ((Component)base.Window.Find("Settings/Content")).gameObject;
		}

		protected override void OnInit()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			((UnityEvent)((Component)base.Window.Find("Settings/Title/Exit")).GetComponent<Button>().onClick).AddListener(new UnityAction(base.Close));
		}
	}
}
namespace FeralCompany.Modules.Map
{
	public sealed class FeralMap : MonoBehaviour
	{
		private Light _light;

		private MapUI _ui;

		private int _targetIndex;

		private const float NorthAtan2 = 1.570796f;

		private static int TargetCount => Feral.Globals.MapTargets.Count;

		internal MapTarget Target => Feral.Globals.MapTargets[_targetIndex];

		internal Camera Camera { get; private set; }

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Feral_MapCamera");
			val.transform.SetParent(((Component)this).transform);
			Camera = val.AddComponent<Camera>();
			((Behaviour)Camera).enabled = false;
			Camera.orthographic = true;
			Camera.orthographicSize = Feral.Settings.Map.Zoom;
			HDAdditionalCameraData obj = val.AddComponent<HDAdditionalCameraData>();
			obj.customRenderingSettings = true;
			((FrameSettings)(ref obj.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)28, false);
			((BitArray128)(ref obj.renderingPathCustomFrameSettingsOverrideMask.mask))[28u] = true;
			_light = new GameObject("Feral_MapLight").AddComponent<Light>();
			((Component)_light).transform.SetParent(((Component)this).transform);
			_light.range = 100f;
			_light.type = (LightType)1;
			_light.color = Color.white;
			_light.colorTemperature = 6500f;
			_light.useColorTemperature = true;
			_ui = Object.Instantiate<GameObject>(Feral.Assets.PrefabFeralMap, ((Component)this).transform).AddComponent<MapUI>();
			UpdateCullingMask(Feral.Settings.Map.CullingMask);
			_ui.Init();
			_ui.OpenEvent += OnOpenMap;
			_ui.CloseEvent += OnCloseMap;
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).performed += OnMouseScroll;
		}

		private void Start()
		{
			Feral.Bindings.ToggleMap.performed += delegate
			{
				Feral.Settings.Map.Enable.Value = !Feral.Settings.Map.Enable.Value;
				if ((bool)Feral.Settings.Map.Enable)
				{
					_ui.Open();
				}
				else
				{
					_ui.Close();
				}
			};
			Feral.Bindings.CycleMapTarget.performed += delegate
			{
				NextTarget();
			};
			RenderPipelineManager.beginCameraRendering += BeginCameraRendering;
			RenderPipelineManager.endCameraRendering += EndCameraRendering;
			Feral.Settings.Map.CullingMask.ChangeEvent += UpdateCullingMask;
			Feral.Settings.Map.Zoom.ChangeEvent += UpdateZoom;
		}

		private static void OnMouseScroll(CallbackContext context)
		{
			if (Feral.Bindings.Shift.IsPressed() && Feral.Bindings.Alt.IsPressed())
			{
				float num = ((CallbackContext)(ref context)).ReadValue<float>();
				float value = Feral.Settings.Map.Scale.Value;
				float num2 = value / 100f;
				float value2 = Mathf.Clamp(value - num * num2, 1f, 5f);
				Feral.Settings.Map.Scale.Value = value2;
			}
			else if (Feral.Bindings.Alt.IsPressed())
			{
				float num3 = ((CallbackContext)(ref context)).ReadValue<float>();
				float value3 = Feral.Settings.Map.Zoom.Value;
				float num4 = value3 / 100f * 8f;
				float value4 = Mathf.Clamp(value3 - num3 * num4, 1f, 100f);
				Feral.Settings.Map.Zoom.Value = value4;
			}
		}

		private void OnOpenMap()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Camera.rect = _ui.CameraRect;
			((Behaviour)Camera).enabled = true;
		}

		private void OnCloseMap()
		{
			((Behaviour)Camera).enabled = false;
		}

		private void Update()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			ValidateTarget();
			foreach (MapPointer pointer in Feral.CurrentRound.Pointers)
			{
				pointer.UpdateFor(Target);
			}
			_light.intensity = (Target.IsInFacility ? Feral.Settings.Map.InternalLight : Feral.Settings.Map.ExternalLight);
			((Component)_light).transform.position = Target.Position + Vector3.up * 30f;
			((Component)_light).transform.rotation = Quaternion.Euler(90f, 0f, 0f);
			float num = 1.570796f - Mathf.Atan2(Target.Forward.x, Target.Forward.z);
			num *= 57.29578f;
			num = (num + 360f) % 360f;
			_ui.CompassRotation = Quaternion.Euler(0f, 0f, 0f - num);
		}

		private void LateUpdate()
		{
			//IL_0029: 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)
			MapTarget target = Target;
			_ui.TargetName = Target.Name;
			((Component)Camera).transform.position = target.CameraPosition;
			((Component)Camera).transform.eulerAngles = target.CameraRotation;
			Camera.nearClipPlane = target.NearClipPlane;
		}

		private void OnDestroy()
		{
			RenderPipelineManager.beginCameraRendering -= BeginCameraRendering;
			RenderPipelineManager.endCameraRendering -= EndCameraRendering;
			Feral.Settings.Map.CullingMask.ChangeEvent -= UpdateCullingMask;
			Feral.Settings.Map.Zoom.ChangeEvent -= UpdateZoom;
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("SwitchItem", false).performed -= OnMouseScroll;
		}

		private void BeginCameraRendering(ScriptableRenderContext _, Camera camera)
		{
			((Behaviour)_light).enabled = (Object)(object)Camera == (Object)(object)camera;
		}

		private void EndCameraRendering(ScriptableRenderContext _, Camera camera)
		{
			((Behaviour)_light).enabled = false;
		}

		private void UpdateCullingMask(int mask)
		{
			Camera.cullingMask = mask;
		}

		private void UpdateZoom(float zoom)
		{
			Camera.orthographicSize = zoom;
		}

		private void NextTarget()
		{
			_targetIndex++;
			if (_targetIndex < 0 || _targetIndex >= TargetCount)
			{
				_targetIndex = 0;
			}
		}

		private void ValidateTarget()
		{
			if (TargetCount == 0)
			{
				return;
			}
			if (_targetIndex < 0)
			{
				_targetIndex = 0;
			}
			if (_targetIndex >= TargetCount)
			{
				_targetIndex = TargetCount - 1;
			}
			int targetIndex = _targetIndex;
			while (!Target.ValidateTarget())
			{
				_targetIndex++;
				if (_targetIndex >= TargetCount)
				{
					_targetIndex = 0;
				}
				if (_targetIndex == targetIndex)
				{
					break;
				}
			}
		}
	}
	public sealed class MapUI : FeralUI
	{
		private TMP_Text _targetNameText;

		private RectTransform _compassTransform;

		private Transform _pointers;

		private List<MapPointer>? _currentPointers;

		internal string TargetName
		{
			get
			{
				return _targetNameText.text;
			}
			set
			{
				_targetNameText.text = value;
			}
		}

		internal Quaternion CompassRotation
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return ((Component)_compassTransform).transform.rotation;
			}
			set
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				((Component)_compassTransform).transform.rotation = value;
			}
		}

		internal Rect CameraRect { get; private set; }

		protected override void AfterAwake()
		{
			_targetNameText = ((Component)base.Window.Find("Panel/Target")).GetComponent<TMP_Text>();
			_compassTransform = ((Component)base.Window.Find("Compass")).GetComponent<RectTransform>();
			_pointers = base.Window.Find("Pointers");
		}

		protected override void OnInit()
		{
			Feral.Events.OnPointersCreated += OnPointersCreated;
			Feral.Settings.Map.Scale.ChangeEvent += base.UpdateScale;
			UIScale = Feral.Settings.Map.Scale;
		}

		protected override void OnBaseDestroy()
		{
			Feral.Events.OnPointersCreated -= OnPointersCreated;
			Feral.Settings.Map.Scale.ChangeEvent -= base.UpdateScale;
		}

		private void OnPointersCreated(IReadOnlyList<MapPointer> pointers)
		{
			foreach (MapPointer pointer in pointers)
			{
				pointer.PointerObject.transform.SetParent(_pointers, false);
			}
			_currentPointers = new List<MapPointer>(pointers);
			_currentPointers.Sort();
			((Component)_pointers).gameObject.SetActive(false);
			for (int i = 0; i < _currentPointers.Count; i++)
			{
				_currentPointers[i].PointerObject.transform.SetSiblingIndex(i);
			}
			((Component)_pointers).gameObject.SetActive(Object.op_Implicit((Object)(object)((Component)this).transform));
		}

		protected override void HandleScaleUpdate(float width, float height)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_001c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Transform)base.WindowRect).position;
			CameraRect = new Rect((position.x - width) / (float)Screen.width, (position.y - height) / (float)Screen.height, width / (float)Screen.width, height / (float)Screen.height);
			if (base.IsOpen)
			{
				Feral.Map.Camera.rect = CameraRect;
			}
		}

		protected override bool CanOpen()
		{
			return Feral.Settings.Map.Enable;
		}
	}
}
namespace FeralCompany.Modules.Map.Targets
{
	public abstract class MapTarget : IComparable<MapTarget>
	{
		private const float DefaultNearClipPlane = -2.47f;

		private const float HangarNearClipPlane = -0.96f;

		private const float CameraHoverY = 3.636f;

		private static int _incrementer;

		private readonly int _targetId = _incrementer++;

		protected internal string Name { get; protected set; } = "Unnamed";


		protected internal bool IsDead { get; protected set; }

		protected internal bool IsInElevator { get; protected set; }

		protected internal bool IsInShip { get; protected set; }

		protected internal bool IsInFacility { get; protected set; }

		protected internal bool IsOutsideShip => !IsInShip;

		protected internal bool IsOutside
		{
			get
			{
				if (!IsInShip)
				{
					return !IsInElevator;
				}
				return false;
			}
		}

		protected internal bool IsOutsideFacility => !IsInFacility;

		protected internal Vector3 Position { get; protected set; }

		protected internal Vector3 Forward { get; protected set; }

		protected internal Quaternion Quaternion { get; protected set; }

		protected internal Vector3 Rotation
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				Quaternion quaternion = Quaternion;
				return ((Quaternion)(ref quaternion)).eulerAngles;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				Quaternion = Quaternion.Euler(value);
			}
		}

		internal float NearClipPlane
		{
			get
			{
				if (!IsInShip)
				{
					return -2.47f;
				}
				return -0.96f;
			}
		}

		internal Vector3 CameraPosition => Position + Vector3.up * 3.636f;

		protected internal Vector3 CameraRotation { get; protected set; }

		internal abstract bool ValidateTarget();

		public int CompareTo(MapTarget? other)
		{
			if (other == null)
			{
				return -1;
			}
			return _targetId.CompareTo(other._targetId);
		}
	}
	public sealed class PlayerTarget : MapTarget
	{
		[CompilerGenerated]
		private PlayerControllerB <player>P;

		public PlayerTarget(PlayerControllerB player)
		{
			<player>P = player;
			base..ctor();
		}

		internal override bool ValidateTarget()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)<player>P))
			{
				PlayerControllerB val = <player>P;
				if (val == null || val.isPlayerControlled || val.isPlayerDead)
				{
					base.Name = <player>P.playerUsername;
					base.IsDead = <player>P.isPlayerDead;
					base.IsInElevator = <player>P.isInElevator;
					base.IsInShip = <player>P.isInHangarShipRoom;
					base.IsInFacility = <player>P.isInsideFactory;
					Transform val2 = (base.IsDead ? ((Component)<player>P.deadBody).transform : ((Component)<player>P).transform);
					base.Position = val2.position;
					base.Forward = val2.forward;
					base.Quaternion = val2.rotation;
					base.CameraRotation = (base.IsDead ? new Vector3(90f, 90f, 0f) : new Vector3(90f, base.Rotation.y, 0f));
					return true;
				}
			}
			return false;
		}
	}
	public sealed class RadarTarget : MapTarget
	{
		[CompilerGenerated]
		private RadarBoosterItem <radar>P;

		private const string NoRadarName = "NoRadarName";

		public RadarTarget(RadarBoosterItem radar)
		{
			<radar>P = radar;
			base..ctor();
		}

		internal override bool ValidateTarget()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if (!<radar>P.radarEnabled)
			{
				return false;
			}
			base.Name = (string.IsNullOrWhiteSpace(<radar>P.radarBoosterName) ? "NoRadarName" : <radar>P.radarBoosterName);
			base.IsInElevator = ((GrabbableObject)<radar>P).isInElevator;
			base.IsInShip = ((GrabbableObject)<radar>P).isInShipRoom;
			base.Position = ((Component)<radar>P).transform.position;
			base.Rotation = new Vector3(90f, 90f, 0f);
			base.IsInFacility = ((GrabbableObject)<radar>P).isInFactory;
			base.CameraRotation = base.Rotation;
			return true;
		}
	}
}
namespace FeralCompany.Modules.Map.Pointers
{
	public sealed class FireExitPointer : MapPointer
	{
		public FireExitPointer(GameObject pointerObject, PointerController controller, Vector3 destination, int entranceId, bool entrance)
			: base(pointerObject, controller, destination, entranceId, entrance)
		{
		}//IL_0003: Unknown result type (might be due to invalid IL or missing references)


		protected internal override Sprite GetIcon()
		{
			return Feral.Assets.SpriteExtinguisher;
		}

		protected override bool VisibleFor(MapTarget target)
		{
			if (base.IsEntrance)
			{
				if (target != null && target.IsOutsideFacility && target.IsOutsideShip)
				{
					return (target is RadarTarget) ? Feral.Settings.Map.PointerExternalFireRadar : Feral.Settings.Map.PointerExternalFire;
				}
			}
			else if (target.IsInFacility)
			{
				return (target is RadarTarget) ? Feral.Settings.Map.PointerInternalFireRadar : Feral.Settings.Map.PointerInternalFire;
			}
			return false;
		}
	}
	public sealed class MainEntrancePointer : MapPointer
	{
		public MainEntrancePointer(GameObject pointerObject, PointerController controller, Vector3 destination, int entranceId, bool entrance)
			: base(pointerObject, controller, destination, entranceId, entrance)
		{
		}//IL_0003: Unknown result type (might be due to invalid IL or missing references)


		protected internal override Sprite GetIcon()
		{
			return Feral.Assets.SpriteEntrance;
		}

		protected override bool VisibleFor(MapTarget target)
		{
			if (base.IsEntrance)
			{
				if (target != null && target.IsOutsideFacility && target.IsOutsideShip)
				{
					return (target is RadarTarget) ? Feral.Settings.Map.PointerExternalEntranceRadar : Feral.Settings.Map.PointerExternalEntrance;
				}
			}
			else if (target.IsInFacility)
			{
				return (target is RadarTarget) ? Feral.Settings.Map.PointerInternalEntranceRadar : Feral.Settings.Map.PointerInternalEntrance;
			}
			return false;
		}
	}
	public abstract class MapPointer : IComparable<MapPointer>
	{
		[CompilerGenerated]
		private Vector3 <destination>P;

		private readonly int _entranceId;

		private float _lastDistance;

		internal GameObject PointerObject { get; }

		internal PointerController Controller { get; }

		protected bool IsEntrance { get; }

		protected MapPointer(GameObject pointerObject, PointerController controller, Vector3 destination, int entranceId, bool entrance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			<destination>P = destination;
			PointerObject = pointerObject;
			Controller = controller;
			IsEntrance = entrance;
			_entranceId = entranceId;
			base..ctor();
		}

		internal void UpdateFor(MapTarget target)
		{
			//IL_0002: 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)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0039: 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_0042: 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_0054: 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)
			_lastDistance = Vector3.Distance(target.Position, <destination>P);
			Controller.Distance = _lastDistance;
			Vector3 val = <destination>P - target.Position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num = Mathf.Atan2(normalized.x, normalized.z) - Mathf.Atan2(target.Forward.x, target.Forward.z);
			num *= 57.29578f;
			num = (num + 360f) % 360f;
			Controller.Pointer = 0f - num;
			bool active = VisibleFor(target);
			PointerObject.SetActive(active);
		}

		protected internal abstract Sprite GetIcon();

		protected abstract bool VisibleFor(MapTarget target);

		public int CompareTo(MapPointer? other)
		{
			if (other == null)
			{
				return -1;
			}
			if (this is ShipPointer || other is ShipPointer)
			{
				if (!(this is ShipPointer))
				{
					return 1;
				}
				return -1;
			}
			if (this is MainEntrancePointer && other is MainEntrancePointer)
			{
				if (!IsEntrance)
				{
					return 1;
				}
				return -1;
			}
			if (this is MainEntrancePointer || other is MainEntrancePointer)
			{
				if (!(this is MainEntrancePointer))
				{
					return 1;
				}
				return -1;
			}
			return _entranceId.CompareTo(other._entranceId);
		}
	}
	public sealed class PointerController : MonoBehaviour
	{
		private TMP_Text _distance;

		private RectTransform _pointer;

		private Image _icon;

		internal bool Active
		{
			get
			{
				return ((Component)((Component)this).transform).gameObject.activeSelf;
			}
			set
			{
				((Component)((Component)this).transform).gameObject.SetActive(value);
			}
		}

		internal float Distance
		{
			get
			{
				return int.Parse(_distance.text);
			}
			set
			{
				_distance.text = $"{Mathf.RoundToInt(value)}";
			}
		}

		internal float Pointer
		{
			get
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: 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)
				Quaternion rotation = ((Component)_pointer).transform.rotation;
				return ((Quaternion)(ref rotation)).eulerAngles.z;
			}
			set
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				((Component)_pointer).transform.rotation = Quaternion.Euler(0f, 0f, value);
			}
		}

		internal Sprite Icon
		{
			get
			{
				return _icon.sprite;
			}
			set
			{
				_icon.sprite = value;
			}
		}

		private void Awake()
		{
			_distance = ((Component)((Component)this).transform.Find("Distance")).GetComponent<TMP_Text>();
			_pointer = ((Component)((Component)this).transform.Find("Pointer")).GetComponent<RectTransform>();
			_icon = ((Component)((Component)this).transform.Find("Icon")).GetComponent<Image>();
		}
	}
	public sealed class ShipPointer : MapPointer
	{
		public ShipPointer(GameObject pointerObject, PointerController controller, Vector3 destination, int entranceId, bool entrance)
			: base(pointerObject, controller, destination, entranceId, entrance)
		{
		}//IL_0003: Unknown result type (might be due to invalid IL or missing references)


		protected internal override Sprite GetIcon()
		{
			return Feral.Assets.SpriteHome;
		}

		protected override bool VisibleFor(MapTarget target)
		{
			if (target != null && target.IsOutsideFacility && target.IsOutside)
			{
				return (target is RadarTarget) ? Feral.Settings.Map.PointerShipRadar : Feral.Settings.Map.PointerShip;
			}
			return false;
		}
	}
}
namespace FeralCompany.Core
{
	public class FeralAssets
	{
		private const string AssetBundleName = "feralcompany_assets";

		internal GameObject PrefabFeralMap;

		internal GameObject PrefabMapPointer;

		internal Sprite SpriteHome;

		internal Sprite SpriteExtinguisher;

		internal Sprite SpriteEntrance;

		private static string AssetPath => Path.Combine(Path.GetDirectoryName(typeof(FeralAssets).Assembly.Location), "feralcompany_assets");

		internal bool Load()
		{
			AssetBundle val = AssetBundle.LoadFromFile(AssetPath);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Feral.IO.Error("Failed to load assets @ " + AssetPath + "!", "D:\\projects\\lethalcompany\\FeralCompany\\FeralCompany\\Core\\FeralAssets.cs", "Load", 25);
				Feral.IO.Error("FeralCompany will shut down, now.", "D:\\projects\\lethalcompany\\FeralCompany\\FeralCompany\\Core\\FeralAssets.cs", "Load", 26);
				return false;
			}
			if (LoadAllAssets(val))
			{
				return true;
			}
			Feral.IO.Error("One or more assets failed to load.", "D:\\projects\\lethalcompany\\FeralCompany\\FeralCompany\\Core\\FeralAssets.cs", "Load", 33);
			Feral.IO.Error("FeralCompany will shut down, now.", "D:\\projects\\lethalcompany\\FeralCompany\\FeralCompany\\Core\\FeralAssets.cs", "Load", 34);
			return false;
		}

		private bool LoadAllAssets(AssetBundle assets)
		{
			if (LoadAsset<GameObject>(assets, "Assets/Prefabs/FeralMap.prefab", out PrefabFeralMap) && LoadAsset<GameObject>(assets, "Assets/Prefabs/MapComp/MapPointer.prefab", out PrefabMapPointer) && LoadAsset<Sprite>(assets, "Assets/Sprites/Home.png", out SpriteHome) && LoadAsset<Sprite>(assets, "Assets/Sprites/Entrance.png", out SpriteEntrance))
			{
				return LoadAsset<Sprite>(assets, "Assets/Sprites/Extinguisher.png", out SpriteExtinguisher);
			}
			return false;
		}

		private static bool LoadAsset<T>(AssetBundle assets, string path, out T asset) where T : Object
		{
			asset = assets.LoadAsset<T>(path);
			if (Object.op_Implicit((Object)(object)asset))
			{
				return true;
			}
			Feral.IO.Error("Failed to load asset @ " + AssetPath + " => " + path, "D:\\projects\\lethalcompany\\FeralCompany\\FeralCompany\\Core\\FeralAssets.cs", "LoadAsset", 57);
			return false;
		}
	}
	public class FeralBindings : LcInputActions
	{
		private readonly InputActionMap _immutableMap;

		[InputAction("<keyboard>/m", Name = "ToggleMap")]
		internal InputAction ToggleMap { get; set; }

		[InputAction("<keyboard>/period", Name = "Cycle Map Target")]
		internal InputAction CycleMapTarget { get; set; }

		internal InputAction Alt => _immutableMap["Alt"];

		internal InputAction Shift => _immutableMap["Shift"];

		internal FeralBindings()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			_immutableMap = new InputActionMap();
			InputActionSetupExtensions.AddAction(_immutableMap, "Alt", (InputActionType)0, "<keyboard>/alt", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(_immutableMap, "Shift", (InputActionType)0, "<keyboard>/shift", (string)null, (string)null, (string)null, (string)null);
			_immutableMap.Enable();
		}

		public void Enable()
		{
			((LcInputActions)this).Enable();
			_immutableMap.Enable();
		}

		public void Disable()
		{
			((LcInputActions)this).Disable();
			_immutableMap.Disable();
		}
	}
	public class FeralEvents
	{
		internal int PlayerCount { get; private set; }

		internal bool IsInGame { get; private set; }

		internal bool IsOnMoon { get; private set; }

		internal event Action? OnClientConnect;

		internal event Action? OnClientDisconnect;

		internal event Action? OnEnterMoon;

		internal event Action? OnExitMoon;

		internal event Action? OnExitGame;

		internal event Action<RadarBoosterItem>? OnAddRadarBooster;

		internal event Action<RadarBoosterItem>? OnRemoveRadarBooster;

		internal event Action<MapPointer[]> OnPointersCreated;

		internal void InvokeClientConnect(ulong _)
		{
			PlayerCount++;
			this.OnClientConnect?.Invoke();
		}

		internal void InvokeClientDisconnect(ulong _)
		{
			PlayerCount--;
			this.OnClientDisconnect?.Invoke();
		}

		internal void InvokeEnterMoon()
		{
			IsOnMoon = true;
			this.OnEnterMoon?.Invoke();
		}

		internal void InvokeExitMoon()
		{
			IsOnMoon = false;
			this.OnExitMoon?.Invoke();
		}

		internal void InvokeExitGame()
		{
			IsInGame = false;
			this.OnExitGame?.Invoke();
		}

		internal void InvokeAddRadarBooster(RadarBoosterItem radar)
		{
			this.OnAddRadarBooster?.Invoke(radar);
		}

		internal void InvokeRemoveRadarBooster(RadarBoosterItem radar)
		{
			this.OnRemoveRadarBooster?.Invoke(radar);
		}

		internal void InvokePointersCreated(MapPointer[] pointers)
		{
			this.OnPointersCreated?.Invoke(pointers);
		}
	}
	public class FeralOutput
	{
		[CompilerGenerated]
		private ManualLogSource <source>P;

		private const string LogTemplate = "[{0}#{1}:L{2}] {3}";

		public FeralOutput(ManualLogSource source)
		{
			<source>P = source;
			base..ctor();
		}

		internal void Status(object msg)
		{
			Feral.HUD.DisplayStatusEffect(msg.ToString());
		}

		internal void Debug(object msg)
		{
			Feral.HUD.SetDebugText(msg.ToString());
		}

		internal void Info(object data, [CallerFilePath] string caller = "", [CallerMemberName] string callerMethod = "", [CallerLineNumber] int lineNumber = 0)
		{
			Log((LogLevel)16, data, caller, callerMethod, lineNumber);
		}

		internal void Warn(object data, [CallerFilePath] string caller = "", [CallerMemberName] string callerMethod = "", [CallerLineNumber] int lineNumber = 0)
		{
			Log((LogLevel)4, data, caller, callerMethod, lineNumber);
		}

		internal void Error(object data, [CallerFilePath] string caller = "", [CallerMemberName] string callerMethod = "", [CallerLineNumber] int lineNumber = 0)
		{
			Log((LogLevel)2, data, caller, callerMethod, lineNumber);
		}

		private void Log(LogLevel level, object data, string caller, string callerMethod, int lineNumber)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			string fileName = Path.GetFileName(caller);
			<source>P.Log(level, (object)$"[{fileName}#{callerMethod}:L{lineNumber}] {data}");
		}
	}
	public class FeralSettings
	{
		internal class GeneralSettings
		{
			internal readonly SettingBase<FeralCompany.Core.Locale.Locale> Locale;

			internal readonly Config<int> InternalNightVisionIntensity;

			internal readonly Config<int> ExternalNightVisionIntensity;

			internal GeneralSettings(ConfigFile config)
			{
				Setting<string> delegated = new Setting<string>("en_US");
				Locale = new FuncSetting<string, FeralCompany.Core.Locale.Locale>(delegated, (string key) => Feral.Locales.Locales[key], (FeralCompany.Core.Locale.Locale locale) => locale.Key);
				InternalNightVisionIntensity = new Config<int>(config, "NightVision", "Facility Intensity", 0, "The intensity of the night vision while inside the facility.", (AcceptableValueBase?)(object)new AcceptableValueRange<int>(0, 100));
				ExternalNightVisionIntensity = new Config<int>(config, "NightVision", "Outside Intensity", 0, "The intensity of the night vision while outside the facility.", (AcceptableValueBase?)(object)new AcceptableValueRange<int>(0, 100));
			}
		}

		internal class MapSettings
		{
			internal readonly Config<bool> Enable;

			internal readonly Config<float> Scale;

			internal readonly Config<float> Zoom;

			internal readonly SettingBase<int> CullingMask;

			internal readonly Config<float> InternalLight;

			internal readonly Config<float> ExternalLight;

			internal readonly Config<bool> PointerShip;

			internal readonly Config<bool> PointerExternalEntrance;

			internal readonly Config<bool> PointerInternalEntrance;

			internal readonly Config<bool> PointerExternalFire;

			internal readonly Config<bool> PointerInternalFire;

			internal readonly Config<bool> PointerShipRadar;

			internal readonly Config<bool> PointerExternalEntranceRadar;

			internal readonly Config<bool> PointerInternalEntranceRadar;

			internal readonly Config<bool> PointerExternalFireRadar;

			internal readonly Config<bool> PointerInternalFireRadar;

			internal MapSettings(ConfigFile config)
			{
				Enable = new Config<bool>(config, "Map", "Enable", defaultValue: true, "Whether or not to enable the map.");
				Scale = new Config<float>(config, "Map", "Scale", 1f, "The size of the map.", (AcceptableValueBase?)(object)new AcceptableValueRange<float>(0.1f, 5f));
				Zoom = new Config<float>(config, "Map", "Zoom", 19.7f, "How close the camera should follow the target.");
				InternalLight = new Config<float>(config, "Map", "Facility Brightness", 15f, "The intensity of the backlight for the map while inside the facility.\r\nVanilla: 0; No lighting other than internal lights and sunlight.", (AcceptableValueBase?)(object)new AcceptableValueRange<float>(0f, 100f));
				ExternalLight = new Config<float>(config, "Map", "Outside Brightness", 15f, "The intensity of the backlight for the map while outside the facility.\r\nVanilla: 0; No lighting other than internal lights and sunlight.", (AcceptableValueBase?)(object)new AcceptableValueRange<float>(0f, 100f));
				PointerShip = new Config<bool>(config, "Map.Pointers", "Ship", defaultValue: true, "Whether or not to show pointers for the ship.");
				PointerExternalEntrance = new Config<bool>(config, "Map.Pointers", "External Entrance", defaultValue: true, "Whether or not to show pointers for the external entrance.");
				PointerInternalEntrance = new Config<bool>(config, "Map.Pointers", "Internal Entrance", defaultValue: true, "Whether or not to show pointers for the internal entrance.");
				PointerExternalFire = new Config<bool>(config, "Map.Pointers", "External Fire", defaultValue: true, "Whether or not to show pointers for external fire exits.");
				PointerInternalFire = new Config<bool>(config, "Map.Pointers", "Internal Fire", defaultValue: true, "Whether or not to show pointers for internal fire exits.");
				PointerShipRadar = new Config<bool>(config, "Map.Pointers", "Ship (Radar)", defaultValue: true, "Whether or not to show pointers for the ship when viewing a radar.");
				PointerExternalEntranceRadar = new Config<bool>(config, "Map.Pointers", "External Entrance (Radar)", defaultValue: true, "Whether or not to show pointers for the external entrance when viewing a radar.");
				PointerInternalEntranceRadar = new Config<bool>(config, "Map.Pointers", "Internal Entrance (Radar)", defaultValue: true, "Whether or not to show pointers for the internal entrance when viewing a radar.");
				PointerExternalFireRadar = new Config<bool>(config, "Map.Pointers", "External Fire (Radar)", defaultValue: true, "Whether or not to show pointers for external fire exits when viewing a radar.");
				PointerInternalFireRadar = new Config<bool>(config, "Map.Pointers", "Internal Fire (Radar)", defaultValue: true, "Whether or not to show pointers for internal fire exits when viewing a radar.");
				Config<string> delegated = new Config<string>(config, "Map", "Visible Layers", "Room,MapRadar", "The layers of the game visible to the minimap camera. Comma-separated list.\r\nValid layers:\r\n$" + string.Join(',', Mask.Names));
				CullingMask = new FuncSetting<string, int>(delegated, (string input) => input.Split(",", StringSplitOptions.RemoveEmptyEntries).Aggregate(0, (int current, string str) => current.AddMask(Mask.Named(str))), (int input) => string.Join(',', Mask.Decompress(input)));
			}
		}

		internal readonly GeneralSettings General = new GeneralSettings(config);

		internal readonly MapSettings Map = new MapSettings(config);

		public FeralSettings(ConfigFile config)
		{
		}
	}
	public class SettingInt : Setting<int>
	{
		public SettingInt(int defaultValue = 0)
			: base(defaultValue)
		{
		}

		internal int Increment(int add = 1)
		{
			Value += add;
			return Value;
		}

		internal int Decrement(int subtract = 1)
		{
			Value -= subtract;
			return Value;
		}
	}
}
namespace FeralCompany.Core.UI
{
	public abstract class FeralUI : MonoBehaviour
	{
		protected float UIScale = 1f;

		private Canvas _canvas;

		private float _originalCanvasScale;

		private float _currentCanvasScale;

		protected Transform Window { get; private set; }

		protected RectTransform WindowRect { get; private set; }

		internal bool IsOpen { get; private set; }

		internal event Action? OpenEvent;

		internal event Action? CloseEvent;

		private void Awake()
		{
			Window = ((Component)this).transform.Find("Container/Window");
			if (Object.op_Implicit((Object)(object)Window))
			{
				((Component)Window).gameObject.SetActive(false);
				WindowRect = ((Component)Window).gameObject.GetComponent<RectTransform>();
			}
			_canvas = ((Component)this).GetComponent<Canvas>();
			_originalCanvasScale = _canvas.scaleFactor;
			_currentCanvasScale = _originalCanvasScale;
			AfterAwake();
		}

		internal void Init()
		{
			OnInit();
			UpdateScale(UIScale);
		}

		protected void Update()
		{
			if (Feral.Player.quickMenuManager.isMenuOpen)
			{
				Close();
				return;
			}
			if (CanOpen())
			{
				Open();
			}
			AfterUpdate();
		}

		internal void Open()
		{
			if (!IsOpen && Object.op_Implicit((Object)(object)Window))
			{
				IsOpen = true;
				((Component)Window).gameObject.SetActive(true);
				OnOpen();
				this.OpenEvent?.Invoke();
			}
		}

		internal void Close()
		{
			if (IsOpen && Object.op_Implicit((Object)(object)Window))
			{
				IsOpen = false;
				((Component)Window).gameObject.SetActive(false);
				OnClose();
				this.CloseEvent?.Invoke();
			}
		}

		private void OnDestroy()
		{
			OnBaseDestroy();
		}

		protected abstract void AfterAwake();

		protected abstract void OnInit();

		protected virtual void AfterUpdate()
		{
		}

		protected virtual void OnOpen()
		{
		}

		protected virtual void OnClose()
		{
		}

		protected virtual void OnBaseDestroy()
		{
		}

		protected virtual void HandleScaleUpdate(float width, float height)
		{
		}

		protected virtual bool CanOpen()
		{
			return true;
		}

		internal void UpdateScale(float newScale)
		{
			//IL_002c: 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)
			UIScale = newScale;
			_currentCanvasScale = _originalCanvasScale * newScale;
			_canvas.scaleFactor = _currentCanvasScale;
			float width = WindowRect.sizeDelta.x * _currentCanvasScale;
			float height = WindowRect.sizeDelta.y * _currentCanvasScale;
			HandleScaleUpdate(width, height);
		}
	}
}
namespace FeralCompany.Core.Setting
{
	public class Config<T> : SettingBase<T>
	{
		private readonly ConfigEntry<T> _entry;

		internal override T Value
		{
			get
			{
				return _entry.Value;
			}
			set
			{
				_entry.Value = value;
			}
		}

		internal override T DefaultValue { get; }

		internal Config(ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase? acceptableValues = null)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: Expected O, but got Unknown
			DefaultValue = defaultValue;
			_entry = config.Bind<T>(new ConfigDefinition(section, key), defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>()));
			_entry.SettingChanged += delegate
			{
				InvokeChangeEvent(_entry.Value);
			};
		}
	}
	public class FuncSetting<T, R> : SettingBase<R>
	{
		[CompilerGenerated]
		private SettingBase<T> <delegated>P;

		[CompilerGenerated]
		private Func<T, R> <mapper>P;

		[CompilerGenerated]
		private Func<R, T> <demapper>P;

		internal override R Value
		{
			get
			{
				return <mapper>P(<delegated>P.Value);
			}
			set
			{
				<delegated>P.Value = <demapper>P(value);
				InvokeChangeEvent(value);
			}
		}

		internal override R DefaultValue => <mapper>P(<delegated>P.Value);

		public FuncSetting(SettingBase<T> delegated, Func<T, R> mapper, Func<R, T> demapper)
		{
			<delegated>P = delegated;
			<mapper>P = mapper;
			<demapper>P = demapper;
			base..ctor();
		}
	}
	public class Setting<T> : SettingBase<T>
	{
		private T _value;

		internal override T Value
		{
			get
			{
				return _value;
			}
			set
			{
				_value = value;
				InvokeChangeEvent(value);
			}
		}

		internal override T DefaultValue { get; }

		public Setting(T defaultValue)
		{
			DefaultValue = defaultValue;
			_value = defaultValue;
			base..ctor();
		}
	}
	public abstract class SettingBase<T>
	{
		internal abstract T Value { get; set; }

		internal abstract T DefaultValue { get; }

		internal event Action<T>? ChangeEvent;

		internal void Reset()
		{
			Value = DefaultValue;
		}

		protected void InvokeChangeEvent(T newValue)
		{
			this.ChangeEvent?.Invoke(newValue);
		}

		public static implicit operator T(SettingBase<T> settingBase)
		{
			return settingBase.Value;
		}
	}
	public class SettingBool : Setting<bool>
	{
		public SettingBool(bool defaultValue = false)
			: base(defaultValue)
		{
		}

		internal void SetFalse()
		{
			Value = false;
		}

		internal void SetTrue()
		{
			Value = true;
		}
	}
}
namespace FeralCompany.Core.Locale
{
	internal class FeralLocales
	{
		internal readonly Dictionary<string, Locale> Locales = new Dictionary<string, Locale>();

		internal bool Init()
		{
			string[] files = Directory.GetFiles(Files.LocalePath, "*.json");
			for (int i = 0; i < files.Length; i++)
			{
				Locale locale = LocaleParser.Parse(files[i]);
				Locales.Add(locale.Key, locale);
			}
			Locale.Current = Feral.Settings.General.Locale;
			return true;
		}
	}
	public class Locale
	{
		internal static Locale Current { get; set; }

		internal string Key { get; }

		internal string Name { get; }

		internal string? Fallback { get; }

		internal Dictionary<string, string> Entries { get; }

		public Locale(string key, string name, string? fallback, Dictionary<string, string> entries)
		{
			Key = key;
			Name = name;
			Fallback = fallback;
			Entries = entries;
			base..ctor();
		}

		internal string GetEntry(string key)
		{
			if (!TryGetEntry(key, out string entry))
			{
				Feral.IO.Warn("Locale '" + key + "' does not contain entry: " + key, "D:\\projects\\lethalcompany\\FeralCompany\\FeralCompany\\Core\\Locale\\Locale.cs", "GetEntry", 18);
			}
			return entry;
		}

		internal string GetEntry(string key, params object[] data)
		{
			if (!TryGetEntry(key, out string entry))
			{
				Feral.IO.Warn("Locale '" + key + "' does not contain entry: " + key, "D:\\projects\\lethalcompany\\FeralCompany\\FeralCompany\\Core\\Locale\\Locale.cs", "GetEntry", 26);
			}
			return string.Format(entry, data);
		}

		internal bool TryGetEntry(string key, out string entry)
		{
			if (Entries.TryGetValue(key, out entry))
			{
				return true;
			}
			if (Fallback != null && Feral.Locales.Locales.TryGetValue(Fallback, out Locale value))
			{
				return value.TryGetEntry(key, out entry);
			}
			entry = key;
			return false;
		}

		internal bool TryGetEntry(string key, out string entry, params object[] data)
		{
			if (!TryGetEntry(key, out entry))
			{
				return false;
			}
			entry = string.Format(entry, data);
			return true;
		}
	}
	internal static class LocaleParser
	{
		internal static Locale Parse(string fileName)
		{
			string text;
			using (StreamReader streamReader = new StreamReader(fileName))
			{
				text = streamReader.ReadToEnd();
			}
			JToken val = JToken.Parse(text);
			string key = val.Value<string>((object)"key");
			string name = val.Value<string>((object)"name");
			string fallback = val.Value<string>((object)"fallback");
			Dictionary<string, string> entries = new Dictionary<string, string>();
			FlattenEntries(entries, val[(object)"entries"]);
			return new Locale(key, name, fallback, entries);
		}

		private static void FlattenEntries(Dictionary<string, string> entries, JToken token, string prefix = "")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected I4, but got Unknown
			//IL_00af: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			JTokenType type = token.Type;
			switch ((int)type)
			{
			case 1:
			{
				foreach (JProperty item in token.Children<JProperty>())
				{
					FlattenEntries(entries, item.Value, Join(prefix, item.Name));
				}
				break;
			}
			case 8:
				entries.Add(prefix, ((object)token).ToString());
				break;
			default:
				throw new ArgumentOutOfRangeException($"Unsupported JTokenType: {token.Type}");
			}
		}

		private static string Join(string prefix, string key)
		{
			if (!string.IsNullOrEmpty(prefix))
			{
				return prefix + "." + key;
			}
			return key;
		}
	}
	public class LocaleToken
	{
		[CompilerGenerated]
		private string <key>P;

		public LocaleToken(string key)
		{
			<key>P = key;
			base..ctor();
		}

		internal string GetEntry()
		{
			return Locale.Current.GetEntry(<key>P);
		}

		internal string GetEntry(params object[] data)
		{
			return Locale.Current.GetEntry(<key>P, data);
		}

		internal bool TryGetEntry(out string entry)
		{
			return Locale.Current.TryGetEntry(<key>P, out entry);
		}

		internal bool TryGetEntry(out string entry, params object[] data)
		{
			return Locale.Current.TryGetEntry(<key>P, out entry, data);
		}

		public static implicit operator string(LocaleToken localeToken)
		{
			return localeToken.GetEntry();
		}
	}
}