Decompiled source of Imperium Repo v0.2.0

giosuel.Imperium.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Imperium.API.Types;
using Imperium.API.Types.Networking;
using Imperium.API.Types.Portals;
using Imperium.Core;
using Imperium.Core.EventLogging;
using Imperium.Core.Input;
using Imperium.Core.Input.InputUtilsStatic;
using Imperium.Core.Lifecycle;
using Imperium.Core.Portal;
using Imperium.Core.Scripts;
using Imperium.Core.Settings;
using Imperium.Extensions;
using Imperium.Integration;
using Imperium.Interface;
using Imperium.Interface.Common;
using Imperium.Interface.ImperiumUI;
using Imperium.Interface.ImperiumUI.Windows.ArenaControl;
using Imperium.Interface.ImperiumUI.Windows.ArenaControl.Widgets;
using Imperium.Interface.ImperiumUI.Windows.ControlCenter;
using Imperium.Interface.ImperiumUI.Windows.ControlCenter.Widgets;
using Imperium.Interface.ImperiumUI.Windows.EventLog;
using Imperium.Interface.ImperiumUI.Windows.LevelGeneration;
using Imperium.Interface.ImperiumUI.Windows.ObjectExplorer;
using Imperium.Interface.ImperiumUI.Windows.ObjectExplorer.ObjectListEntry;
using Imperium.Interface.ImperiumUI.Windows.Portal;
using Imperium.Interface.ImperiumUI.Windows.Preferences;
using Imperium.Interface.ImperiumUI.Windows.Rendering;
using Imperium.Interface.ImperiumUI.Windows.Teleport;
using Imperium.Interface.ImperiumUI.Windows.Teleport.Widgets;
using Imperium.Interface.ImperiumUI.Windows.Upgrades;
using Imperium.Interface.ImperiumUI.Windows.Visualization;
using Imperium.Interface.ImperiumUI.Windows.Visualization.ObjectVisualizerEntries;
using Imperium.Interface.ImperiumUI.Windows.Visualization.Widgets;
using Imperium.Interface.LayerSelector;
using Imperium.Interface.MapUI;
using Imperium.Interface.SpawningUI;
using Imperium.Networking;
using Imperium.Patches;
using Imperium.Types;
using Imperium.Util;
using Imperium.Visualizers;
using Imperium.Visualizers.Objects;
using JetBrains.Annotations;
using Librarium;
using Librarium.Binding;
using Microsoft.CodeAnalysis;
using MonoMod.Utils;
using Newtonsoft.Json;
using Photon.Pun;
using REPOLib.Modules;
using RepoSteamNetworking.API;
using RepoSteamNetworking.Networking;
using RepoSteamNetworking.Networking.Serialization;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;
using UniverseLib.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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("giosuel")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A powerful all-in-one debugging and admin tool to test and explore game mechanics and functionality in R.E.P.O.")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+e3a154369d1b0919597c78f2e951ebaf5a81ee2e")]
[assembly: AssemblyProduct("Imperium Repo")]
[assembly: AssemblyTitle("giosuel.Imperium")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/giosuel/imperium-repo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace Imperium
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("giosuel.Imperium", "Imperium Repo", "0.2.0")]
	public class Imperium : BaseUnityPlugin
	{
		private static Harmony Harmony;

		private static ManualLogSource Log;

		private static ConfigFile configFile;

		internal static ImpBinding<Camera> ActiveCamera;

		internal static MenuManager MenuManager => MenuManager.instance;

		internal static PlayerAvatar Player => PlayerAvatar.instance;

		internal static GameDirector GameDirector => GameDirector.instance;

		internal static ImpSettings Settings { get; private set; }

		internal static ImpOutput IO { get; private set; }

		internal static ImpNetworking Networking { get; set; }

		internal static StartupManager StartupManager { get; private set; }

		internal static PortalManager PortalManager { get; private set; }

		internal static GameManager GameManager { get; private set; }

		internal static ObjectManager ObjectManager { get; private set; }

		internal static PlayerManager PlayerManager { get; private set; }

		internal static ArenaManager ArenaManager { get; private set; }

		internal static Visualization Visualization { get; private set; }

		internal static ImpEventLog EventLog { get; private set; }

		internal static InputBlocker InputBlocker { get; private set; }

		internal static ImpMap Map { get; private set; }

		internal static ImpFreecam Freecam { get; private set; }

		internal static ImpNightVision NightVision { get; private set; }

		internal static TapeMeasure TapeMeasure { get; private set; }

		internal static ImpInputBindings InputBindings { get; private set; }

		internal static PositionIndicator PositionIndicator { get; private set; }

		internal static ImpInterfaceManager Interface { get; private set; }

		internal static WaypointManager WaypointManager { get; private set; }

		internal static bool IsImperiumInitialized { get; private set; }

		internal static bool IsImperiumLaunched { get; private set; }

		internal static ImpBinaryBinding IsImperiumEnabled { get; private set; }

		internal static ImpBinaryBinding IsLevelLoaded { get; private set; }

		internal static IBinding<bool> IsGameLevel { get; private set; }

		internal static GameObject GameObject { get; private set; }

		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			configFile = ((BaseUnityPlugin)this).Config;
			Log = ((BaseUnityPlugin)this).Logger;
			IsLevelLoaded = new ImpBinaryBinding(false, (Action)null, (Action)null);
			IsGameLevel = (IBinding<bool>)(object)new ImpExternalBinding<bool, bool>((Func<bool>)GameManager.IsGameLevel, (IBinding<bool>)(object)IsLevelLoaded, (Action<bool>)null, (Action<bool>)null);
			IsImperiumEnabled = new ImpBinaryBinding(false, (Action)null, (Action)null);
			Settings = new ImpSettings(((BaseUnityPlugin)this).Config);
			((ImpBinding<bool>)(object)IsLevelLoaded).OnUpdate += OnLevelLoaded;
			IO = new ImpOutput(Log);
			StartupManager = new StartupManager();
			Networking = new ImpNetworking();
			PortalManager = new PortalManager();
			if (ImpAssets.Load())
			{
				Harmony = new Harmony("0.2.0");
				PreLaunchPatches();
				IsImperiumInitialized = true;
				IO.LogInfo("[INIT] Imperium has been successfully initialized \\o/");
			}
		}

		internal static void Launch()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if (IsImperiumInitialized && !IsImperiumLaunched)
			{
				GameObject = new GameObject("Imperium");
				Object.DontDestroyOnLoad((Object)(object)GameObject);
				InputBlocker = new InputBlocker();
				InputBindings = new ImpInputBindings();
				ActiveCamera = (ImpBinding<Camera>)(object)new ImpExternalBinding<Camera, bool>((Func<Camera>)(() => PlayerAvatar.instance.localCamera), (IBinding<bool>)(object)IsLevelLoaded, (Action<Camera>)null, (Action<Camera>)null);
				IO.BindNotificationSettings(Settings);
				Networking.BindAllowClients((IBinding<bool>)(object)Settings.Preferences.AllowClients);
				Interface = ImpInterfaceManager.Create(Settings.Preferences.Theme, GameObject.transform);
				EventLog = new ImpEventLog();
				GameManager = ImpLifecycleObject.Create<GameManager>(GameObject.transform, (IBinding<bool>)(object)IsLevelLoaded, (IBinding<int>)(object)ImpNetworking.ConnectedPlayers);
				ArenaManager = ImpLifecycleObject.Create<ArenaManager>(GameObject.transform, (IBinding<bool>)(object)IsLevelLoaded, (IBinding<int>)(object)ImpNetworking.ConnectedPlayers);
				ObjectManager = ImpLifecycleObject.Create<ObjectManager>(GameObject.transform, (IBinding<bool>)(object)IsLevelLoaded, (IBinding<int>)(object)ImpNetworking.ConnectedPlayers);
				PlayerManager = ImpLifecycleObject.Create<PlayerManager>(GameObject.transform, (IBinding<bool>)(object)IsLevelLoaded, (IBinding<int>)(object)ImpNetworking.ConnectedPlayers);
				WaypointManager = ImpLifecycleObject.Create<WaypointManager>(GameObject.transform, (IBinding<bool>)(object)IsLevelLoaded, (IBinding<int>)(object)ImpNetworking.ConnectedPlayers);
				Visualization = new Visualization(GameObject.transform, ObjectManager, configFile);
				Map = ImpScript.Create<ImpMap>(GameObject.transform);
				Freecam = ImpScript.Create<ImpFreecam>(GameObject.transform);
				NightVision = ImpScript.Create<ImpNightVision>(GameObject.transform);
				TapeMeasure = ImpScript.Create<TapeMeasure>(GameObject.transform, ImpAssets.TapeIndicatorObject);
				PositionIndicator = ImpScript.Create<PositionIndicator>(GameObject.transform, ImpAssets.PositionIndicatorObject);
				Harmony.PatchAll();
				UnityExplorerIntegration.PatchFunctions(Harmony);
				IsImperiumLaunched = true;
				if (Settings.Preferences.EnableImperium.Value)
				{
					EnableImperium();
					IsLevelLoaded.SetFalse();
				}
				else
				{
					DisableImperium();
				}
			}
		}

		internal static void DisableImperium()
		{
			if (IsImperiumLaunched && ((ImpBinding<bool>)(object)IsImperiumEnabled).Value)
			{
				IsImperiumEnabled.SetFalse();
				Interface.Close();
				PlayerManager.IsFlying.SetFalse();
				Freecam.IsFreecamEnabled.SetFalse();
				PositionIndicator.Deactivate();
				TapeMeasure.Deactivate();
				InputBindings.BaseMap.Disable();
				InputBindings.StaticMap.Disable();
				InputBindings.FreecamMap.Disable();
				InputBindings.InterfaceMap.Disable();
			}
		}

		internal static void EnableImperium()
		{
			if (IsImperiumLaunched && !((ImpBinding<bool>)(object)IsImperiumEnabled).Value)
			{
				IsImperiumEnabled.SetTrue();
				Settings.LoadAll();
				RegisterInterfaces();
				InputBindings.BaseMap.Enable();
				InputBindings.StaticMap.Enable();
				InputBindings.FreecamMap.Enable();
				InputBindings.InterfaceMap.Enable();
			}
		}

		internal static void Unload()
		{
			if (IsImperiumLaunched)
			{
				Harmony.UnpatchSelf();
				Networking.Unload();
				DisableImperium();
				PreLaunchPatches();
				Object.Destroy((Object)(object)GameObject);
				IsImperiumLaunched = false;
			}
		}

		internal static void Reload()
		{
			Unload();
			Launch();
			IO.Send("[SYS] Successfully reloaded Imperium.");
		}

		private static void OnLevelLoaded(bool isLoaded)
		{
			if (isLoaded)
			{
				Settings.LoadAll();
			}
		}

		private static void RegisterInterfaces()
		{
			Interface.OpenInterface.OnUpdate += delegate(BaseUI openInterface)
			{
				if (Object.op_Implicit((Object)(object)openInterface))
				{
					PositionIndicator.Deactivate();
				}
			};
			Interface.RegisterInterface<ImperiumUI>(ImpAssets.ImperiumUIObject, "ImperiumUI", "Imperium UI", "Imperium's main interface.", InputBindings.InterfaceMap.ImperiumUI, Array.Empty<IBinding<bool>>());
			Interface.RegisterInterface<SpawningUI>(ImpAssets.SpawningUIObject, "SpawningUI", "Spawning", "Allows you to spawn objects\nsuch as Scrap or Entities.", InputBindings.InterfaceMap.SpawningUI, new IBinding<bool>[1] { IsGameLevel });
			Interface.RegisterInterface<MapUI>(ImpAssets.MapUIObject, "MapUI", "Map", "Imperium's built-in map.", InputBindings.InterfaceMap.MapUI, new IBinding<bool>[1] { IsGameLevel });
			Interface.RegisterInterface<MinimapSettings>(ImpAssets.MinimapSettingsObject, Array.Empty<IBinding<bool>>());
			Interface.RefreshTheme();
			IO.LogInfo("[SYS] Imperium interfaces have been registered! \\o/");
		}

		private static void PreLaunchPatches()
		{
			Harmony.PatchAll(typeof(PreInitPatches));
		}
	}
	internal static class LCMPluginInfo
	{
		public const string PLUGIN_GUID = "giosuel.Imperium";

		public const string PLUGIN_NAME = "Imperium Repo";

		public const string PLUGIN_VERSION = "0.2.0";
	}
}
namespace Imperium.Visualizers
{
	internal class EnemyGizmos : BaseVisualizer<IReadOnlyCollection<EnemyParent>, EnemyGizmo>
	{
		internal readonly Dictionary<string, EntityGizmoConfig> EntityInfoConfigs = new Dictionary<string, EntityGizmoConfig>();

		private readonly ConfigFile config;

		internal EnemyGizmos(Transform parent, IBinding<IReadOnlyCollection<EnemyParent>> objectsBinding, IBinding<bool> isArenaLoaded, ConfigFile config)
			: base(parent, objectsBinding, (IBinding<bool>)null)
		{
			EnemyGizmos enemyGizmos = this;
			this.config = config;
			foreach (ExtendedEnemySetup item in Imperium.ObjectManager.LoadedEntities.Value)
			{
				EntityInfoConfigs[item.EnemyName] = new EntityGizmoConfig(item.EnemyName, config);
			}
			isArenaLoaded.OnTrigger += delegate
			{
				enemyGizmos.HardRefresh(objectsBinding.Value);
			};
		}

		protected override void OnRefresh(IReadOnlyCollection<EnemyParent> objects)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			foreach (EnemyParent item in objects.Where((EnemyParent entity) => Object.op_Implicit((Object)(object)entity)))
			{
				if (!visualizerObjects.ContainsKey(((Object)item).GetInstanceID()))
				{
					if (!EntityInfoConfigs.TryGetValue(item.enemyName, out var value))
					{
						value = new EntityGizmoConfig(item.enemyName, config);
						EntityInfoConfigs[item.enemyName] = value;
					}
					GameObject val = new GameObject($"ImpVis_EnemyGizmo_{((Object)item).GetInstanceID()}");
					val.transform.SetParent(base.parent);
					EnemyGizmo enemyGizmo = val.AddComponent<EnemyGizmo>();
					enemyGizmo.Init(value, item);
					visualizerObjects[((Object)item).GetInstanceID()] = enemyGizmo;
				}
			}
		}

		private void HardRefresh(IReadOnlyCollection<EnemyParent> objects)
		{
			ClearObjects();
			OnRefresh(objects);
		}

		internal void VisionUpdate(EnemyVision vision)
		{
			if (!((Object)(object)vision?.Enemy == (Object)null) && visualizerObjects.TryGetValue(((Object)vision.Enemy.EnemyParent).GetInstanceID(), out var value))
			{
				value.VisionUpdate();
			}
		}

		internal void NoiseVisualizerUpdate(EnemyStateInvestigate instance, Vector3 origin)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (visualizerObjects.TryGetValue(((Object)instance.Enemy.EnemyParent).GetInstanceID(), out var value))
			{
				value.NoiseUpdate(origin);
			}
		}
	}
	internal class LevelPointVisualizer : BaseVisualizer<bool, Component>
	{
		private readonly GameObject levelPointParent;

		private readonly Color invalidColor = new Color(1f, 0.47f, 0.07f);

		private readonly Color validColor = new Color(0.06f, 1f, 0.64f);

		internal LevelPointVisualizer(Transform parent, ImpBinding<bool> isLoadedBinding, ImpBinding<bool> visibilityBinding)
			: base(parent, (IBinding<bool>)(object)isLoadedBinding, (IBinding<bool>)(object)visibilityBinding)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			levelPointParent = new GameObject("ImpVis_LevelPoints");
			levelPointParent.transform.SetParent(parent);
		}

		protected override void OnRefresh(bool isSceneLoaded)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			ClearObjects();
			if (!isSceneLoaded)
			{
				return;
			}
			Dictionary<Edge, LineRenderer> dictionary = new Dictionary<Edge, LineRenderer>();
			LevelPoint[] array = Object.FindObjectsByType<LevelPoint>((FindObjectsSortMode)0);
			foreach (LevelPoint val in array)
			{
				GameObject val2 = Object.Instantiate<GameObject>(ImpAssets.LevelPoint, levelPointParent.transform);
				val2.transform.localScale = Vector3.one * 0.14f;
				val2.transform.position = ((Component)val).transform.position;
				ComponentHolderProtocol.AddComponent<LevelPointObject>((Object)(object)val2.transform.Find("point"));
				visualizerObjects.Add(((Object)val2).GetInstanceID(), (Component)(object)val2.transform);
				foreach (LevelPoint connectedPoint in val.ConnectedPoints)
				{
					Edge key = new Edge(((Component)val).transform.position, ((Component)connectedPoint).transform.position);
					if (!dictionary.TryGetValue(key, out var value))
					{
						value = Geometry.CreateLine(levelPointParent.transform, 0.025f, true, (string)null, (Color?)invalidColor, (Color?)invalidColor, false, (Vector3[])(object)new Vector3[2]
						{
							key.PointA + Vector3.up * 0.04f,
							key.PointB + Vector3.up * 0.04f
						});
						visualizerObjects.Add(((Object)value).GetInstanceID(), (Component)(object)((Component)value).transform);
						dictionary[key] = value;
					}
					else
					{
						Geometry.SetLineColor(value, (Color?)validColor, (Color?)validColor);
					}
				}
			}
		}
	}
	internal class NavMeshVisualizer : BaseVisualizer<bool, Component>
	{
		private readonly GameObject navMeshParent;

		internal NavMeshVisualizer(Transform parent, ImpBinding<bool> isLoadedBinding, ImpBinding<bool> visibilityBinding)
			: base(parent, (IBinding<bool>)(object)isLoadedBinding, (IBinding<bool>)(object)visibilityBinding)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			navMeshParent = new GameObject("ImpVis_NavMesh");
			navMeshParent.transform.SetParent(parent);
		}

		protected override void OnRefresh(bool _)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			ClearObjects();
			int num = 0;
			foreach (Mesh navmeshSurface in Geometry.GetNavmeshSurfaces())
			{
				GameObject val = new GameObject($"ImpVis_NavMeshSurface_{num}");
				val.transform.SetParent(navMeshParent.transform);
				MeshRenderer val2 = val.AddComponent<MeshRenderer>();
				((Renderer)val2).material = ImpAssets.NavmeshMaterial;
				MeshFilter val3 = val.AddComponent<MeshFilter>();
				val3.mesh = navmeshSurface;
				val.AddComponent<MeshDataBuilder>();
				visualizerObjects[((Object)val).GetInstanceID()] = (Component)(object)val2;
				num++;
			}
		}

		internal void Refresh()
		{
			OnRefresh(_: true);
		}
	}
	internal class NoiseIndicators : ImpScript
	{
		private const int noiseIndicatorCount = 20;

		private const int noiseIndicatorDisplayTime = 10;

		private readonly NoiseIndicator[] noiseIndicators = new NoiseIndicator[20];

		private int noiseIndex;

		private void Awake()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			for (int i = 0; i < 20; i++)
			{
				GameObject val = new GameObject("ImpVis_NoiseIndicator" + i);
				val.transform.SetParent(((Component)this).transform);
				noiseIndicators[i] = val.AddComponent<NoiseIndicator>();
			}
			((ImpBinding<bool>)(object)Imperium.Settings.Visualization.NoiseIndicators).OnUpdate += delegate(bool value)
			{
				if (!value)
				{
					for (int j = 0; j < 20; j++)
					{
						noiseIndicators[j].Deactivate();
					}
				}
			};
		}

		internal void Clear()
		{
			NoiseIndicator[] array = noiseIndicators;
			foreach (NoiseIndicator noiseIndicator in array)
			{
				noiseIndicator.Deactivate();
			}
		}

		internal void AddNoise(Vector3 position, float radius, bool isMuted)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (Imperium.Settings.Visualization.NoiseIndicators.Value && !(!Imperium.IsLevelLoaded) && !Imperium.GameManager.IsGameLoading)
			{
				noiseIndicators[noiseIndex].Activate(position, radius, 10, isMuted);
				noiseIndex = (noiseIndex + 1) % noiseIndicators.Length;
			}
		}
	}
	internal class ObjectInsights : BaseVisualizer<HashSet<Component>, ObjectInsight>
	{
		private readonly ConfigFile config;

		internal readonly ImpBinding<Dictionary<Type, ImpBinding<bool>>> InsightVisibilityBindings = new ImpBinding<Dictionary<Type, ImpBinding<bool>>>(new Dictionary<Type, ImpBinding<bool>>(), (Dictionary<Type, ImpBinding<bool>>)null, (Action<Dictionary<Type, ImpBinding<bool>>>)null, (Action<Dictionary<Type, ImpBinding<bool>>>)null, false);

		private readonly ImpBinding<Dictionary<Type, InsightDefinition<Component>>> registeredInsights = new ImpBinding<Dictionary<Type, InsightDefinition<Component>>>(new Dictionary<Type, InsightDefinition<Component>>(), (Dictionary<Type, InsightDefinition<Component>>)null, (Action<Dictionary<Type, InsightDefinition<Component>>>)null, (Action<Dictionary<Type, InsightDefinition<Component>>>)null, false);

		private readonly HashSet<int> insightVisualizerObjects = new HashSet<int>();

		private readonly Dictionary<int, Vector3?> entityColliderCache = new Dictionary<int, Vector3?>();

		internal ObjectInsights(Transform parent, ConfigFile config)
			: base(parent, (IBinding<HashSet<Component>>)null, (IBinding<bool>)null)
		{
			this.config = config;
			RegisterDefaultInsights();
			Refresh();
			foreach (var (_, val2) in InsightVisibilityBindings.Value)
			{
				val2.OnTrigger += Refresh;
			}
			registeredInsights.OnTrigger += Refresh;
		}

		internal void Refresh()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			if (!Imperium.IsLevelLoaded || InsightVisibilityBindings.Value.All((KeyValuePair<Type, ImpBinding<bool>> binding) => !binding.Value.Value))
			{
				return;
			}
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			foreach (GameObject val in array)
			{
				if (insightVisualizerObjects.Contains(((Object)val).GetInstanceID()))
				{
					continue;
				}
				foreach (Component item in from component in val.GetComponents<Component>()
					where Object.op_Implicit((Object)(object)component)
					select component)
				{
					InsightDefinition<Component> insightDefinition = FindMostMatchingInsightDefinition(((object)item).GetType());
					if (insightDefinition != null)
					{
						if (!visualizerObjects.TryGetValue(((Object)item).GetInstanceID(), out var value))
						{
							GameObject val2 = new GameObject($"Imp_ObjectInsight_{((Object)val).GetInstanceID()}");
							val2.transform.SetParent(val.transform);
							insightVisualizerObjects.Add(((Object)val2).GetInstanceID());
							value = val2.AddComponent<ObjectInsight>();
							value.Init(item, insightDefinition);
							visualizerObjects[((Object)item).GetInstanceID()] = value;
						}
						else if (insightDefinition != value.InsightDefinition)
						{
							value.UpdateInsightDefinition(insightDefinition);
						}
					}
				}
			}
		}

		internal InsightDefinition<T> InsightsFor<T>() where T : Component
		{
			if (registeredInsights.Value.TryGetValue(typeof(T), out var value))
			{
				return value as InsightDefinition<T>;
			}
			InsightDefinitionImpl<T> insightDefinitionImpl = new InsightDefinitionImpl<T>(registeredInsights.Value, InsightVisibilityBindings, config);
			registeredInsights.Value[typeof(T)] = (InsightDefinition<Component>)insightDefinitionImpl;
			registeredInsights.Refresh();
			return insightDefinitionImpl;
		}

		private InsightDefinition<Component> FindMostMatchingInsightDefinition(Type inputType)
		{
			foreach (Type parentType in Debugging.GetParentTypes(inputType))
			{
				if (registeredInsights.Value.TryGetValue(parentType, out var value))
				{
					return value;
				}
			}
			return null;
		}

		private void RegisterDefaultInsights()
		{
			this.InsightsFor<EnemyParent>().SetNameGenerator((EnemyParent enemy) => enemy.enemyName).SetIsDisabledGenerator((EnemyParent enemy) => !enemy.Spawned)
				.RegisterInsight("Health", (EnemyParent enemy) => $"{enemy.Enemy.Health.health} HP")
				.RegisterInsight("Current State", GameManager.GetEnemyState)
				.RegisterInsight("Spawn Timer", (EnemyParent enemy) => Formatting.FormatSecondsMinutes(enemy.SpawnedTimer))
				.RegisterInsight("Spawn Paused", (EnemyParent enemy) => Formatting.FormatSecondsMinutes(enemy.spawnedTimerPauseTimer))
				.RegisterInsight("Despawn Timer", (EnemyParent enemy) => Formatting.FormatSecondsMinutes(enemy.DespawnedTimer))
				.RegisterInsight("Valuable Timer", (EnemyParent enemy) => Formatting.FormatSecondsMinutes(enemy.valuableSpawnTimer))
				.RegisterInsight("No Vision Timer", (EnemyParent enemy) => (!Object.op_Implicit((Object)(object)enemy.Enemy.Vision)) ? "?" : Formatting.FormatSecondsMinutes(enemy.Enemy.Vision.DisableTimer))
				.RegisterInsight("Player Close", (EnemyParent enemy) => enemy.playerClose.ToString())
				.RegisterInsight("Spawn Idle Timer", (EnemyParent _) => Formatting.FormatSecondsMinutes(EnemyDirector.instance.spawnIdlePauseTimer))
				.SetPositionOverride((EnemyParent enemy) => ((Component)enemy.Enemy).transform.position)
				.SetConfigKey("Enemies");
			this.InsightsFor<ExtractionPoint>().SetNameGenerator((ExtractionPoint _) => "Extraction Point").RegisterInsight("Current State", (ExtractionPoint point) => ((object)(State)(ref point.currentState)).ToString())
				.RegisterInsight("Haul Goal", (ExtractionPoint point) => SemiFunc.DollarGetString(point.haulGoal))
				.RegisterInsight("Haul Current", (ExtractionPoint point) => SemiFunc.DollarGetString(point.haulCurrent))
				.RegisterInsight("In Start Room", (ExtractionPoint point) => $"{point.inStartRoom}")
				.SetPositionOverride((ExtractionPoint point) => ((Component)point).transform.position)
				.SetConfigKey("Extraction Points");
			this.InsightsFor<ValuableObject>().SetNameGenerator((ValuableObject valuable) => ((Object)valuable).name.Replace("Valuable ", "").Replace("(Clone)", "")).RegisterInsight("Value", (ValuableObject valuable) => "$" + SemiFunc.DollarGetString(Mathf.RoundToInt(valuable.dollarValueCurrent)))
				.RegisterInsight("Is Discovered", (ValuableObject valuable) => $"{valuable.discovered}")
				.RegisterInsight("Durability", (ValuableObject valuable) => $"{valuable.durabilityPreset.durability}")
				.RegisterInsight("Discovered Timer", (ValuableObject valuable) => $"{valuable.discoveredReminderTimer:0}s")
				.SetPositionOverride((ValuableObject valuable) => ((Component)valuable).transform.position)
				.SetConfigKey("Valuables");
		}

		private Vector3 DefaultPositionOverride(Component obj)
		{
			//IL_0078: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			if (!entityColliderCache.TryGetValue(((Object)obj).GetInstanceID(), out var value))
			{
				BoxCollider componentInChildren = obj.GetComponentInChildren<BoxCollider>();
				Vector3? obj2;
				if (componentInChildren == null)
				{
					CapsuleCollider componentInChildren2 = obj.GetComponentInChildren<CapsuleCollider>();
					obj2 = ((componentInChildren2 != null) ? new Vector3?(componentInChildren2.center) : null);
				}
				else
				{
					obj2 = componentInChildren.center;
				}
				value = obj2;
				entityColliderCache[((Object)obj).GetInstanceID()] = value;
			}
			if (!value.HasValue)
			{
				return obj.transform.position;
			}
			return obj.transform.position + Vector3.up * value.Value.y * obj.transform.localScale.y * 1.5f;
		}
	}
	internal class PlayerGizmos : BaseVisualizer<IReadOnlyCollection<PlayerAvatar>, PlayerGizmo>
	{
		internal readonly Dictionary<PlayerAvatar, PlayerGizmoConfig> PlayerInfoConfigs = new Dictionary<PlayerAvatar, PlayerGizmoConfig>();

		internal PlayerGizmos(Transform parent, IBinding<IReadOnlyCollection<PlayerAvatar>> objectsBinding, ConfigFile config)
			: base(parent, objectsBinding, (IBinding<bool>)null)
		{
			foreach (PlayerAvatar player in Imperium.GameDirector.PlayerList)
			{
				PlayerInfoConfigs[player] = new PlayerGizmoConfig(player.playerName, config);
			}
		}

		protected override void OnRefresh(IReadOnlyCollection<PlayerAvatar> objects)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			ClearObjects();
			foreach (PlayerAvatar @object in objects)
			{
				if (!visualizerObjects.ContainsKey(((Object)@object).GetInstanceID()))
				{
					GameObject val = new GameObject($"ImpVis_PlayerGizmo_{((Object)@object).GetInstanceID()}");
					val.transform.SetParent(base.parent);
					PlayerGizmo playerGizmo = val.AddComponent<PlayerGizmo>();
					if (!PlayerInfoConfigs.TryGetValue(@object, out var value))
					{
						Imperium.IO.LogInfo("[ERR] Player was not found, no config loaded for insight.");
						continue;
					}
					playerGizmo.Init(value, ((Component)@object).GetComponent<PlayerAvatar>());
					visualizerObjects[((Object)@object).GetInstanceID()] = playerGizmo;
				}
			}
		}

		internal void PlayerNoiseUpdate(PlayerAvatar player, float range)
		{
			visualizerObjects[((Object)player).GetInstanceID()].NoiseUpdate(range);
		}
	}
	public class StaticVisualizers : ImpScript
	{
		private readonly Dictionary<string, VisualizerDefinition> VisualizerRegistry = new Dictionary<string, VisualizerDefinition>();

		private readonly HashSet<string> EnabledVisualizers = new HashSet<string>();

		private readonly Dictionary<string, Dictionary<int, List<GameObject>>> VisualizerObjectMap = new Dictionary<string, Dictionary<int, List<GameObject>>>();

		private static Material DefaultMaterial => ImpAssets.WireframeCyan;

		internal void Collider(bool isOn, string identifier, VisualizerIdentifier type, Material material = null, bool overrideInactive = false)
		{
			Visualize(identifier, isOn, VisualizeColliders, type, 0f, material, overrideInactive);
		}

		internal void Collider<T>(bool isOn, Material material = null, bool overrideInactive = false)
		{
			Visualize(typeof(T).AssemblyQualifiedName, isOn, VisualizeColliders, VisualizerIdentifier.Component, 0f, material, overrideInactive);
		}

		internal void Point(bool isOn, string identifier, VisualizerIdentifier type, float radius = 1f, Material material = null, bool overrideInactive = false)
		{
			Visualize(identifier, isOn, VisualizePoint, type, radius, material, overrideInactive);
		}

		internal void Point<T>(bool isOn, float radius = 1f, Material material = null, bool overrideInactive = false)
		{
			Visualize(typeof(T).AssemblyQualifiedName, isOn, VisualizePoint, VisualizerIdentifier.Component, radius, material, overrideInactive);
		}

		internal void Refresh(bool hardRefresh = false)
		{
			if (hardRefresh)
			{
				CollectionExtensions.Do<GameObject>(VisualizerObjectMap.Values.SelectMany((Dictionary<int, List<GameObject>> objs) => objs.Values).SelectMany((List<GameObject> list) => list), (Action<GameObject>)Object.Destroy);
				VisualizerObjectMap.Clear();
			}
			foreach (string key in VisualizerRegistry.Keys)
			{
				ToggleVisualizer(key, EnabledVisualizers.Contains(key));
			}
		}

		private void ToggleVisualizer(string uniqueIdentifier, bool isOn)
		{
			if (!VisualizerRegistry.TryGetValue(uniqueIdentifier, out var value))
			{
				Imperium.IO.LogError("[VIS] Failed to toggle unregistered visualizer '" + uniqueIdentifier + "'. Aborting.");
				return;
			}
			if (!isOn)
			{
				EnabledVisualizers.Remove(uniqueIdentifier);
				if (!VisualizerObjectMap.TryGetValue(uniqueIdentifier, out var value2))
				{
					return;
				}
				{
					foreach (List<GameObject> value5 in value2.Values)
					{
						ImpUtils.ToggleGameObjects(value5, isOn: false);
					}
					return;
				}
			}
			EnabledVisualizers.Add(uniqueIdentifier);
			if (!VisualizerObjectMap.TryGetValue(uniqueIdentifier, out var value3))
			{
				value3 = new Dictionary<int, List<GameObject>>();
				VisualizerObjectMap[uniqueIdentifier] = value3;
			}
			foreach (GameObject targetObject in GetTargetObjects(value.identifier, value.type, value.overrideInactive))
			{
				if (value3.TryGetValue(((Object)targetObject).GetInstanceID(), out var value4))
				{
					ImpUtils.ToggleGameObjects(value4, isOn: true);
				}
				else
				{
					value3.Add(((Object)targetObject).GetInstanceID(), value.visualizer(targetObject, value.size, value.material, value.overrideInactive).ToList());
				}
			}
		}

		private void Visualize(string identifier, bool isOn, VisualizerFunc visualizer, VisualizerIdentifier type, float size, Material material, bool overrideInactive)
		{
			string text = $"{identifier}_{size}";
			VisualizerRegistry[text] = new VisualizerDefinition(identifier, type, size, visualizer, material, overrideInactive);
			ToggleVisualizer(text, isOn);
		}

		private IEnumerable<GameObject> VisualizePoint(GameObject target, float size, Material material = null, bool overrideInactive = false)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = (overrideInactive ? ((Component)this).transform : target.transform);
			GameObject val2 = Geometry.CreatePrimitive((PrimitiveType)0, val, material ?? DefaultMaterial, size, 0, $"ImpVis_{((Object)target).GetInstanceID()}", true, false, false);
			val2.transform.position = target.transform.position;
			return new <>z__ReadOnlySingleElementList<GameObject>(val2);
		}

		private static IEnumerable<GameObject> VisualizeColliders(GameObject target, float size, Material material = null, bool overrideInactive = false)
		{
			return (from collider in target.GetComponentsInChildren<BoxCollider>()
				select VisualizeBoxCollider(collider, material)).Concat(from collider in target.GetComponentsInChildren<CapsuleCollider>()
				select VisualizeCapsuleCollider(collider, material)).Concat(from collider in target.GetComponentsInChildren<SphereCollider>()
				select VisualizeSphereCollider(collider, material)).ToList();
		}

		private static GameObject VisualizeBoxCollider(BoxCollider collider, Material material = null)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)collider))
			{
				return null;
			}
			GameObject val = Geometry.CreatePrimitive((PrimitiveType)3, ((Component)collider).transform, material ?? DefaultMaterial, 1f, 0, $"ImpVis_{((Object)collider).GetInstanceID()}", true, false, false);
			Transform transform = ((Component)collider).transform;
			val.transform.position = transform.position;
			val.transform.localPosition = collider.center;
			val.transform.localScale = collider.size;
			val.transform.rotation = transform.rotation;
			return val;
		}

		private static GameObject VisualizeCapsuleCollider(CapsuleCollider collider, Material material = null)
		{
			//IL_004b: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)collider))
			{
				return null;
			}
			GameObject val = Geometry.CreatePrimitive((PrimitiveType)1, ((Component)collider).transform, material ?? DefaultMaterial, 1f, 0, $"ImpVis_{((Object)collider).GetInstanceID()}", true, false, false);
			val.transform.position = ((Component)collider).transform.position;
			val.transform.localPosition = collider.center;
			val.transform.localScale = new Vector3(collider.radius * 2f, collider.height / 2f, collider.radius * 2f);
			val.transform.rotation = ((Component)collider).transform.rotation;
			return val;
		}

		private static GameObject VisualizeSphereCollider(SphereCollider collider, Material material = null)
		{
			//IL_004b: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)collider))
			{
				return null;
			}
			GameObject val = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)collider).transform, material ?? DefaultMaterial, 1f, 0, $"ImpVis_{((Object)collider).GetInstanceID()}", true, false, false);
			val.transform.position = ((Component)collider).transform.position;
			val.transform.localPosition = collider.center;
			val.transform.localScale = Vector3.one * collider.radius;
			val.transform.rotation = ((Component)collider).transform.rotation;
			return val;
		}

		private static IEnumerable<GameObject> GetTargetObjects(string identifier, VisualizerIdentifier type, bool overrideInactive)
		{
			return type switch
			{
				VisualizerIdentifier.Tag => GameObject.FindGameObjectsWithTag(identifier), 
				VisualizerIdentifier.Layer => (from obj in Object.FindObjectsByType<GameObject>((FindObjectsInactive)(overrideInactive ? 1 : 0), (FindObjectsSortMode)0)
					where obj.layer == LayerMask.NameToLayer(identifier)
					select obj).ToArray(), 
				VisualizerIdentifier.Component => from obj in ((IEnumerable<Object>)Object.FindObjectsByType(Type.GetType(identifier), (FindObjectsSortMode)0)).Select((Func<Object, GameObject>)delegate(Object obj)
					{
						GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null);
						if (val != null)
						{
							return val;
						}
						Component val2 = (Component)(object)((obj is Component) ? obj : null);
						return (val2 != null) ? val2.gameObject : null;
					})
					where Object.op_Implicit((Object)(object)obj)
					select obj, 
				_ => throw new ArgumentOutOfRangeException("type", type, null), 
			};
		}
	}
}
namespace Imperium.Visualizers.Objects
{
	public class EnemyGizmo : MonoBehaviour
	{
		private const float visualizerTimeout = 2f;

		private EnemyParent enemyParent;

		private EntityGizmoConfig entityConfig;

		private LineRenderer lastHeardNoiseLine;

		private GameObject lastHeardNoiseDot;

		private const int pathSegmentCount = 30;

		private LineRenderer pathLine;

		private readonly GameObject[] pathDots = (GameObject[])(object)new GameObject[30];

		private EnemyVision enemyVision;

		private GameObject coneStanding;

		private GameObject coneCrouching;

		private GameObject coneCrawling;

		private GameObject proximitySphereStanding;

		private GameObject proximitySphereCrouching;

		private GameObject playerCloseSphere;

		private GameObject playerVeryCloseSphere;

		private float lastUpdateTimer;

		private bool hasInitializedVision;

		internal void Init(EntityGizmoConfig config, EnemyParent entity)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			entityConfig = config;
			enemyParent = entity;
			enemyVision = entity.Enemy.Vision;
			pathLine = Geometry.CreateLine(((Component)this).transform, 0.04f, true, (string)null, (Color?)new Color(1f, 0.67f, 0.03f), (Color?)new Color(1f, 0.67f, 0.03f), true, Array.Empty<Vector3>());
			for (int i = 0; i < 30; i++)
			{
				pathDots[i] = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)this).transform, ImpAssets.WireframeYellow, 1f, 0, (string)null, true, false, true);
			}
			lastHeardNoiseLine = Geometry.CreateLine(((Component)this).transform, 0.03f, true, (string)null, (Color?)new Color(1f, 0.43f, 0.44f), (Color?)new Color(1f, 0.43f, 0.44f), true, Array.Empty<Vector3>());
			lastHeardNoiseDot = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)this).transform, new Color(1f, 1f, 1f), 0.2f, 0, (string)null, true, false, true);
			playerCloseSphere = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)enemyParent.Enemy).transform, ImpAssets.WireframeOrange, 40f, 0, (string)null, true, false, true);
			playerVeryCloseSphere = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)enemyParent.Enemy).transform, ImpAssets.WireframeRed, 12f, 0, (string)null, true, false, true);
			GameObject val = Object.Instantiate<GameObject>(ImpAssets.EnemyStatus, ((Component)this).transform);
			val.AddComponent<EnemyStatus>().Init(enemyParent, entityConfig);
			if (enemyParent.Enemy.HasVision)
			{
				InitVisionObjects(enemyParent.Enemy.Vision);
			}
		}

		private void InitVisionObjects(EnemyVision vision)
		{
			coneStanding = CreateCone("standing", vision.VisionDotStanding, vision.VisionDistance, ImpAssets.WireframeCyan);
			coneCrouching = CreateCone("crouching", vision.VisionDotCrouch, vision.VisionDistance, ImpAssets.WireframeGreen);
			coneCrawling = CreateCone("crawl", vision.VisionDotCrawl, vision.VisionDistance, ImpAssets.WireframeRed);
			proximitySphereStanding = CreateSphere("standing", vision.VisionDistanceClose, ImpAssets.WireframeCyan);
			proximitySphereCrouching = CreateSphere("crouching", vision.VisionDistanceCloseCrouch, ImpAssets.WireframeRed);
			hasInitializedVision = true;
		}

		private (GameObject, GameObject) SelectActiveVisionObjects()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			GameObject val;
			GameObject val2;
			if ((int)enemyVision.Enemy.CurrentState == 10)
			{
				val = coneStanding;
				val2 = proximitySphereStanding;
				coneCrouching.SetActive(false);
				coneCrawling.SetActive(false);
				proximitySphereCrouching.SetActive(false);
			}
			else if (PlayerAvatar.instance.isCrawling && !PlayerAvatar.instance.isTumbling)
			{
				val = coneCrawling;
				val2 = proximitySphereCrouching;
				coneStanding.SetActive(false);
				coneCrouching.SetActive(false);
				proximitySphereStanding.SetActive(false);
			}
			else if (PlayerAvatar.instance.isCrouching || PlayerAvatar.instance.isTumbling)
			{
				val = coneCrouching;
				val2 = proximitySphereCrouching;
				coneStanding.SetActive(false);
				coneCrawling.SetActive(false);
				proximitySphereStanding.SetActive(false);
			}
			else
			{
				val = coneStanding;
				val2 = proximitySphereStanding;
				coneCrouching.SetActive(false);
				coneCrawling.SetActive(false);
				proximitySphereCrouching.SetActive(false);
			}
			if (entityConfig.Vision.Value)
			{
				val.SetActive(true);
			}
			if (entityConfig.Proximity.Value)
			{
				val2.SetActive(true);
			}
			return (val, val2);
		}

		private GameObject CreateCone(string identifier, float dot, float distance, Material material)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ImpVis_LoS_" + identifier);
			val.transform.SetParent(((Component)this).transform);
			val.SetActive(false);
			((Renderer)val.AddComponent<MeshRenderer>()).material = material;
			val.AddComponent<MeshFilter>().mesh = Geometry.CreateCone(Mathf.Acos(dot) * (180f / MathF.PI));
			val.transform.localScale = Vector3.one * distance;
			return val;
		}

		private GameObject CreateSphere(string identifier, float radius, Material material)
		{
			return Geometry.CreatePrimitive((PrimitiveType)0, ((Component)this).transform, material, radius * 2f, 0, "ImpVis_Instant_" + identifier, true, false, true);
		}

		internal void NoiseUpdate(Vector3 origin)
		{
			//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_007c: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			((Component)lastHeardNoiseLine).gameObject.SetActive(entityConfig.Hearing.Value);
			lastHeardNoiseDot.gameObject.SetActive(entityConfig.Hearing.Value);
			if (entityConfig.Hearing.Value)
			{
				Geometry.SetLinePositions(lastHeardNoiseLine, (Vector3[])(object)new Vector3[2]
				{
					((Component)enemyParent.Enemy).transform.position,
					origin
				});
				lastHeardNoiseDot.gameObject.transform.position = origin;
			}
		}

		internal void VisionUpdate()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if (hasInitializedVision && (entityConfig.Vision.Value || entityConfig.Proximity.Value))
			{
				lastUpdateTimer = 2f;
				var (val, val2) = SelectActiveVisionObjects();
				if (entityConfig.Vision.Value)
				{
					val.transform.SetParent(Imperium.Settings.Visualization.SmoothAnimations.Value ? enemyVision.VisionTransform : ((Component)this).transform);
					val.transform.position = enemyVision.VisionTransform.position;
					val.transform.rotation = Quaternion.LookRotation(enemyVision.VisionTransform.forward);
				}
				if (entityConfig.Proximity.Value)
				{
					val2.transform.SetParent(Imperium.Settings.Visualization.SmoothAnimations.Value ? enemyVision.VisionTransform : ((Component)this).transform);
					val2.transform.position = enemyVision.VisionTransform.position;
					val2.transform.rotation = Quaternion.LookRotation(enemyVision.VisionTransform.forward);
				}
			}
		}

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)enemyParent))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			if (hasInitializedVision)
			{
				if (!entityConfig.Vision.Value || lastUpdateTimer < 0f)
				{
					coneStanding.SetActive(false);
					coneCrouching.SetActive(false);
					coneCrawling.SetActive(false);
				}
				if (!entityConfig.Proximity.Value || lastUpdateTimer < 0f)
				{
					proximitySphereStanding.SetActive(false);
					proximitySphereCrouching.SetActive(false);
				}
			}
			DrawPathLines(entityConfig.Pathfinding.Value && ((Behaviour)enemyParent).enabled);
			DrawNoiseLine(entityConfig.Hearing.Value && ((Behaviour)enemyParent).enabled);
			DrawPlayerCloseSpheres();
			int item = (SemiFunc.IsMultiplayer() ? ((MonoBehaviourPun)enemyParent).photonView.ViewID : ((Object)((Component)enemyParent).gameObject).GetInstanceID());
			if (!Imperium.ObjectManager.DisabledObjects.Value.Contains(item))
			{
				lastUpdateTimer -= Time.deltaTime;
			}
		}

		private void DrawNoiseLine(bool isShown)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if (!isShown || (int)enemyParent.Enemy.CurrentState != 7)
			{
				((Component)lastHeardNoiseLine).gameObject.SetActive(false);
				lastHeardNoiseDot.gameObject.SetActive(false);
			}
		}

		private void DrawPathLines(bool isShown)
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)enemyParent) || !Object.op_Implicit((Object)(object)enemyParent.Enemy.NavMeshAgent?.Agent))
			{
				GameObject[] array = pathDots;
				foreach (GameObject val in array)
				{
					val.gameObject.SetActive(false);
				}
				((Component)pathLine).gameObject.SetActive(false);
				return;
			}
			((Component)pathLine).gameObject.SetActive(isShown);
			Vector3[] corners = enemyParent.Enemy.NavMeshAgent.Agent.path.corners;
			LineRenderer obj = pathLine;
			Vector3 position = ((Component)enemyParent.Enemy).transform.position;
			Vector3[] array2 = corners;
			int num = 0;
			Vector3[] array3 = (Vector3[])(object)new Vector3[1 + array2.Length];
			array3[num] = position;
			num++;
			ReadOnlySpan<Vector3> readOnlySpan = new ReadOnlySpan<Vector3>(array2);
			readOnlySpan.CopyTo(new Span<Vector3>(array3).Slice(num, readOnlySpan.Length));
			num += readOnlySpan.Length;
			Geometry.SetLinePositions(obj, array3);
			for (int j = 0; j < 30; j++)
			{
				if (j < corners.Length)
				{
					pathDots[j].gameObject.SetActive(isShown);
					if (isShown)
					{
						pathDots[j].transform.position = corners[j];
						pathDots[j].transform.localScale = Vector3.one * 0.15f;
					}
				}
				else
				{
					pathDots[j].gameObject.SetActive(false);
				}
			}
		}

		private void DrawPlayerCloseSpheres()
		{
			bool value = Imperium.Settings.Visualization.PlayerProximity.Value;
			playerCloseSphere.SetActive(value);
		}

		private void OnDestroy()
		{
			if (hasInitializedVision)
			{
				Object.Destroy((Object)(object)coneStanding);
				Object.Destroy((Object)(object)coneCrouching);
				Object.Destroy((Object)(object)coneCrawling);
				Object.Destroy((Object)(object)proximitySphereStanding);
				Object.Destroy((Object)(object)proximitySphereCrouching);
			}
			Object.Destroy((Object)(object)playerCloseSphere);
			Object.Destroy((Object)(object)playerVeryCloseSphere);
		}
	}
	internal class EntityGizmoConfig
	{
		internal readonly string entityName;

		internal readonly ImpConfig<bool> Info;

		internal readonly ImpConfig<bool> Pathfinding;

		internal readonly ImpConfig<bool> Proximity;

		internal readonly ImpConfig<bool> Vision;

		internal readonly ImpConfig<bool> Hearing;

		internal readonly ImpConfig<bool> Vitality;

		internal readonly ImpConfig<bool> Custom;

		internal EntityGizmoConfig(string entityName, ConfigFile config)
		{
			this.entityName = entityName;
			string text = entityName.Replace("\"", "").Replace("'", "").Replace("[", "")
				.Replace("]", "")
				.Replace("\n", "")
				.Replace("\t", "")
				.Replace("\\", "");
			Info = new ImpConfig<bool>(config, "Visualization.EntityGizmos.Info", text, false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
			Pathfinding = new ImpConfig<bool>(config, "Visualization.EntityGizmos.Pathfinding", text, false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
			Proximity = new ImpConfig<bool>(config, "Visualization.EntityGizmos.Proximity", text, false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
			Vision = new ImpConfig<bool>(config, "Visualization.EntityGizmos.Vision", text, false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
			Hearing = new ImpConfig<bool>(config, "Visualization.EntityGizmos.Hearing", text, false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
			Vitality = new ImpConfig<bool>(config, "Visualization.EntityGizmos.Vitality", text, false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
			Custom = new ImpConfig<bool>(config, "Visualization.EntityGizmos.Custom", text, false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
		}
	}
	public class EnemyStatus : MonoBehaviour
	{
		private Transform healthBar;

		private Image healthBarImage;

		private TMP_Text healthBarText;

		private Transform detectionBar;

		private Image detectionBarImage;

		private TMP_Text detectionBarText;

		private EnemyParent enemy;

		private RectTransform canvasRect;

		private RectTransform panelRect;

		private Transform origin;

		private bool hasVision;

		private Vector3 panelOffset;

		private Gradient healthGradient;

		private EntityGizmoConfig config;

		private bool leFunniDuck;

		private float currentHealthValue;

		private const float smoothSpeed = 5f;

		private void Awake()
		{
			canvasRect = ((Component)((Component)this).transform).GetComponent<RectTransform>();
			panelRect = ((Component)((Component)this).transform.Find("Panel")).GetComponent<RectTransform>();
			((Component)panelRect).gameObject.SetActive(false);
			healthBar = ((Transform)panelRect).Find("Health/Container/Bar");
			healthBarImage = ((Component)healthBar).GetComponent<Image>();
			healthBarText = ((Component)((Transform)panelRect).Find("Health/Container/Text")).GetComponent<TMP_Text>();
			detectionBar = ((Transform)panelRect).Find("Detection/Container/Bar");
			detectionBarImage = ((Component)detectionBar).GetComponent<Image>();
			detectionBarText = ((Component)((Transform)panelRect).Find("Detection/Container/Text")).GetComponent<TMP_Text>();
			detectionBarText.text = "";
			SetHealthGradient();
		}

		private void SetHealthGradient()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(Color.red, 0.3f),
				new GradientColorKey(Color.yellow, 0.6f),
				new GradientColorKey(Color.green, 1f)
			};
			GradientAlphaKey[] array2 = (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey
				{
					alpha = 1f,
					time = 0f
				},
				new GradientAlphaKey
				{
					alpha = 1f,
					time = 1f
				}
			};
			healthGradient = new Gradient();
			healthGradient.SetKeys(array, array2);
		}

		internal void Init(EnemyParent enemyParent, EntityGizmoConfig enemyConfig)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			enemy = enemyParent;
			config = enemyConfig;
			hasVision = enemy.Enemy.HasVision;
			origin = (enemy.Enemy.HasVision ? enemy.Enemy.Vision.VisionTransform : ((Component)enemy.Enemy).transform);
			panelOffset = GetPanelOffset(enemy);
			leFunniDuck = enemy.enemyName == "Apex Predator" && Random.Range(0, 100) < 5;
			if (!hasVision)
			{
				((Component)((Transform)panelRect).Find("Detection")).gameObject.SetActive(false);
			}
		}

		private void Update()
		{
			//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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Invalid comparison between Unknown and I4
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Min((float)enemy.Enemy.Health.healthCurrent / (float)enemy.Enemy.Health.health, 1f);
			currentHealthValue = Mathf.Lerp(currentHealthValue, num, Time.deltaTime * 5f);
			Transform obj = healthBar;
			Vector3 localScale = detectionBar.localScale;
			localScale.x = currentHealthValue;
			obj.localScale = localScale;
			((Graphic)healthBarImage).color = healthGradient.Evaluate(currentHealthValue);
			healthBarText.text = $"{enemy.Enemy.Health.healthCurrent} HP";
			if (hasVision)
			{
				int num2 = (((int)enemy.Enemy.CurrentState == 10) ? (enemy.Enemy.Vision.VisionsToTrigger + 1) : ((PlayerAvatar.instance.isCrawling && !PlayerAvatar.instance.isTumbling) ? (enemy.Enemy.Vision.VisionsToTriggerCrawl + 1) : ((!PlayerAvatar.instance.isCrouching && !PlayerAvatar.instance.isTumbling) ? (enemy.Enemy.Vision.VisionsToTrigger + 1) : (enemy.Enemy.Vision.VisionsToTriggerCrouch + 1))));
				int valueOrDefault = MiscHelpers.GetValueOrDefault<int, int>(enemy.Enemy.Vision.VisionsTriggered, Imperium.Player.photonView.ViewID);
				float x = Mathf.Min((float)valueOrDefault / (float)num2, 1f);
				Transform obj2 = detectionBar;
				localScale = detectionBar.localScale;
				localScale.x = x;
				obj2.localScale = localScale;
				detectionBarText.text = ((valueOrDefault < num2) ? ((valueOrDefault == 0) ? "Idle" : $"{Mathf.Min(valueOrDefault, num2)}/{num2}") : (leFunniDuck ? "Ducktected!" : "Detected!"));
			}
		}

		private void LateUpdate()
		{
			//IL_0057: 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)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			Camera value = Imperium.ActiveCamera.Value;
			if (!Object.op_Implicit((Object)(object)value) || !Object.op_Implicit((Object)(object)enemy) || !enemy.Spawned || !config.Vitality.Value)
			{
				((Component)panelRect).gameObject.SetActive(false);
				return;
			}
			Vector3 position = origin.position + panelOffset;
			((Component)canvasRect).transform.position = position;
			((Component)panelRect).gameObject.SetActive(true);
			Vector3 val = -(((Component)Imperium.ActiveCamera.Value).transform.position - ((Component)panelRect).transform.position);
			Quaternion rotation = Quaternion.LookRotation(val, Vector3.up);
			((Component)panelRect).transform.rotation = rotation;
		}

		private static Vector3 GetPanelOffset(EnemyParent enemyParent)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((Component)enemyParent).GetComponentInChildren<EnemyCeilingEye>() != (Object)null)
			{
				return Vector3.down * 0.2f;
			}
			if ((Object)(object)((Component)enemyParent).GetComponentInChildren<EnemyHeadController>() != (Object)null)
			{
				return Vector3.up * 0.6f;
			}
			if ((Object)(object)((Component)enemyParent).GetComponentInChildren<EnemyRobe>() != (Object)null)
			{
				return Vector3.up * 0.4f;
			}
			if ((Object)(object)((Component)enemyParent).GetComponentInChildren<EnemyHunter>() != (Object)null)
			{
				return Vector3.up * 2.4f;
			}
			return Vector3.up * 0.2f;
		}
	}
	public class LevelPointObject : MonoBehaviour
	{
		private void Update()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			Vector3 position = ((Component)Imperium.ActiveCamera.Value).transform.position;
			position.y = ((Component)this).transform.position.y;
			transform.LookAt(position);
		}
	}
	public class NoiseIndicator : MonoBehaviour
	{
		private float timer;

		private bool isDone;

		private GameObject normalSphere;

		private GameObject spawnDecreaseSphere;

		private GameObject mutedSphere;

		internal void Awake()
		{
			normalSphere = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)this).transform, ImpAssets.FresnelOrange, 1f, 0, (string)null, true, false, false);
			spawnDecreaseSphere = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)this).transform, ImpAssets.FresnelRed, 1f, 0, (string)null, true, false, false);
			mutedSphere = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)this).transform, ImpAssets.FresnelWhite, 1f, 0, (string)null, true, false, false);
		}

		internal void Activate(Vector3 position, float radius, int time, bool isMuted)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0047: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			timer = time;
			isDone = false;
			((Component)this).transform.position = position;
			mutedSphere.transform.localScale = Vector3.one * radius;
			normalSphere.transform.localScale = Vector3.one * radius;
			spawnDecreaseSphere.transform.localScale = Vector3.one * radius;
			mutedSphere.SetActive(isMuted);
			normalSphere.SetActive(!isMuted && radius < 15f);
			spawnDecreaseSphere.SetActive(!isMuted && radius >= 15f);
			((Component)this).gameObject.SetActive(true);
		}

		internal void Deactivate()
		{
			((Component)this).gameObject.SetActive(false);
		}

		private void LateUpdate()
		{
			if (((ImpBinding<bool>)(object)Imperium.IsLevelLoaded).Value && !Imperium.GameManager.IsGameLoading)
			{
				if (timer >= 0f)
				{
					timer -= Time.deltaTime;
				}
				else if (!isDone)
				{
					Deactivate();
					isDone = true;
				}
			}
		}
	}
	public class ObjectInsight : MonoBehaviour
	{
		private Component targetObject;

		private GameObject insightPanelObject;

		private Transform panelContainer;

		private Transform insightPanel;

		private RectTransform insightPanelRect;

		private RectTransform insightPanelCanvasRect;

		private TMP_Text panelObjectName;

		private TMP_Text panelObjectPersonalName;

		private GameObject panelEntryTemplate;

		private Image deathOverlay;

		private readonly Dictionary<string, ObjectInsightEntry> targetInsightEntries = new Dictionary<string, ObjectInsightEntry>();

		private readonly ImpTimer overlayUpdateTimer = ImpTimer.ForInterval(1f);

		internal InsightDefinition<Component> InsightDefinition { get; private set; }

		internal void Init(Component target, InsightDefinition<Component> definition)
		{
			targetObject = target;
			InsightDefinition = definition;
			insightPanelObject = Object.Instantiate<GameObject>(ImpAssets.ObjectInsightPanel, ((Component)this).transform);
			panelContainer = insightPanelObject.transform.Find("Container");
			insightPanel = panelContainer.Find("Panel");
			insightPanelRect = ((Component)panelContainer).GetComponent<RectTransform>();
			insightPanelCanvasRect = insightPanelObject.GetComponent<RectTransform>();
			panelObjectName = ((Component)insightPanel.Find("Name")).GetComponent<TMP_Text>();
			panelObjectPersonalName = ((Component)insightPanel.Find("PersonalName")).GetComponent<TMP_Text>();
			deathOverlay = ((Component)insightPanel.Find("Death")).GetComponent<Image>();
			panelEntryTemplate = ((Component)insightPanel.Find("Template")).gameObject;
			panelEntryTemplate.SetActive(false);
			InsightDefinition.Insights.OnUpdate += OnInsightsPrimaryUpdate;
			OnInsightsPrimaryUpdate(InsightDefinition.Insights.Value);
			UpdateInsightOverlay();
		}

		internal void UpdateInsightDefinition(InsightDefinition<Component> definition)
		{
			InsightDefinition.Insights.OnUpdate -= OnInsightsPrimaryUpdate;
			InsightDefinition = definition;
			InsightDefinition.Insights.OnUpdate += OnInsightsPrimaryUpdate;
		}

		private void OnInsightsPrimaryUpdate(Dictionary<string, Func<Component, string>> insights)
		{
			foreach (var (text2, func2) in insights)
			{
				if (!targetInsightEntries.TryGetValue(text2, out var value))
				{
					targetInsightEntries[text2] = CreateInsightEntry(text2, func2);
				}
				else
				{
					value.Init(text2, func2, targetObject);
				}
			}
			foreach (string item in targetInsightEntries.Keys.ToHashSet().Except(insights.Keys.ToHashSet()))
			{
				Object.Destroy((Object)(object)((Component)targetInsightEntries[item]).gameObject);
				targetInsightEntries.Remove(item);
			}
		}

		private ObjectInsightEntry CreateInsightEntry(string insightName, Func<Component, string> insightGenerator)
		{
			if (targetInsightEntries.TryGetValue(insightName, out var value))
			{
				Object.Destroy((Object)(object)((Component)value).gameObject);
			}
			GameObject val = Object.Instantiate<GameObject>(panelEntryTemplate, insightPanel);
			val.SetActive(true);
			ObjectInsightEntry objectInsightEntry = val.gameObject.AddComponent<ObjectInsightEntry>();
			objectInsightEntry.Init(insightName, insightGenerator, targetObject);
			return objectInsightEntry;
		}

		private void UpdateInsightOverlay()
		{
			panelObjectName.text = ((InsightDefinition.NameGenerator != null) ? InsightDefinition.NameGenerator(targetObject) : ((Object)targetObject).GetInstanceID().ToString());
			if (InsightDefinition.PersonalNameGenerator == null)
			{
				((Component)panelObjectPersonalName).gameObject.SetActive(false);
			}
			else
			{
				panelObjectPersonalName.text = InsightDefinition.PersonalNameGenerator(targetObject);
				((Component)panelObjectPersonalName).gameObject.SetActive(true);
			}
			if (InsightDefinition.IsDisabledGenerator != null && InsightDefinition.IsDisabledGenerator(targetObject))
			{
				((Component)deathOverlay).gameObject.SetActive(true);
			}
			else
			{
				((Component)deathOverlay).gameObject.SetActive(false);
			}
		}

		private void LateUpdate()
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			Camera value = Imperium.ActiveCamera.Value;
			if (!Object.op_Implicit((Object)(object)value) || !Object.op_Implicit((Object)(object)targetObject) || !Object.op_Implicit((Object)(object)insightPanelCanvasRect))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			RenderTexture activeTexture = value.activeTexture;
			if (InsightDefinition.VisibilityBinding.Value)
			{
				Func<Component, bool> isDisabledGenerator = InsightDefinition.IsDisabledGenerator;
				if ((isDisabledGenerator == null || !isDisabledGenerator(targetObject) || !Imperium.Settings.Visualization.SSHideDespawned.Value) && Object.op_Implicit((Object)(object)activeTexture) && ((ImpBinding<bool>)(object)Imperium.IsLevelLoaded).Value && !Imperium.GameManager.IsGameLoading)
				{
					Vector3 val = InsightDefinition.PositionOverride?.Invoke(targetObject) ?? targetObject.transform.position;
					Vector3 val2 = value.WorldToScreenPoint(val);
					if ((Physics.Linecast(((Component)value).transform.position, val) && !Imperium.Settings.Visualization.SSAlwaysOnTop.Value) || val2.z < 0f)
					{
						insightPanelObject.SetActive(false);
						return;
					}
					if (overlayUpdateTimer.Tick())
					{
						UpdateInsightOverlay();
					}
					float num = (float)((Texture)activeTexture).width / insightPanelCanvasRect.sizeDelta.x;
					float num2 = (float)((Texture)activeTexture).height / insightPanelCanvasRect.sizeDelta.y;
					float num3 = val2.x / num;
					float num4 = val2.y / num2;
					insightPanelRect.anchoredPosition = new Vector2(num3, num4);
					float num5 = Imperium.Settings.Visualization.SSOverlayScale.Value;
					if (Imperium.Settings.Visualization.SSAutoScale.Value)
					{
						num5 *= Math.Clamp(5f / Vector3.Distance(((Component)value).transform.position, val), 0.01f, 1f);
					}
					((Component)this).transform.localScale = Vector3.one;
					((Transform)insightPanelRect).localScale = num5 * Vector3.one;
					insightPanelObject.SetActive(true);
					return;
				}
			}
			insightPanelObject.SetActive(false);
		}
	}
	public class ObjectInsightEntry : MonoBehaviour
	{
		private Component targetComponent;

		private Func<Component, string> insightGenerator;

		private TMP_Text insightValueText;

		private readonly ImpTimer entryUpdateTimer = ImpTimer.ForInterval(0.2f);

		public void Init(string insightName, Func<Component, string> generator, Component target)
		{
			insightGenerator = generator;
			targetComponent = target;
			insightValueText = ((Component)((Component)this).transform.Find("Value")).GetComponent<TMP_Text>();
			((Component)((Component)this).transform.Find("Title")).GetComponent<TMP_Text>().text = insightName;
			insightValueText.text = insightGenerator(targetComponent);
		}

		private void Update()
		{
			if (entryUpdateTimer.Tick())
			{
				insightValueText.text = insightGenerator(targetComponent);
			}
		}
	}
	public class PlayerGizmo : MonoBehaviour
	{
		private PlayerAvatar playerController;

		private PlayerGizmoConfig playerGizmoConfig;

		private GameObject noiseRangeSphere;

		internal void Init(PlayerGizmoConfig config, PlayerAvatar player)
		{
			playerGizmoConfig = config;
			playerController = player;
			noiseRangeSphere = Geometry.CreatePrimitive((PrimitiveType)0, ((Component)player).transform, ImpAssets.WireframeRed, 1f, 0, (string)null, true, false, true);
		}

		internal void NoiseUpdate(float range)
		{
		}

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)playerController))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				DrawNoiseRange(playerGizmoConfig.NoiseRange.Value);
			}
		}

		private void DrawNoiseRange(bool isShown)
		{
			if (!isShown)
			{
				noiseRangeSphere.SetActive(false);
			}
		}
	}
	internal class PlayerGizmoConfig
	{
		internal readonly string playerName;

		internal readonly ImpBinding<bool> NoiseRange;

		internal PlayerGizmoConfig(string playerName, ConfigFile config)
		{
			this.playerName = playerName;
			NoiseRange = (ImpBinding<bool>)(object)new ImpConfig<bool>(config, "Visualization.PlayerGizmos", "NoiseRange", false, (Action<bool>)null, (Action<bool>)null, false, false, (string)null, (Func<bool>)null);
		}
	}
}
namespace Imperium.Util
{
	internal struct Edge
	{
		public Vector3 PointA;

		public Vector3 PointB;

		public Edge(Vector3 a, Vector3 b)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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 (((Vector3)(ref a)).sqrMagnitude <= ((Vector3)(ref b)).sqrMagnitude)
			{
				PointA = a;
				PointB = b;
			}
			else
			{
				PointA = b;
				PointB = a;
			}
		}

		public override bool Equals(object obj)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!(obj is Edge edge))
			{
				return false;
			}
			if (PointA == edge.PointA)
			{
				return PointB == edge.PointB;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return ((object)(Vector3)(ref PointA)).GetHashCode() ^ ((object)(Vector3)(ref PointB)).GetHashCode();
		}
	}
	internal abstract class ImpAssets
	{
		internal static GameObject ImperiumDockObject;

		internal static GameObject ImperiumTooltipObject;

		internal static GameObject ImperiumUIObject;

		internal static GameObject MapUIObject;

		internal static GameObject SpawningUIObject;

		internal static GameObject LayerSelectorObject;

		internal static GameObject ComponentManagerObject;

		internal static GameObject MinimapOverlayObject;

		internal static GameObject MinimapSettingsObject;

		internal static GameObject ControlCenterWindowObject;

		internal static GameObject ObjectExplorerWindowObject;

		internal static GameObject InfoWindowObject;

		internal static GameObject LevelGenerationWindowObject;

		internal static GameObject EventLogWindowObject;

		internal static GameObject ArenaControlWindowObject;

		internal static GameObject RenderingWindowObject;

		internal static GameObject SaveEditorWindowObject;

		internal static GameObject TeleportationWindowObject;

		internal static GameObject VisualizationWindowObject;

		internal static GameObject PreferencesWindowObject;

		internal static GameObject PortalWindowObject;

		internal static GameObject UpgradesWindowObject;

		internal static Material FresnelWhite;

		internal static Material FresnelBlue;

		internal static Material FresnelYellow;

		internal static Material FresnelGreen;

		internal static Material FresnelRed;

		internal static Material FresnelOrange;

		internal static Material WireframePurple;

		internal static Material WireframeOrange;

		internal static Material WireframeCyan;

		internal static Material WireframeAmaranth;

		internal static Material WireframeYellow;

		internal static Material WireframeGreen;

		internal static Material WireframeRed;

		internal static Material XRay;

		internal static Material ShiggyMaterial;

		internal static Material NavmeshMaterial;

		internal static GameObject PositionIndicatorObject;

		internal static GameObject TapeIndicatorObject;

		internal static GameObject WaypointOverlay;

		internal static GameObject ObjectInsightPanel;

		internal static GameObject WaypointBeacon;

		internal static GameObject LevelPoint;

		internal static GameObject EnemyStatus;

		internal static AudioClip ButtonClick;

		internal static AudioClip OpenClick;

		internal static AssetBundle ImperiumAssets;

		private static readonly Dictionary<string, Sprite> spriteCache = new Dictionary<string, Sprite>();

		private static List<string> logBuffer = new List<string>();

		internal static bool Load()
		{
			if (!LoadAssets())
			{
				Imperium.IO.LogInfo("[INIT] Failed to load one or more assets from assembly, aborting!");
				return false;
			}
			return true;
		}

		private static bool LoadAssets()
		{
			using (Stream stream = LoadResource("Imperium.resources.assets.imperium_assets"))
			{
				ImperiumAssets = AssetBundle.LoadFromStream(stream);
			}
			if ((Object)(object)ImperiumAssets == (Object)null)
			{
				Imperium.IO.LogError("[INIT] Failed to load assets from assembly, aborting!");
				return false;
			}
			logBuffer = new List<string>();
			List<bool> source = new List<bool>(47)
			{
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/imperium_dock.prefab", out ImperiumDockObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/tooltip.prefab", out ImperiumTooltipObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/imperium_ui.prefab", out ImperiumUIObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/layer_selector.prefab", out LayerSelectorObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/component_manager.prefab", out ComponentManagerObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/map_ui.prefab", out MapUIObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/minimap.prefab", out MinimapOverlayObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/minimap_settings.prefab", out MinimapSettingsObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/spawning_ui.prefab", out SpawningUIObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/control_center.prefab", out ControlCenterWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/info.prefab", out InfoWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/level_generation.prefab", out LevelGenerationWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/event_log.prefab", out EventLogWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/object_explorer.prefab", out ObjectExplorerWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/preferences.prefab", out PreferencesWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/portal.prefab", out PortalWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/upgrades.prefab", out UpgradesWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/rendering.prefab", out RenderingWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/save_editor.prefab", out SaveEditorWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/arena_control.prefab", out ArenaControlWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/teleportation.prefab", out TeleportationWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/UI/Windows/visualization.prefab", out VisualizationWindowObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/tape_indicator.prefab", out TapeIndicatorObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/position_indicator.prefab", out PositionIndicatorObject),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/insight_panel.prefab", out ObjectInsightPanel),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/waypoint_beacon.prefab", out WaypointBeacon),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/level_point.prefab", out LevelPoint),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/enemy_status.prefab", out EnemyStatus),
				LoadAsset<GameObject>(ImperiumAssets, "Assets/Imperium/Prefabs/waypoint_overlay.prefab", out WaypointOverlay),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/xray.mat", out XRay),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/fresnel_white.mat", out FresnelWhite),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/fresnel_blue.mat", out FresnelBlue),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/fresnel_red.mat", out FresnelRed),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/fresnel_orange.mat", out FresnelOrange),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/fresnel_green.mat", out FresnelGreen),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/fresnel_yellow.mat", out FresnelYellow),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/wireframe_purple.mat", out WireframePurple),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/wireframe_orange.mat", out WireframeOrange),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/wireframe_cyan.mat", out WireframeCyan),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/wireframe_amaranth.mat", out WireframeAmaranth),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/wireframe_yellow.mat", out WireframeYellow),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/wireframe_green.mat", out WireframeGreen),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/wireframe_red.mat", out WireframeRed),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/shig.mat", out ShiggyMaterial),
				LoadAsset<Material>(ImperiumAssets, "Assets/Imperium/Materials/navmesh.mat", out NavmeshMaterial),
				LoadAsset<AudioClip>(ImperiumAssets, "Assets/Imperium/Audio/ButtonClick.wav", out ButtonClick),
				LoadAsset<AudioClip>(ImperiumAssets, "Assets/Imperium/Audio/OpenClick.ogg", out OpenClick)
			};
			Imperium.IO.LogBlock(logBuffer, "Imperium Resource Loader");
			return source.All((bool result) => result);
		}

		internal static Sprite LoadSpriteFromFiles(string spriteName)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			string text = new string[3]
			{
				Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
				"images",
				spriteName + ".png"
			}.Aggregate(Path.Combine);
			if (spriteCache.TryGetValue(text, out var value))
			{
				return value;
			}
			if (File.Exists(text))
			{
				byte[] array = File.ReadAllBytes(text);
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, array))
				{
					value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f));
					spriteCache[spriteName] = value;
					return value;
				}
			}
			return null;
		}

		private static bool LoadAsset<T>(AssetBundle assets, string path, out T loadedObject) where T : Object
		{
			loadedObject = assets.LoadAsset<T>(path);
			if (!Object.op_Implicit((Object)(object)loadedObject))
			{
				Imperium.IO.LogError("[INIT] Object '" + path + "' missing from the embedded Imperium asset bundle.");
				return false;
			}
			logBuffer.Add("> Successfully loaded " + path.Split("/").Last() + " from asset bundle.");
			return true;
		}

		private static Stream LoadResource(string name)
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
		}
	}
	public abstract class ImpAttributes
	{
		internal class HostOnly : Attribute
		{
		}

		internal class LocalMethod : Attribute
		{
		}

		internal class RemoteMethod : Attribute
		{
		}

		internal class HostMasterBinding : Attribute
		{
		}
	}
	public static class ImpMath
	{
		public static float SampleQuadraticBezier(float start, float end, float control, float t)
		{
			return (1f - t) * (1f - t) * start + 2f * (1f - t) * t * control + t * t * end;
		}

		public static float NormalizeFloat(float value)
		{
			string[] array = value.ToString(CultureInfo.InvariantCulture).Split('.');
			if (array.Length == 1)
			{
				return value;
			}
			if (int.Parse(array[1]) == 0)
			{
				return (int)value;
			}
			return MathF.Round(value);
		}

		internal static Vector3 ClosestPointAlongRay(Ray ray, Vector3 point)
		{
			//IL_0002: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Vector3 origin = ((Ray)(ref ray)).origin;
			Vector3 val = ((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction;
			Vector3 val2 = val - origin;
			float num = Vector3.Dot(point - origin, val2);
			num = Mathf.Max(num, 0f);
			return ((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction * num;
		}
	}
	internal class ImpOutput
	{
		[CompilerGenerated]
		private ManualLogSource <logger>P;

		private Dictionary<NotificationType, ImpBinding<bool>> NotificationSettings;

		public ImpOutput(ManualLogSource logger)
		{
			<logger>P = logger;
			NotificationSettings = new Dictionary<NotificationType, ImpBinding<bool>>();
			base..ctor();
		}

		internal void BindNotificationSettings(ImpSettings settings)
		{
			NotificationSettings = new Dictionary<NotificationType, ImpBinding<bool>>
			{
				{
					NotificationType.GodMode,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsGodMode
				},
				{
					NotificationType.OracleUpdate,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsOracle
				},
				{
					NotificationType.Confirmation,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsConfirmation
				},
				{
					NotificationType.SpawnReport,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsSpawnReports
				},
				{
					NotificationType.Entities,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsEntities
				},
				{
					NotificationType.Server,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsServer
				},
				{
					NotificationType.AccessControl,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsAccessControl
				},
				{
					NotificationType.Spawning,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsSpawning
				},
				{
					NotificationType.Required,
					new ImpBinding<bool>(true, false, (Action<bool>)null, (Action<bool>)null, false)
				},
				{
					NotificationType.Other,
					(ImpBinding<bool>)(object)settings.Preferences.NotificationsOther
				}
			};
		}

		private bool IsNotificationEnabled(NotificationType type)
		{
			return NotificationSettings.GetValueOrDefault(type, null)?.Value ?? false;
		}

		internal void Send(string text, string title = "Imperium", bool isWarning = false, NotificationType type = NotificationType.Other)
		{
			//IL_0018: 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)
			if (IsNotificationEnabled(type) && !Imperium.Settings.IsLoading)
			{
				SemiFunc.UIFocusText(text, Color.white, AssetManager.instance.colorYellow, 3f);
			}
		}

		internal void LogBlock(List<string> lines, string title = "Imperium Monitoring")
		{
			if (Imperium.Settings.Preferences.GeneralLogging.Value)
			{
				title = "< " + title + " >";
				int width = Mathf.Min(lines.Max((string line) => line.Length) + 4, 520);
				string text = string.Concat(Enumerable.Repeat("═", width - 2));
				int num = (width - title.Length) / 2 - 1;
				if ((width - title.Length) / 2 % 2 == 0)
				{
					num++;
				}
				string text2 = string.Concat(Enumerable.Repeat(" ", num));
				string text3 = "╒" + text + "╕\n";
				text3 = text3 + "│" + text2 + title + text2 + "│\n";
				text3 = text3 + "╞" + text + "╡\n";
				text3 = lines.Aggregate(text3, delegate(string current, string line)
				{
					string text5 = ((line.Length > 512) ? (line.Substring(0, 512) + "...") : line);
					return current + ("│ " + text5).PadRight(width - 2) + " │\n";
				});
				text3 = text3 + "╘" + text + "╛";
				string[] array = text3.Split("\n");
				foreach (string text4 in array)
				{
					Log((LogLevel)8, text4.Trim());
				}
			}
		}

		internal void Log(LogLevel level, string text)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			<logger>P.Log(level, (object)text);
		}

		internal void LogInfo(string text)
		{
			<logger>P.LogInfo((object)text);
		}

		internal void LogDebug(string text)
		{
			<logger>P.LogDebug((object)text);
		}

		internal void LogWarning(string text)
		{
			<logger>P.LogWarning((object)text);
		}

		internal void LogError(string text)
		{
			<logger>P.LogError((object)text);
		}
	}
	public class ImpStack<T> : List<T>
	{
		public void MoveToBackOrAdd(T item)
		{
			int num = IndexOf(item);
			if (num > -1)
			{
				Remove(item);
			}
			Add(item);
		}
	}
	internal class ImpTimer
	{
		private float initialTime;

		private float countdown;

		private ImpTimer()
		{
		}

		internal static ImpTimer ForInterval(float seconds)
		{
			return new ImpTimer
			{
				initialTime = seconds,
				countdown = seconds
			};
		}

		internal void Set(float newTime)
		{
			initialTime = newTime;
		}

		internal bool Tick()
		{
			countdown -= Time.deltaTime;
			if (countdown <= 0f)
			{
				countdown = initialTime;
				return true;
			}
			return false;
		}

		internal void Reset()
		{
			countdown = initialTime;
		}
	}
	public abstract class ImpUtils
	{
		internal abstract class Interface
		{
			[CompilerGenerated]
			private sealed class <SlideInAndBounceAnimation>d__7 : IEnumerator<