Decompiled source of CompanyLighting v1.0.0

SomethingSomethingCompany.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CompanyLighting.UpgradeLogic;
using CompanyLighting.UpgradeLogic.RadarPing;
using GameNetcodeStuff;
using HarmonyLib;
using LethalAPI.LibTerminal;
using LethalAPI.LibTerminal.Attributes;
using LethalAPI.LibTerminal.Interactions;
using LethalAPI.LibTerminal.Models;
using LethalNetworkAPI;
using LethalNetworkAPI.Utils;
using SomethingSomethingCompany.NetcodePatcher;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SomethingSomethingCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SomethingSomethingCompany")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5c8bdedf-3253-4203-9016-42eec73a5697")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace CompanyLighting
{
	public class LightingNetworkHandler
	{
		private readonly Dictionary<string, LNetworkVariable<int>> _upgradeVars = new Dictionary<string, LNetworkVariable<int>>();

		private LNetworkMessage<string> _purchaseRequest;

		private bool _hasLoadedServerSave;

		public static LightingNetworkHandler Instance { get; private set; }

		public static void Initialize()
		{
			if (Instance == null)
			{
				Instance = new LightingNetworkHandler();
				Instance.SetupNetworking();
			}
		}

		private void SetupNetworking()
		{
			foreach (string key in Upgrades.UpgradeList.Keys)
			{
				_upgradeVars[key] = LNetworkVariable<int>.Connect("BetterLighting_Upgrade_" + key, 0, (LNetworkVariableWritePerms)0, (Action<int, int>)null);
			}
			_purchaseRequest = LNetworkMessage<string>.Connect("BetterLighting_PurchaseRequest", (Action<string, ulong>)null, (Action<string>)null, (Action<string, ulong>)null);
			_purchaseRequest.OnServerReceived += OnPurchaseRequestReceived;
			LNetworkUtils.OnNetworkStart += OnNetworkStart;
		}

		private void OnNetworkStart(bool isHostOrServer)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer || _hasLoadedServerSave)
			{
				return;
			}
			_hasLoadedServerSave = true;
			Debug.Log((object)"[CompanyLighting] Server is loading saved upgrade levels.");
			foreach (KeyValuePair<string, LNetworkVariable<int>> upgradeVar in _upgradeVars)
			{
				int num = SaveManager.LoadUpgradeLevel(upgradeVar.Key);
				upgradeVar.Value.Value = num;
				Debug.Log((object)$"[CompanyLighting] Server Loaded: {upgradeVar.Key} = {num}");
			}
		}

		private void OnPurchaseRequestReceived(string upgradeKey, ulong senderClientId)
		{
			Debug.Log((object)$"[CompanyLighting] Server received purchase request for '{upgradeKey}' from client {senderClientId}");
			if (!string.IsNullOrEmpty(upgradeKey) && Upgrades.UpgradeList.ContainsKey(upgradeKey) && _upgradeVars.TryGetValue(upgradeKey, out var value))
			{
				(string, int, int, string, float) tuple = Upgrades.UpgradeList[upgradeKey];
				int value2 = value.Value;
				if (value2 < tuple.Item3)
				{
					int num = value2 + 1;
					SaveManager.SaveUpgradeLevel(upgradeKey, num);
					value.Value = num;
					Debug.Log((object)$"[CompanyLighting] Server upgraded '{upgradeKey}' to {num}");
				}
			}
		}

		public void RequestPurchase(string upgradeKey)
		{
			_purchaseRequest?.SendServer(upgradeKey);
		}

		public int GetUpgradeLevel(string upgradeKey, int defaultValue = 0)
		{
			if (_upgradeVars.TryGetValue(upgradeKey, out var value))
			{
				return value.Value;
			}
			return defaultValue;
		}
	}
	[BepInPlugin("mogus.vin.betterlighting", "BetterLighting", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private static TerminalCommands CurTerminal;

		public const string PLUGIN_GUID = "mogus.vin.betterlighting";

		public const string PLUGIN_NAME = "BetterLighting";

		public const string PLUGIN_VER = "1.0.0";

		public static Harmony VinPatcher = new Harmony("mogus.vin.betterlighting");

		public static ManualLogSource VinLogger;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			VinLogger = ((BaseUnityPlugin)this).Logger;
			VinLogger.LogInfo((object)"Attempting to patch using Harmony.");
			VinPatcher.PatchAll();
			Upgrades.SetupUpgrades();
			LightingNetworkHandler.Initialize();
			RadarPingManager.Initialize();
			if (CurTerminal == null)
			{
				CurTerminal = new TerminalCommands();
				TerminalCommands.SetupTerminal(CurTerminal);
			}
		}

		private static void InitializeNetcodePatchedTypes()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class SaveManager
	{
		private const string SAVE_PREFIX = "CompanyLighting_";

		public static void SaveUpgradeLevel(string upgradeKey, int upgradeLevel)
		{
			if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && GameNetworkManager.Instance.isHostingGame)
			{
				string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
				if (!string.IsNullOrEmpty(currentSaveFileName))
				{
					ES3.Save<int>("CompanyLighting_" + upgradeKey, upgradeLevel, currentSaveFileName);
				}
			}
		}

		public static int LoadUpgradeLevel(string upgradeKey, int defaultValue = 0)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return defaultValue;
			}
			string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
			if (string.IsNullOrEmpty(currentSaveFileName))
			{
				return defaultValue;
			}
			return ES3.Load<int>("CompanyLighting_" + upgradeKey, currentSaveFileName, defaultValue);
		}
	}
	public class TerminalCommands
	{
		private static TerminalModRegistry terminalRegistry;

		public static void SetupTerminal(TerminalCommands self)
		{
			terminalRegistry = TerminalRegistry.CreateTerminalRegistry();
			terminalRegistry.RegisterFrom<TerminalCommands>(self);
			Plugin.VinLogger.LogMessage((object)"Terminal integration loaded.");
		}

		[TerminalCommand("upgrades", false)]
		[CommandInfo("Displays available ship and crew upgrades. (CompanyLighting)", "")]
		public TerminalNode OnUpgradesListCommand()
		{
			if (LightingNetworkHandler.Instance == null)
			{
				return CreateNode("The upgrade network is not initialized yet. Please wait a moment.\n");
			}
			if (Upgrades.UpgradeList == null || Upgrades.UpgradeList.Count == 0)
			{
				return CreateNode("No upgrades are currently available.\n");
			}
			string text = "CREW & SHIP UPGRADES\nUse words UPGRADE and INFO on any upgrade.\n(ex. upgrade visorlightrange)\n";
			string text2 = new string('_', 28) + "\n\n";
			string text3 = "";
			foreach (KeyValuePair<string, (string, int, int, string, float)> upgrade in Upgrades.UpgradeList)
			{
				int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel(upgrade.Key);
				int price = Upgrades.GetPrice(upgrade.Key);
				text3 += $"* {upgrade.Value.Item1}   ({upgradeLevel}/{upgrade.Value.Item3})  //  Price: ${price}\n";
			}
			return CreateNode(text + text2 + text3);
		}

		[TerminalCommand("upgrade", false)]
		[CommandInfo("Purchase a desired upgrade. (CompanyLighting)", "")]
		public TerminalNode OnUpgradeEmptyCommand()
		{
			return CreateNode("Please specify an upgrade to purchase. (ex. upgrade visorlightrange)\n");
		}

		[TerminalCommand("upgrade", false)]
		[CommandInfo("Purchase a desired upgrade. (CompanyLighting)", "")]
		public object OnUpgradeArgumentCommand(string argument)
		{
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			if (LightingNetworkHandler.Instance == null)
			{
				return CreateNode("The upgrade network is not initialized yet. Please wait a moment.\n");
			}
			string text = "[There was no object supplied with the action, or your word was typed incorrectly or does not exist.]\n";
			if (string.IsNullOrEmpty(argument))
			{
				return CreateNode(text);
			}
			string upgKey = Upgrades.FindUpgrade(argument);
			if (string.IsNullOrEmpty(upgKey))
			{
				return CreateNode(text);
			}
			int upgradeValue = LightingNetworkHandler.Instance.GetUpgradeLevel(upgKey);
			int item = Upgrades.UpgradeList[upgKey].Item3;
			if (upgradeValue >= item)
			{
				return CreateNode($"You already have this upgraded at max level! ({upgradeValue}/{item})\n");
			}
			Terminal gameTerminal = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)gameTerminal == (Object)null)
			{
				return CreateNode("Error: Could not locate the terminal.\n");
			}
			int upgradePrice = Upgrades.GetPrice(upgKey);
			string item2 = Upgrades.UpgradeList[upgKey].Item4;
			string text2 = new string('_', 28) + "\n";
			string text3 = $"Your current upgrade level for '{Upgrades.UpgradeList[upgKey].Item1}' is {upgradeValue},\n" + $"Total cost to upgrade: ${upgradePrice}\n\n" + "\"" + item2 + "\"\n" + text2;
			TerminalNode val = CreateNode(text3);
			return (object)new ConfirmInteraction(val, (Delegate)(Func<TerminalNode>)delegate
			{
				if (gameTerminal.groupCredits < upgradePrice)
				{
					return CreateNode("You do not have enough credits for this upgrade!\n\n");
				}
				Terminal obj = gameTerminal;
				obj.groupCredits -= upgradePrice;
				gameTerminal.SyncGroupCreditsServerRpc(gameTerminal.groupCredits, gameTerminal.numberOfItemsInDropship);
				Upgrades.ConfirmUpgrade(upgKey);
				return CreateNode($"SUCCESS: Purchased '{Upgrades.UpgradeList[upgKey].Item1}'. New level: {upgradeValue + 1}\n\n");
			}, (Delegate)(Func<TerminalNode>)(() => CreateNode("Cancelled order.\n\n")));
		}

		private static TerminalNode CreateNode(string text)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.clearPreviousText = true;
			val.displayText = text;
			return val;
		}
	}
	public class Upgrades
	{
		private static float PriceMultiplier = 1.45f;

		public static Dictionary<string, (string, int, int, string, float)> UpgradeList = new Dictionary<string, (string, int, int, string, float)>();

		private static string StripUpgrade(string toStrip)
		{
			toStrip = toStrip.ToLower();
			toStrip = toStrip.Replace(" ", "");
			return toStrip;
		}

		public static void SetupUpgrades()
		{
			UpgradeList.Clear();
			UpgradeList.Add("flrange", ("Visor Light Range", 120, 3, "Increase the range of the built-in visor light.", 1.5f));
			UpgradeList.Add("flbrightness", ("Visor Brightness", 100, 3, "Increase brightness of the built-in visor light.", 1.45f));
			UpgradeList.Add("carryamount", ("Backpack", 950, 1, "Grant everyone an extra slot for scrap.", 1f));
			UpgradeList.Add("lightweight", ("Lightweight", 250, 3, "Allow yourself to move like a feather; carry more weight.", 1.8f));
			UpgradeList.Add("magneticgloves", ("Longer Arms", 250, 2, "Increases the distance from which you can interact with and grab objects.", 1.5f));
			UpgradeList.Add("deepscanner", ("Deep Scanner", 150, 3, "Increases your suit scanner's radius and slightly illuminates the area.", 1.35f));
			UpgradeList.Add("doorhydraulics", ("Better Hydraulics", 200, 3, "Increases the duration the ship doors can remain closed before losing power.", 1.4f));
			UpgradeList.Add("acousticdampeners", ("Acoustic Dampeners", 350, 3, "Muffles your suit's joints and footwear, reducing the noise you make when moving.", 1.6f));
		}

		public static int GetPrice(string upgradeKey)
		{
			int result = 106;
			if (string.IsNullOrEmpty(upgradeKey))
			{
				return result;
			}
			if (!UpgradeList.ContainsKey(upgradeKey))
			{
				return result;
			}
			int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel(upgradeKey);
			if (upgradeLevel > 0)
			{
				(string, int, int, string, float) tuple = UpgradeList[upgradeKey];
				return Mathf.RoundToInt((float)tuple.Item2 * Mathf.Pow(tuple.Item5, (float)upgradeLevel));
			}
			return UpgradeList[upgradeKey].Item2;
		}

		public static void ConfirmUpgrade(string upgradeKey)
		{
			if (!string.IsNullOrEmpty(upgradeKey) && UpgradeList.ContainsKey(upgradeKey))
			{
				LightingNetworkHandler.Instance.RequestPurchase(upgradeKey);
			}
		}

		public static string FindUpgrade(string upgradeStripped)
		{
			foreach (KeyValuePair<string, (string, int, int, string, float)> upgrade in UpgradeList)
			{
				if (StripUpgrade(upgrade.Value.Item1) == upgradeStripped)
				{
					return upgrade.Key;
				}
			}
			return "";
		}
	}
}
namespace CompanyLighting.UpgradeLogic
{
	internal static class InventoryHUDPatch
	{
		private static GameObject extraFrameObj;

		private static GameObject extraIconObj;

		private const float SlotSpacing = 62f;

		public static void SetSlotCount(HUDManager hud, int count)
		{
			if (count <= 4)
			{
				RemoveExtraSlot(hud);
			}
			else if (!((Object)(object)extraFrameObj != (Object)null))
			{
				AddExtraSlot(hud);
			}
		}

		private static void AddExtraSlot(HUDManager hud)
		{
			//IL_0064: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			Image val = hud.itemSlotIconFrames[hud.itemSlotIconFrames.Length - 1];
			Image value = hud.itemSlotIcons[hud.itemSlotIcons.Length - 1];
			Image[] componentsInChildren = ((Component)val).GetComponentsInChildren<Image>(true);
			int num = Array.IndexOf(componentsInChildren, value);
			extraFrameObj = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
			RectTransform component = extraFrameObj.GetComponent<RectTransform>();
			component.anchoredPosition = ((Component)val).GetComponent<RectTransform>().anchoredPosition + new Vector2(62f, 0f);
			Image[] componentsInChildren2 = extraFrameObj.GetComponentsInChildren<Image>(true);
			Image val2 = ((num >= 0) ? componentsInChildren2[num] : componentsInChildren2[^1]);
			((Behaviour)val2).enabled = false;
			extraIconObj = ((Component)val2).gameObject;
			hud.itemSlotIconFrames = hud.itemSlotIconFrames.Append(extraFrameObj.GetComponent<Image>()).ToArray();
			hud.itemSlotIcons = hud.itemSlotIcons.Append(val2).ToArray();
		}

		private static void RemoveExtraSlot(HUDManager hud)
		{
			if (!((Object)(object)extraFrameObj == (Object)null))
			{
				Image frameImg = extraFrameObj.GetComponent<Image>();
				Image iconImg = extraIconObj.GetComponent<Image>();
				hud.itemSlotIconFrames = hud.itemSlotIconFrames.Where((Image i) => (Object)(object)i != (Object)(object)frameImg).ToArray();
				hud.itemSlotIcons = hud.itemSlotIcons.Where((Image i) => (Object)(object)i != (Object)(object)iconImg).ToArray();
				Object.Destroy((Object)(object)extraFrameObj);
				extraFrameObj = null;
				extraIconObj = null;
			}
		}
	}
	internal class Backpack
	{
		public static void ApplyInventorySize(PlayerControllerB player, bool hasUpgrade)
		{
			int num = (hasUpgrade ? 5 : 4);
			if (player.ItemSlots.Length != num)
			{
				if (hasUpgrade || player.ItemSlots.Length <= 4 || (Object)(object)player.ItemSlots[4] != (Object)null)
				{
				}
				GrabbableObject[] array = (GrabbableObject[])(object)new GrabbableObject[num];
				for (int i = 0; i < Mathf.Min(player.ItemSlots.Length, num); i++)
				{
					array[i] = player.ItemSlots[i];
				}
				player.ItemSlots = array;
				if (((NetworkBehaviour)player).IsOwner)
				{
					InventoryHUDPatch.SetSlotCount(HUDManager.Instance, num);
				}
			}
		}
	}
	public static class Overcharger
	{
		private const float FrontDir = -1f;

		public static GameObject Instance { get; private set; }

		public static Transform GaugeNeedle { get; private set; }

		public static Transform BreakerLever { get; private set; }

		public static Light FlickerLight { get; private set; }

		public static Renderer CopperGlowRenderer { get; private set; }

		public static GameObject Spawn(GameObject customPrefab = null, float wallOffset = 0f)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			ItemCharger val = Object.FindObjectOfType<ItemCharger>();
			if ((Object)(object)val == (Object)null)
			{
				Plugin.VinLogger.LogError((object)"Could not find ItemCharger on ship!");
				return null;
			}
			Vector3 val2 = -((Component)val).transform.forward * wallOffset;
			if ((Object)(object)Instance != (Object)null)
			{
				Instance.transform.position = ((Component)val).transform.position + val2;
				Instance.transform.rotation = ((Component)val).transform.rotation;
				Instance.transform.SetParent(((Component)val).transform.parent, true);
				Plugin.VinLogger.LogMessage((object)"Overcharger Instance already exists, returning existing.");
				return Instance;
			}
			if ((Object)(object)customPrefab != (Object)null)
			{
				Plugin.VinLogger.LogMessage((object)"Custom Overcharger Prefab exists, instantiating.");
				Instance = Object.Instantiate<GameObject>(customPrefab);
			}
			else
			{
				Plugin.VinLogger.LogMessage((object)"Custom Overcharger Prefab does not exist, building high-detail scrap-rig model.");
				Instance = BuildScrapRigModel(val);
			}
			((Object)Instance).name = "CompanyLightingOverchargerUnit";
			Instance.transform.position = ((Component)val).transform.position + val2;
			Instance.transform.rotation = ((Component)val).transform.rotation;
			Instance.transform.SetParent(((Component)val).transform.parent, true);
			return Instance;
		}

		private static GameObject BuildScrapRigModel(ItemCharger standardCharger)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_00af: 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_00e7: 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_0108: Expected O, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Expected O, but got Unknown
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Expected O, but got Unknown
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0744: Unknown result type (might be due to invalid IL or missing references)
			//IL_0761: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0820: Unknown result type (might be due to invalid IL or missing references)
			//IL_0839: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_0864: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_089f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d1: Expected O, but got Unknown
			//IL_08fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_0967: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0d: Expected O, but got Unknown
			//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5b: Expected O, but got Unknown
			//IL_0c86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eaa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ecb: Expected O, but got Unknown
			//IL_0f35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd9: Expected O, but got Unknown
			//IL_1003: Unknown result type (might be due to invalid IL or missing references)
			//IL_104e: Unknown result type (might be due to invalid IL or missing references)
			//IL_106b: Unknown result type (might be due to invalid IL or missing references)
			//IL_10cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_110f: Unknown result type (might be due to invalid IL or missing references)
			//IL_112c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1140: Unknown result type (might be due to invalid IL or missing references)
			//IL_114a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1177: Unknown result type (might be due to invalid IL or missing references)
			//IL_117e: Expected O, but got Unknown
			//IL_11a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_1215: Unknown result type (might be due to invalid IL or missing references)
			//IL_1236: Unknown result type (might be due to invalid IL or missing references)
			//IL_1253: Unknown result type (might be due to invalid IL or missing references)
			//IL_12a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_12c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_12e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_133b: Unknown result type (might be due to invalid IL or missing references)
			//IL_135c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1379: Unknown result type (might be due to invalid IL or missing references)
			//IL_13a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_13a7: Expected O, but got Unknown
			//IL_13ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_13f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1406: Unknown result type (might be due to invalid IL or missing references)
			//IL_140d: Expected O, but got Unknown
			//IL_1437: Unknown result type (might be due to invalid IL or missing references)
			//IL_1458: Unknown result type (might be due to invalid IL or missing references)
			//IL_14a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_14c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1515: Unknown result type (might be due to invalid IL or missing references)
			//IL_1536: Unknown result type (might be due to invalid IL or missing references)
			//IL_1553: Unknown result type (might be due to invalid IL or missing references)
			//IL_15b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_15d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_15f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1613: Unknown result type (might be due to invalid IL or missing references)
			//IL_166b: Unknown result type (might be due to invalid IL or missing references)
			//IL_168c: Unknown result type (might be due to invalid IL or missing references)
			//IL_16a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_16db: Unknown result type (might be due to invalid IL or missing references)
			//IL_16e2: Expected O, but got Unknown
			//IL_170d: Unknown result type (might be due to invalid IL or missing references)
			//IL_173b: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_17d9: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OverchargerRoot");
			Material sourceMat = null;
			Renderer val2 = default(Renderer);
			if (((Component)standardCharger).TryGetComponent<Renderer>(ref val2) && (Object)(object)val2.material != (Object)null)
			{
				sourceMat = val2.material;
			}
			Random random = new Random(12345);
			GameObject val3 = new GameObject("BackplateAssembly");
			val3.transform.SetParent(val.transform, false);
			float num = 0.75f;
			float num2 = 0.85f;
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val4).name = "HazardSignBase";
			val4.transform.SetParent(val3.transform, false);
			val4.transform.localPosition = new Vector3(-0.015f, 0f, 0f);
			val4.transform.localScale = new Vector3(0.01f, num2, num);
			ApplyColor(val4, sourceMat, new Color(0.12f, 0.11f, 0.1f), 0.8f);
			GameObject val5 = new GameObject("HazardStripes");
			val5.transform.SetParent(val3.transform, false);
			int num3 = 10;
			for (int i = 0; i < num3; i++)
			{
				GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val6).name = $"Stripe_{i}";
				val6.transform.SetParent(val5.transform, false);
				float num4 = Mathf.Lerp((0f - num2) * 0.45f, num2 * 0.45f, (float)i / (float)(num3 - 1));
				val6.transform.localPosition = new Vector3(-0.012f, num4, 0f);
				val6.transform.localRotation = Quaternion.Euler(35f, 0f, 0f);
				val6.transform.localScale = new Vector3(0.002f, 0.05f, num * 1.2f);
				Color color = ((i % 2 == 0) ? new Color(0.85f, 0.6f, 0.05f) : new Color(0.08f, 0.08f, 0.08f));
				ApplyColor(val6, sourceMat, color, 0.1f, 0.3f);
			}
			int num5 = 9;
			for (int j = 0; j < num5; j++)
			{
				GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val7).name = $"CorrugatedStrip_{j}";
				val7.transform.SetParent(val3.transform, false);
				float num6 = Mathf.Lerp((0f - num) / 2f, num / 2f, (float)j / (float)(num5 - 1));
				float num7 = (float)(random.NextDouble() - 0.5) * 0.015f;
				float num8 = (float)(random.NextDouble() - 0.5) * 0.06f;
				val7.transform.localPosition = new Vector3(-0.008f + num7, 0f, num6);
				val7.transform.localRotation = Quaternion.Euler((float)(random.NextDouble() - 0.5) * 3f, (float)(random.NextDouble() - 0.5) * 2f, 0f);
				val7.transform.localScale = new Vector3(0.012f, num2 + num8, num / (float)num5 * 1.2f);
				ApplyColor(val7, sourceMat, RustColor(random), 0.6f, 0.15f);
			}
			Vector3[] array = (Vector3[])(object)new Vector3[6]
			{
				new Vector3(0f, num2 * 0.44f, num * 0.44f),
				new Vector3(0f, num2 * 0.42f, (0f - num) * 0.42f),
				new Vector3(0f, (0f - num2) * 0.45f, num * 0.4f),
				new Vector3(0f, (0f - num2) * 0.43f, (0f - num) * 0.45f),
				new Vector3(0f, 0.1f, (0f - num) * 0.2f),
				new Vector3(0f, -0.15f, num * 0.25f)
			};
			Vector3[] array2 = array;
			foreach (Vector3 val8 in array2)
			{
				GameObject val9 = GameObject.CreatePrimitive((PrimitiveType)2);
				((Object)val9).name = "BoltWasher";
				val9.transform.SetParent(val3.transform, false);
				val9.transform.localPosition = val8 + new Vector3(0.002f, 0f, 0f);
				val9.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
				val9.transform.localScale = new Vector3(0.06f, 0.004f, 0.06f);
				ApplyColor(val9, sourceMat, new Color(0.2f, 0.18f, 0.16f), 0.9f, 0.1f);
				GameObject val10 = GameObject.CreatePrimitive((PrimitiveType)2);
				((Object)val10).name = "HexBolt";
				val10.transform.SetParent(val3.transform, false);
				val10.transform.localPosition = val8 + new Vector3(0.012f, 0f, 0f);
				val10.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
				float num9 = 0.038f + (float)random.NextDouble() * 0.015f;
				val10.transform.localScale = new Vector3(num9, 0.018f, num9);
				ApplyColor(val10, sourceMat, new Color(0.35f, 0.33f, 0.3f), 0.85f, 0.3f);
			}
			GameObject val11 = new GameObject("CablesAssembly");
			val11.transform.SetParent(val.transform, false);
			BuildDetailedConduit(val11, sourceMat, random, new Vector3(-0.02f, num2 * 0.52f, 0.18f), new Vector3(-0.06f, 0.18f, 0.09f), new Vector3(-0.05f, 0.01f, 0.02f));
			BuildDetailedConduit(val11, sourceMat, random, new Vector3(-0.02f, num2 * 0.52f, -0.22f), new Vector3(-0.07f, 0.22f, -0.07f), new Vector3(-0.05f, -0.01f, -0.01f));
			GameObject val12 = new GameObject("ExposedCopperKnot");
			val12.transform.SetParent(val.transform, false);
			val12.transform.localPosition = new Vector3(-0.05f, 0f, 0f);
			GameObject val13 = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val13).name = "CopperCore";
			val13.transform.SetParent(val12.transform, false);
			val13.transform.localScale = new Vector3(0.08f, 0.06f, 0.08f);
			ApplyEmissiveColor(val13, sourceMat, new Color(0.7f, 0.38f, 0.12f), new Color(1f, 0.5f, 0.1f) * 4f, 0.9f);
			CopperGlowRenderer = val13.GetComponent<Renderer>();
			int num10 = 8;
			for (int l = 0; l < num10; l++)
			{
				GameObject val14 = GameObject.CreatePrimitive((PrimitiveType)2);
				((Object)val14).name = $"CopperStrand_{l}";
				val14.transform.SetParent(val12.transform, false);
				float num11 = (float)(random.NextDouble() - 0.5) * 160f;
				float num12 = (float)(random.NextDouble() - 0.5) * 160f;
				val14.transform.localRotation = Quaternion.Euler(num11, num12, 0f);
				val14.transform.localPosition = val14.transform.forward * 0.035f;
				val14.transform.localScale = new Vector3(0.006f, 0.025f, 0.006f);
				ApplyEmissiveColor(val14, sourceMat, new Color(0.75f, 0.4f, 0.12f), new Color(1f, 0.55f, 0.15f) * 2.5f, 0.95f);
			}
			GameObject val15 = new GameObject("GaugeAssembly");
			val15.transform.SetParent(val.transform, false);
			val15.transform.localPosition = new Vector3(-0.035f, 0.24f, 0f);
			GameObject val16 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val16).name = "GaugeBezel";
			val16.transform.SetParent(val15.transform, false);
			val16.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			val16.transform.localScale = new Vector3(0.2f, 0.02f, 0.2f);
			ApplyColor(val16, sourceMat, new Color(0.2f, 0.18f, 0.15f), 0.9f);
			GameObject val17 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val17).name = "GaugeHousing";
			val17.transform.SetParent(val15.transform, false);
			val17.transform.localPosition = new Vector3(-0.015f, 0f, 0f);
			val17.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			val17.transform.localScale = new Vector3(0.18f, 0.05f, 0.18f);
			ApplyColor(val17, sourceMat, new Color(0.32f, 0.28f, 0.18f), 0.7f, 0.3f);
			GameObject val18 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val18).name = "GaugeDialFace";
			val18.transform.SetParent(val15.transform, false);
			val18.transform.localPosition = new Vector3(-0.042f, 0f, 0f);
			val18.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			val18.transform.localScale = new Vector3(0.16f, 0.002f, 0.16f);
			ApplyColor(val18, sourceMat, new Color(0.85f, 0.82f, 0.75f), 0f, 0.1f);
			GameObject val19 = new GameObject("MarkerSafeZone");
			val19.transform.SetParent(val15.transform, false);
			int num13 = 10;
			float num14 = -35f;
			float num15 = 45f;
			for (int m = 0; m < num13; m++)
			{
				float num16 = (float)m / (float)(num13 - 1);
				float num17 = Mathf.Lerp(num14, num15, num16);
				float num18 = num17 * (MathF.PI / 180f);
				GameObject val20 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val20).name = "MarkerStroke";
				val20.transform.SetParent(val19.transform, false);
				val20.transform.localPosition = new Vector3(-0.045f, Mathf.Sin(num18) * 0.065f, Mathf.Cos(num18) * 0.065f);
				val20.transform.localRotation = Quaternion.Euler(num17, 0f, 0f);
				val20.transform.localScale = new Vector3(0.003f, 0.018f, 0.022f);
				ApplyEmissiveColor(val20, sourceMat, new Color(0.05f, 0.95f, 0.1f), new Color(0.1f, 1f, 0.15f) * 2f, 0f);
			}
			GameObject val21 = new GameObject("NeedlePivot");
			val21.transform.SetParent(val15.transform, false);
			val21.transform.localPosition = new Vector3(-0.047f, 0f, 0f);
			val21.transform.localRotation = Quaternion.Euler(-15f, 0f, 0f);
			GameObject val22 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val22).name = "NeedleHub";
			val22.transform.SetParent(val21.transform, false);
			val22.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			val22.transform.localScale = new Vector3(0.022f, 0.005f, 0.022f);
			ApplyColor(val22, sourceMat, new Color(0.1f, 0.1f, 0.1f), 0.8f, 0.5f);
			GameObject val23 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val23).name = "NeedleArm";
			val23.transform.SetParent(val21.transform, false);
			val23.transform.localPosition = new Vector3(0f, 0.04f, 0f);
			val23.transform.localRotation = Quaternion.Euler(0f, 0f, 4f);
			val23.transform.localScale = new Vector3(0.003f, 0.075f, 0.006f);
			ApplyColor(val23, sourceMat, new Color(0.75f, 0.1f, 0.05f), 0.2f, 0.4f);
			GaugeNeedle = val21.transform;
			GameObject val24 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val24).name = "GaugeGlassLens";
			val24.transform.SetParent(val15.transform, false);
			val24.transform.localPosition = new Vector3(-0.052f, 0f, 0f);
			val24.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
			val24.transform.localScale = new Vector3(0.17f, 0.002f, 0.17f);
			ApplyColor(val24, sourceMat, new Color(0.8f, 0.85f, 0.85f, 0.4f), 0.1f, 0.95f);
			GameObject val25 = new GameObject("GlassCracks");
			val25.transform.SetParent(val15.transform, false);
			for (int n = 0; n < 3; n++)
			{
				GameObject val26 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val26).name = $"GlassCrack_{n}";
				val26.transform.SetParent(val25.transform, false);
				val26.transform.localPosition = new Vector3(-0.054f, 0.02f, -0.01f);
				val26.transform.localRotation = Quaternion.Euler((float)n * 40f + 15f, 0f, 0f);
				val26.transform.localScale = new Vector3(0.002f, 0.09f, 0.002f);
				ApplyColor(val26, sourceMat, new Color(1f, 1f, 1f, 0.6f), 0f, 1f);
			}
			GameObject val27 = new GameObject("BreakerSwitchAssembly");
			val27.transform.SetParent(val.transform, false);
			val27.transform.localPosition = new Vector3(-0.035f, -0.06f, 0f);
			GameObject val28 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val28).name = "BreakerMountBox";
			val28.transform.SetParent(val27.transform, false);
			val28.transform.localScale = new Vector3(0.065f, 0.1f, 0.12f);
			ApplyColor(val28, sourceMat, new Color(0.18f, 0.18f, 0.18f), 0.8f);
			for (int num19 = -1; num19 <= 1; num19 += 2)
			{
				GameObject val29 = GameObject.CreatePrimitive((PrimitiveType)2);
				((Object)val29).name = "ContactTerminal";
				val29.transform.SetParent(val27.transform, false);
				val29.transform.localPosition = new Vector3(-0.035f, 0.035f, (float)num19 * 0.035f);
				val29.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
				val29.transform.localScale = new Vector3(0.02f, 0.015f, 0.02f);
				ApplyEmissiveColor(val29, sourceMat, new Color(0.6f, 0.35f, 0.1f), new Color(0.9f, 0.45f, 0.1f) * 1.5f, 0.9f);
			}
			GameObject val30 = new GameObject("LeverPivot");
			val30.transform.SetParent(val27.transform, false);
			val30.transform.localPosition = new Vector3(-0.035f, 0.02f, 0f);
			val30.transform.localRotation = Quaternion.Euler(0f, 0f, -55f);
			GameObject val31 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val31).name = "PivotPin";
			val31.transform.SetParent(val30.transform, false);
			val31.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
			val31.transform.localScale = new Vector3(0.02f, 0.05f, 0.02f);
			ApplyColor(val31, sourceMat, new Color(0.4f, 0.38f, 0.35f), 0.85f, 0.3f);
			GameObject val32 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val32).name = "LeverArm";
			val32.transform.SetParent(val30.transform, false);
			val32.transform.localPosition = new Vector3(0f, 0.06f, 0f);
			val32.transform.localScale = new Vector3(0.016f, 0.07f, 0.016f);
			ApplyColor(val32, sourceMat, new Color(0.55f, 0.08f, 0.08f), 0.5f, 0.3f);
			GameObject val33 = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val33).name = "BakeliteHandleGrip";
			val33.transform.SetParent(val30.transform, false);
			val33.transform.localPosition = new Vector3(0f, 0.13f, 0f);
			val33.transform.localScale = new Vector3(0.038f, 0.045f, 0.038f);
			ApplyColor(val33, sourceMat, new Color(0.08f, 0.08f, 0.08f), 0.1f, 0.6f);
			BreakerLever = val30.transform;
			GameObject val34 = new GameObject("JumperClampsAssembly");
			val34.transform.SetParent(val.transform, false);
			BuildHighDetailClamp(val34, sourceMat, random, new Vector3(-0.08f, -0.16f, 0.14f), 18f);
			BuildHighDetailClamp(val34, sourceMat, random, new Vector3(-0.08f, -0.16f, -0.16f), -14f);
			GameObject val35 = new GameObject("ItemShelfAssembly");
			val35.transform.SetParent(val.transform, false);
			val35.transform.localPosition = new Vector3(-0.085f, -0.3f, 0f);
			val35.transform.localRotation = Quaternion.Euler(0f, 0f, -7f);
			GameObject val36 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val36).name = "ShelfPlate";
			val36.transform.SetParent(val35.transform, false);
			val36.transform.localScale = new Vector3(0.2f, 0.018f, 0.28f);
			ApplyColor(val36, sourceMat, new Color(0.2f, 0.18f, 0.16f), 0.7f);
			GameObject val37 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val37).name = "ShelfFrontLip";
			val37.transform.SetParent(val35.transform, false);
			val37.transform.localPosition = new Vector3(-0.095f, 0.012f, 0f);
			val37.transform.localScale = new Vector3(0.01f, 0.025f, 0.28f);
			ApplyColor(val37, sourceMat, new Color(0.18f, 0.16f, 0.14f), 0.7f);
			for (int num20 = -1; num20 <= 1; num20 += 2)
			{
				GameObject val38 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val38).name = "ShelfSupportStrut";
				val38.transform.SetParent(val.transform, false);
				val38.transform.localPosition = new Vector3(-0.045f, -0.36f, (float)num20 * 0.09f);
				val38.transform.localRotation = Quaternion.Euler(0f, 0f, 38f);
				val38.transform.localScale = new Vector3(0.016f, 0.16f, 0.016f);
				ApplyColor(val38, sourceMat, new Color(0.25f, 0.22f, 0.2f), 0.8f, 0.15f);
				GameObject val39 = GameObject.CreatePrimitive((PrimitiveType)0);
				((Object)val39).name = "WeldJoint";
				val39.transform.SetParent(val.transform, false);
				val39.transform.localPosition = new Vector3(-0.005f, -0.41f, (float)num20 * 0.09f);
				val39.transform.localScale = new Vector3(0.025f, 0.025f, 0.025f);
				ApplyColor(val39, sourceMat, new Color(0.15f, 0.14f, 0.13f), 0.9f, 0.1f);
			}
			GameObject val40 = new GameObject("GaugeEmberLight");
			val40.transform.SetParent(val15.transform, false);
			val40.transform.localPosition = new Vector3(-0.04f, 0f, 0f);
			Light val41 = val40.AddComponent<Light>();
			val41.type = (LightType)2;
			val41.color = new Color(1f, 0.5f, 0.15f);
			val41.intensity = 2.2f;
			val41.range = 1.5f;
			val41.shadows = (LightShadows)0;
			FlickerLight = val41;
			Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>();
			foreach (Collider val42 in componentsInChildren)
			{
				Object.Destroy((Object)(object)val42);
			}
			BoxCollider val43 = val.AddComponent<BoxCollider>();
			val43.center = new Vector3(-0.05f, -0.05f, 0f);
			val43.size = new Vector3(0.24f, num2 + 0.1f, num + 0.1f);
			return val;
		}

		private static void BuildDetailedConduit(GameObject parent, Material sourceMat, Random rng, Vector3 start, Vector3 mid, Vector3 end)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0061: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PowerConduit");
			val.transform.SetParent(parent.transform, false);
			int num = 4;
			Vector3 val2 = start;
			for (int i = 1; i <= num; i++)
			{
				float num2 = (float)i / (float)num;
				Vector3 val3 = Mathf.Pow(1f - num2, 2f) * start + 2f * (1f - num2) * num2 * mid + Mathf.Pow(num2, 2f) * end;
				AddCableSegment(val, sourceMat, val2, val3);
				val2 = val3;
			}
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val4).name = "YellowTapeWrap";
			val4.transform.SetParent(val.transform, false);
			val4.transform.localPosition = mid;
			val4.transform.localScale = new Vector3(0.026f, 0.035f, 0.026f);
			ApplyColor(val4, sourceMat, new Color(0.65f, 0.58f, 0.08f), 0.05f, 0.3f);
		}

		private static void AddCableSegment(GameObject parent, Material sourceMat, Vector3 from, Vector3 to)
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_008a: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val).name = "ConduitSegment";
			val.transform.SetParent(parent.transform, false);
			Vector3 localPosition = (from + to) / 2f;
			float num = Vector3.Distance(from, to);
			val.transform.localPosition = localPosition;
			Transform transform = val.transform;
			Vector3 up = Vector3.up;
			Vector3 val2 = to - from;
			transform.localRotation = Quaternion.FromToRotation(up, ((Vector3)(ref val2)).normalized);
			val.transform.localScale = new Vector3(0.02f, num / 2f, 0.02f);
			ApplyColor(val, sourceMat, new Color(0.09f, 0.09f, 0.09f));
		}

		private static void BuildHighDetailClamp(GameObject parent, Material sourceMat, Random rng, Vector3 localPos, float hangAngle)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0025: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("AlligatorClamp");
			val.transform.SetParent(parent.transform, false);
			val.transform.localPosition = localPos;
			val.transform.localRotation = Quaternion.Euler(0f, 0f, hangAngle);
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val2).name = "ClampCable";
			val2.transform.SetParent(val.transform, false);
			val2.transform.localPosition = new Vector3(0f, 0.09f, 0f);
			val2.transform.localScale = new Vector3(0.016f, 0.08f, 0.016f);
			ApplyColor(val2, sourceMat, new Color(0.1f, 0.1f, 0.1f));
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val3).name = "InsulatedGrip";
			val3.transform.SetParent(val.transform, false);
			val3.transform.localPosition = new Vector3(0f, 0.03f, 0f);
			val3.transform.localScale = new Vector3(0.028f, 0.035f, 0.028f);
			ApplyColor(val3, sourceMat, new Color(0.55f, 0.12f, 0.1f), 0.05f, 0.4f);
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val4).name = "SpringHinge";
			val4.transform.SetParent(val.transform, false);
			val4.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
			val4.transform.localScale = new Vector3(0.022f, 0.02f, 0.022f);
			ApplyColor(val4, sourceMat, new Color(0.4f, 0.35f, 0.3f), 0.85f, 0.3f);
			for (int i = -1; i <= 1; i += 2)
			{
				GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val5).name = ((i == -1) ? "JawTop" : "JawBottom");
				val5.transform.SetParent(val.transform, false);
				val5.transform.localPosition = new Vector3(0f, -0.03f, (float)i * 0.008f);
				val5.transform.localRotation = Quaternion.Euler((float)(-i) * 10f, 0f, 0f);
				val5.transform.localScale = new Vector3(0.026f, 0.055f, 0.007f);
				ApplyColor(val5, sourceMat, new Color(0.25f, 0.22f, 0.18f), 0.8f);
				for (int j = 0; j < 4; j++)
				{
					GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)3);
					((Object)val6).name = "JawTooth";
					val6.transform.SetParent(val5.transform, false);
					val6.transform.localPosition = new Vector3(((float)j - 1.5f) * 0.2f, -0.4f, (float)(-i) * 0.4f);
					val6.transform.localScale = new Vector3(0.15f, 0.15f, 0.3f);
					ApplyColor(val6, sourceMat, new Color(0.4f, 0.38f, 0.35f), 0.9f, 0.3f);
				}
			}
			GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val7).name = "ScorchMark";
			val7.transform.SetParent(val.transform, false);
			val7.transform.localPosition = new Vector3(0f, -0.058f, 0f);
			val7.transform.localScale = new Vector3(0.032f, 0.012f, 0.032f);
			ApplyColor(val7, sourceMat, new Color(0.02f, 0.02f, 0.02f), 0f, 0.05f);
		}

		private static Color RustColor(Random rng)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.28f + (float)rng.NextDouble() * 0.22f;
			float num2 = 0.14f + (float)rng.NextDouble() * 0.12f;
			float num3 = 0.07f + (float)rng.NextDouble() * 0.08f;
			return new Color(num, num2, num3);
		}

		private static void ApplyColor(GameObject obj, Material sourceMat, Color color, float metallic = 0.1f, float smoothness = 0.2f)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			Renderer val = default(Renderer);
			if (!obj.TryGetComponent<Renderer>(ref val))
			{
				return;
			}
			if ((Object)(object)sourceMat != (Object)null)
			{
				val.material = new Material(sourceMat);
			}
			else
			{
				Shader val2 = Shader.Find("HDRP/Lit");
				if ((Object)(object)val2 != (Object)null)
				{
					val.material.shader = val2;
				}
			}
			if (val.material.HasProperty("_BaseColor"))
			{
				val.material.SetColor("_BaseColor", color);
			}
			else
			{
				val.material.color = color;
			}
			if (val.material.HasProperty("_Metallic"))
			{
				val.material.SetFloat("_Metallic", metallic);
			}
			if (val.material.HasProperty("_Smoothness"))
			{
				val.material.SetFloat("_Smoothness", smoothness);
			}
		}

		private static void ApplyEmissiveColor(GameObject obj, Material sourceMat, Color baseColor, Color emissionColor, float metallic = 0.5f)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			ApplyColor(obj, sourceMat, baseColor, metallic, 0.5f);
			Renderer val = default(Renderer);
			if (obj.TryGetComponent<Renderer>(ref val))
			{
				if (val.material.HasProperty("_EmissiveColor"))
				{
					val.material.SetColor("_EmissiveColor", emissionColor);
					val.material.SetColor("_EmissiveColorLDR", emissionColor);
					val.material.EnableKeyword("_EMISSION");
					val.material.SetFloat("_UseEmissiveIntensity", 1f);
					val.material.SetFloat("_EmissiveIntensity", 2f);
				}
				else if (val.material.HasProperty("_EmissionColor"))
				{
					val.material.SetColor("_EmissionColor", emissionColor);
					val.material.EnableKeyword("_EMISSION");
				}
			}
		}

		public static void SetActive(bool isActive)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Instance.SetActive(isActive);
			}
			else
			{
				Plugin.VinLogger.LogWarning((object)"Trying to SetActive but Instance is null!");
			}
		}

		public static void Despawn()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)Instance);
				Instance = null;
			}
		}
	}
}
namespace CompanyLighting.UpgradeLogic.RadarPing
{
	public static class RadarPingConfig
	{
		public const string UpgradeId = "radarping";

		public const int MaxUpgradeLevel = 1;

		public const int CreditCost = 450;

		public const float LoadDurationSeconds = 3.5f;

		public const float CooldownSeconds = 20f;

		public const int PulseCount = 2;

		public const float BaseCorruptionChance = 0.05f;

		public const float EnemyProximityRadius = 15f;

		public const float EnemyCorruptionChance = 0.65f;

		public const float MaxSignalRange = 120f;

		public const float FalloffCorruptionWeight = 0.5f;
	}
	public static class RadarPingCorruption
	{
		public static bool RollCorruption(out float signalStrength)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			signalStrength = 1f;
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Vector3 val2 = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.elevatorTransform.position : Vector3.zero);
			float num = Vector3.Distance(((Component)val).transform.position, val2);
			float num2 = Mathf.Clamp01(num / 120f);
			signalStrength = 1f - num2;
			float num3 = 0.05f + num2 * 0.5f;
			if (IsDangerousEnemyNearby(((Component)val).transform.position))
			{
				num3 = Mathf.Max(num3, 0.65f);
			}
			return Random.value < Mathf.Clamp01(num3);
		}

		private static bool IsDangerousEnemyNearby(Vector3 position)
		{
			//IL_0088: 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)(object)RoundManager.Instance == (Object)null || RoundManager.Instance.SpawnedEnemies == null)
			{
				return false;
			}
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if ((Object)(object)spawnedEnemy == (Object)null || spawnedEnemy.isEnemyDead || (!(spawnedEnemy is SpringManAI) && !(spawnedEnemy is FlowerSnakeEnemy)) || !(Vector3.Distance(((Component)spawnedEnemy).transform.position, position) <= 15f))
				{
					continue;
				}
				return true;
			}
			return false;
		}
	}
	public class RadarPingManager
	{
		private double _nextAvailableServerTime;

		private bool _localAwaitingResult;

		private LNetworkEvent _requestRadarPingEvent;

		private LNetworkEvent _denyRadarPingEvent;

		private LNetworkEvent _triggerRadarScanEvent;

		public static RadarPingManager Instance { get; private set; }

		public static void Initialize()
		{
			if (Instance == null)
			{
				Instance = new RadarPingManager();
				Instance.SetupNetworking();
			}
		}

		private void SetupNetworking()
		{
			_requestRadarPingEvent = LNetworkEvent.Connect("CompanyLighting_RequestRadarPing", (Action<ulong>)null, (Action)null, (Action<ulong>)null);
			_denyRadarPingEvent = LNetworkEvent.Connect("CompanyLighting_DenyRadarPing", (Action<ulong>)null, (Action)null, (Action<ulong>)null);
			_triggerRadarScanEvent = LNetworkEvent.Connect("CompanyLighting_TriggerRadarScan", (Action<ulong>)null, (Action)null, (Action<ulong>)null);
			_requestRadarPingEvent.OnServerReceived += OnRequestRadarPingReceived;
			_denyRadarPingEvent.OnClientReceived += OnDenyRadarPingReceived;
			_triggerRadarScanEvent.OnClientReceived += OnTriggerRadarScanReceived;
			LNetworkUtils.OnNetworkStart += OnNetworkStart;
		}

		private void OnNetworkStart(bool isHostOrServer)
		{
			_nextAvailableServerTime = 0.0;
			_localAwaitingResult = false;
		}

		public TerminalNode TryStartRadarPing()
		{
			if (_localAwaitingResult)
			{
				return BuildNode("Radar array is still processing the last scan.");
			}
			_localAwaitingResult = true;
			_requestRadarPingEvent.InvokeServer();
			return BuildNode("Pinging all active signals...");
		}

		private void OnRequestRadarPingReceived(ulong senderClientId)
		{
			double realtimeSinceStartupAsDouble = Time.realtimeSinceStartupAsDouble;
			if (realtimeSinceStartupAsDouble < _nextAvailableServerTime)
			{
				_denyRadarPingEvent.InvokeClient(senderClientId);
				return;
			}
			_nextAvailableServerTime = realtimeSinceStartupAsDouble + 3.5 + 20.0;
			_triggerRadarScanEvent.InvokeClients();
		}

		private void OnDenyRadarPingReceived()
		{
			_localAwaitingResult = false;
			if ((Object)(object)RadarPingUI.Instance != (Object)null)
			{
				RadarPingUI.Instance.ShowMessage("Radar array recharging.");
			}
		}

		private void OnTriggerRadarScanReceived()
		{
			_localAwaitingResult = false;
			if ((Object)(object)RadarPingUI.Instance != (Object)null)
			{
				Plugin.VinLogger.LogMessage((object)"SCAN UI EXISTS");
				RadarPingUI.Instance.PlayScanSequence();
			}
		}

		private static TerminalNode BuildNode(string text)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.displayText = text + "\n\n";
			val.clearPreviousText = true;
			return val;
		}
	}
	[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
	internal static class RadarPingTerminalPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(Terminal __instance, ref TerminalNode __result)
		{
			int num = ((LightingNetworkHandler.Instance != null) ? LightingNetworkHandler.Instance.GetUpgradeLevel("radarping") : 0);
			if (num <= 0)
			{
				return true;
			}
			string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
			Plugin.VinLogger.LogMessage((object)text);
			string text2 = text?.Trim();
			if (string.IsNullOrEmpty(text2) || !text2.Equals("ping", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (RadarPingManager.Instance != null)
			{
				RadarPingManager.Instance.TryStartRadarPing();
				__result = BuildNode("Pinging available suits...");
			}
			else
			{
				__result = BuildNode("Radar array offline.");
			}
			return false;
		}

		private static TerminalNode BuildNode(string text)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.displayText = text + "\n\n";
			val.clearPreviousText = true;
			return val;
		}
	}
	public class RadarPingUI : MonoBehaviour
	{
		[Header("Pulse (top-right corner)")]
		[SerializeField]
		private RectTransform pulseCircleTransform;

		[SerializeField]
		private Image pulseCircleImage;

		[SerializeField]
		private float pulseGrowScale = 6f;

		[SerializeField]
		private float pulseDuration = 3.6f;

		[Header("Map Reveal")]
		[SerializeField]
		private CanvasGroup mapPanelGroup;

		[SerializeField]
		private RawImage mapImage;

		[SerializeField]
		private GameObject corruptionStaticOverlay;

		[SerializeField]
		private float mapFadeInTime = 1.4f;

		[SerializeField]
		private float mapFadeOutTime = 3.6f;

		private Coroutine _activeSequence;

		public static RadarPingUI Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			if ((Object)(object)mapPanelGroup != (Object)null)
			{
				mapPanelGroup.alpha = 0f;
			}
			if ((Object)(object)pulseCircleImage != (Object)null)
			{
				SetAlpha(pulseCircleImage, 0f);
			}
		}

		public void PlayScanSequence()
		{
			if (_activeSequence != null)
			{
				((MonoBehaviour)this).StopCoroutine(_activeSequence);
			}
			_activeSequence = ((MonoBehaviour)this).StartCoroutine(ScanSequenceRoutine());
		}

		public void ShowMessage(string message)
		{
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				HUDManager.Instance.DisplayTip("Radar Upgrade", message, false, false, "LC_Tip1");
			}
		}

		private IEnumerator ScanSequenceRoutine()
		{
			Debug.Log((object)"[RadarPingUI] Starting ScanSequenceRoutine...");
			if ((Object)(object)pulseCircleTransform == (Object)null)
			{
				Debug.LogError((object)"[RadarPingUI] pulseCircleTransform is NULL!");
			}
			if ((Object)(object)mapPanelGroup == (Object)null)
			{
				Debug.LogError((object)"[RadarPingUI] mapPanelGroup is NULL!");
			}
			Debug.Log((object)"[RadarPingUI] Rolling corruption...");
			bool corrupted = false;
			float signalStrength = 1f;
			try
			{
				corrupted = RadarPingCorruption.RollCorruption(out signalStrength);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[RadarPingUI] Crash in RollCorruption: {arg}");
			}
			int pulses = 1;
			Debug.Log((object)$"[RadarPingUI] Playing {pulses} pulses...");
			for (int i = 0; i < pulses; i++)
			{
				yield return PlayPulse();
			}
			Debug.Log((object)"[RadarPingUI] Taking map screenshot...");
			Texture2D mapShot = null;
			try
			{
				mapShot = RadarScreenshotUtility.CaptureCleanMapShot();
				if ((Object)(object)mapShot == (Object)null)
				{
					Debug.LogWarning((object)"[RadarPingUI] mapShot returned NULL!");
				}
			}
			catch (Exception arg2)
			{
				Debug.LogError((object)$"[RadarPingUI] Crash in CaptureCleanMapShot: {arg2}");
			}
			Debug.Log((object)"[RadarPingUI] Revealing map...");
			yield return RevealMap(mapShot, corrupted, signalStrength);
			Debug.Log((object)$"[RadarPingUI] Waiting {3.5f} seconds...");
			yield return (object)new WaitForSeconds(3.5f);
			Debug.Log((object)"[RadarPingUI] Hiding map...");
			yield return HideMap();
			if ((Object)(object)mapShot != (Object)null)
			{
				Object.Destroy((Object)(object)mapShot);
			}
			_activeSequence = null;
			Debug.Log((object)"[RadarPingUI] Sequence complete!");
		}

		private IEnumerator PlayPulse()
		{
			if (!((Object)(object)pulseCircleTransform == (Object)null) && !((Object)(object)pulseCircleImage == (Object)null))
			{
				float spinAmount = 90f;
				((Transform)pulseCircleTransform).localScale = Vector3.one * 0.2f;
				((Transform)pulseCircleTransform).localRotation = Quaternion.identity;
				SetAlpha(pulseCircleImage, 0.8f);
				float t = 0f;
				while (t < pulseDuration)
				{
					t += Time.deltaTime;
					float p = t / pulseDuration;
					float easedP = Mathf.SmoothStep(0f, 1f, p);
					((Transform)pulseCircleTransform).localScale = Vector3.one * Mathf.Lerp(0.2f, pulseGrowScale, easedP);
					((Transform)pulseCircleTransform).localRotation = Quaternion.Euler(0f, 0f, spinAmount * easedP);
					SetAlpha(pulseCircleImage, Mathf.Lerp(0.8f, 0f, easedP));
					yield return null;
				}
			}
		}

		private IEnumerator RevealMap(Texture2D mapShot, bool corrupted, float signalStrength)
		{
			if ((Object)(object)mapImage != (Object)null)
			{
				mapImage.texture = (Texture)(object)mapShot;
			}
			if ((Object)(object)corruptionStaticOverlay != (Object)null)
			{
				corruptionStaticOverlay.SetActive(corrupted);
			}
			float targetAlpha = (corrupted ? 0.5f : Mathf.Max(0.85f, signalStrength));
			float t = 0f;
			while (t < mapFadeInTime)
			{
				t += Time.deltaTime;
				if ((Object)(object)mapPanelGroup != (Object)null)
				{
					mapPanelGroup.alpha = Mathf.Lerp(0f, targetAlpha, t / mapFadeInTime);
				}
				yield return null;
			}
		}

		private IEnumerator HideMap()
		{
			float startAlpha = (((Object)(object)mapPanelGroup != (Object)null) ? mapPanelGroup.alpha : 0f);
			float t = 0f;
			while (t < mapFadeOutTime)
			{
				t += Time.deltaTime;
				if ((Object)(object)mapPanelGroup != (Object)null)
				{
					mapPanelGroup.alpha = Mathf.Lerp(startAlpha, 0f, t / mapFadeOutTime);
				}
				yield return null;
			}
			if ((Object)(object)corruptionStaticOverlay != (Object)null)
			{
				corruptionStaticOverlay.SetActive(false);
			}
		}

		private static void SetAlpha(Image img, float a)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			Color color = ((Graphic)img).color;
			color.a = a;
			((Graphic)img).color = color;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class RadarPingUIInjector
	{
		private static Sprite CreateProceduralCircleSprite(int size, float borderWidth)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_00e5: 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_004b: 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)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)0;
			float num = (float)size / 2f;
			float num2 = num - 2f;
			float num3 = num2 * (1f - borderWidth);
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num4 = Vector2.Distance(new Vector2((float)i, (float)j), new Vector2(num, num));
					bool flag = num4 <= num2;
					bool flag2 = num4 >= num3;
					float num5 = ((flag && flag2) ? 1f : 0f);
					val.SetPixel(i, j, new Color(1f, 1f, 1f, num5));
				}
			}
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f));
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void BuildUIAtRuntime(HUDManager __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0072: 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_0088: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)RadarPingUI.Instance != (Object)null))
			{
				GameObject val = new GameObject("RadarPingUI_Root");
				val.transform.SetParent(__instance.HUDContainer.transform, false);
				val.transform.SetAsLastSibling();
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = Vector2.zero;
				val2.offsetMax = Vector2.zero;
				GameObject val3 = new GameObject("RadarPulse");
				val3.transform.SetParent(val.transform, false);
				RectTransform val4 = val3.AddComponent<RectTransform>();
				val4.anchorMin = new Vector2(1f, 1f);
				val4.anchorMax = new Vector2(1f, 1f);
				val4.sizeDelta = new Vector2(150f, 150f);
				val4.anchoredPosition = new Vector2(0f, 0f);
				Image val5 = val3.AddComponent<Image>();
				((Graphic)val5).color = new Color(0f, 1f, 0.3f, 0f);
				Sprite sprite = CreateProceduralCircleSprite(120, 0.15f);
				val5.sprite = sprite;
				GameObject val6 = new GameObject("RadarMapPanel");
				val6.transform.SetParent(val.transform, false);
				RectTransform val7 = val6.AddComponent<RectTransform>();
				val7.anchorMin = new Vector2(1f, 1f);
				val7.anchorMax = new Vector2(1f, 1f);
				val7.sizeDelta = new Vector2(125f, 125f);
				val7.anchoredPosition = new Vector2(-50f, -50f);
				CanvasGroup val8 = val6.AddComponent<CanvasGroup>();
				val8.alpha = 0f;
				GameObject val9 = new GameObject("MapRawImage");
				val9.transform.SetParent(val6.transform, false);
				RectTransform val10 = val9.AddComponent<RectTransform>();
				val10.anchorMin = Vector2.zero;
				val10.anchorMax = Vector2.one;
				val10.offsetMin = Vector2.zero;
				val10.offsetMax = Vector2.zero;
				RawImage val11 = val9.AddComponent<RawImage>();
				((Graphic)val11).color = Color.white;
				GameObject val12 = new GameObject("CorruptionStaticOverlay");
				val12.transform.SetParent(val6.transform, false);
				RectTransform val13 = val12.AddComponent<RectTransform>();
				val13.anchorMin = Vector2.zero;
				val13.anchorMax = Vector2.one;
				val13.offsetMin = Vector2.zero;
				val13.offsetMax = Vector2.zero;
				Image val14 = val12.AddComponent<Image>();
				((Graphic)val14).color = new Color(1f, 1f, 1f, 0.4f);
				val12.SetActive(false);
				RadarPingUI target = val.AddComponent<RadarPingUI>();
				SetPrivateField(target, "pulseCircleTransform", val4);
				SetPrivateField(target, "pulseCircleImage", val5);
				SetPrivateField(target, "mapPanelGroup", val8);
				SetPrivateField(target, "mapImage", val11);
				SetPrivateField(target, "corruptionStaticOverlay", val12);
				val8.alpha = 0f;
				((Graphic)val5).color = new Color(((Graphic)val5).color.r, ((Graphic)val5).color.g, ((Graphic)val5).color.b, 0f);
			}
		}

		private static void SetPrivateField(object target, string fieldName, object value)
		{
			FieldInfo field = target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(target, value);
			}
			else
			{
				Debug.LogError((object)("[RadarPingUIInjector] Could not find private field '" + fieldName + "' in RadarPingUI!"));
			}
		}
	}
	public static class RadarScreenshotUtility
	{
		private const int ImageResolution = 512;

		private const float OrthoSize = 40f;

		private const float CameraHeight = 60f;

		private static readonly string[] IncludedLayerNames = new string[5] { "Room", "Default", "InteriorWall", "Foliage", "Player" };

		public static Texture2D CaptureCleanMapShot()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			GameObject val2 = new GameObject("RadarPingTempCamera");
			Camera val3 = val2.AddComponent<Camera>();
			val3.orthographic = true;
			val3.orthographicSize = 40f;
			val3.clearFlags = (CameraClearFlags)2;
			val3.backgroundColor = Color.black;
			val3.cullingMask = LayerMask.GetMask(IncludedLayerNames);
			val3.farClipPlane = 70f;
			val2.transform.position = ((Component)val).transform.position + Vector3.up * 60f;
			val2.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
			RenderTexture val4 = (val3.targetTexture = new RenderTexture(512, 512, 16));
			Texture2D val6 = new Texture2D(512, 512, (TextureFormat)3, false);
			RenderTexture active = RenderTexture.active;
			val3.Render();
			RenderTexture.active = val4;
			val6.ReadPixels(new Rect(0f, 0f, 512f, 512f), 0, 0);
			val6.Apply();
			RenderTexture.active = active;
			val3.targetTexture = null;
			val4.Release();
			Object.Destroy((Object)(object)val4);
			Object.Destroy((Object)(object)val2);
			return val6;
		}
	}
}
namespace CompanyLighting.Patches
{
	[HarmonyPatch(typeof(HangarShipDoor))]
	internal class HangarShipDoorPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void DoorHydraulicPatch(HangarShipDoor __instance)
		{
			if (LightingNetworkHandler.Instance != null)
			{
				int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel("doorhydraulics");
				float num = 20f;
				num += (float)upgradeLevel * 5f;
				__instance.doorPowerDuration = num;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("PingScan_performed")]
		[HarmonyPrefix]
		private static void ScannerPatch(HUDManager __instance, ref float ___playerPingingScan)
		{
			if (LightingNetworkHandler.Instance != null && ___playerPingingScan <= -1f)
			{
				int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel("deepscanner");
				if (upgradeLevel > 0)
				{
					((MonoBehaviour)__instance).StartCoroutine(ScanLightPulse(upgradeLevel));
				}
			}
		}

		private static IEnumerator ScanLightPulse(int scanValue)
		{
			PlayerControllerB localPlayer = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.gameplayCamera == (Object)null)
			{
				yield break;
			}
			GameObject scanLightObj = new GameObject("V_ScanPulseLight");
			scanLightObj.transform.SetParent(((Component)localPlayer.gameplayCamera).transform, false);
			scanLightObj.transform.localPosition = Vector3.zero;
			Light scanLight = scanLightObj.AddComponent<Light>();
			HDAdditionalLightData hdLightData = scanLightObj.AddComponent<HDAdditionalLightData>();
			scanLight.type = (LightType)2;
			scanLight.color = new Color(0.1f, 0.4f, 1f);
			float totalDuration = 0.6f;
			float fadeStartTime = 0.3f;
			float timer = 0f;
			float maxIntensity = 20f * (float)scanValue;
			float maxRange = 12f + 3f * (float)scanValue;
			hdLightData.lightUnit = (LightUnit)0;
			hdLightData.intensity = maxIntensity;
			while (timer < totalDuration)
			{
				timer += Time.deltaTime;
				float timeProgress = timer / totalDuration;
				scanLight.range = Mathf.Lerp(0f, maxRange, Mathf.Sqrt(timeProgress));
				if (timer > fadeStartTime)
				{
					float fadeProgress = (timer - fadeStartTime) / (totalDuration - fadeStartTime);
					float fadeCurve = 1f - Mathf.SmoothStep(0f, 1f, fadeProgress);
					hdLightData.intensity = maxIntensity * fadeCurve;
				}
				yield return null;
			}
			Object.Destroy((Object)(object)scanLightObj);
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		private static GameObject helmetLObject;

		private static Light helmetLight;

		private static HDAdditionalLightData hdLightData;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void HelmetLightPatch(PlayerControllerB __instance, ref Light ___nightVision, ref Camera ___gameplayCamera, ref Transform ___playerGlobalHead)
		{
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Expected O, but got Unknown
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Expected O, but got Unknown
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			if (LightingNetworkHandler.Instance == null)
			{
				return;
			}
			if ((Object)(object)___nightVision != (Object)null)
			{
				((Behaviour)___nightVision).enabled = false;
			}
			if ((Object)(object)___gameplayCamera == (Object)null)
			{
				return;
			}
			bool flag = false;
			if (__instance.isInsideFactory)
			{
				flag = true;
			}
			else if (__instance.isInHangarShipRoom)
			{
				if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.shipRoomLights != (Object)null)
				{
					flag = !StartOfRound.Instance.shipRoomLights.areLightsOn;
				}
			}
			else if ((Object)(object)TimeOfDay.Instance != (Object)null)
			{
				int num = (int)(TimeOfDay.Instance.currentDayTime / TimeOfDay.Instance.lengthOfHours) + 6;
				if (num >= 18)
				{
					flag = true;
				}
			}
			float num2 = Mathf.Clamp01((float)__instance.health / 100f);
			float num3 = num2;
			if (num2 < 1f && !__instance.isPlayerDead)
			{
				float num4 = Mathf.Lerp(25f, 5f, num2);
				float num5 = Mathf.PerlinNoise(Time.time * num4, (float)__instance.playerClientId * 10f);
				float num6 = Mathf.Lerp(1f, 0f, num2);
				num3 -= num5 * num6;
			}
			num3 = Mathf.Clamp01(num3);
			int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel("flbrightness");
			int upgradeLevel2 = LightingNetworkHandler.Instance.GetUpgradeLevel("flrange");
			float num7 = 1.5f * (float)upgradeLevel;
			float num8 = 1.5f * (float)upgradeLevel2;
			if ((((NetworkBehaviour)__instance).IsOwner || (((NetworkBehaviour)__instance).IsServer && __instance.isHostPlayerObject)) && __instance.isPlayerControlled)
			{
				if ((Object)(object)helmetLObject == (Object)null)
				{
					helmetLObject = new GameObject("V_HelmetLight");
					helmetLight = helmetLObject.AddComponent<Light>();
					hdLightData = helmetLObject.AddComponent<HDAdditionalLightData>();
				}
				if ((Object)(object)helmetLObject.transform.parent != (Object)(object)((Component)___gameplayCamera).transform)
				{
					helmetLObject.transform.SetParent(((Component)___gameplayCamera).transform, false);
					helmetLObject.transform.localPosition = new Vector3(0f, 0f, 0.2f);
					helmetLObject.transform.localRotation = Quaternion.identity;
				}
				if ((Object)(object)helmetLight == (Object)null)
				{
					helmetLight = helmetLObject.AddComponent<Light>();
				}
				helmetLight.type = (LightType)0;
				helmetLight.color = new Color(0.8f, 0.95f, 1f);
				helmetLight.range = 8f + (float)upgradeLevel2;
				helmetLight.spotAngle = 125f;
				helmetLight.innerSpotAngle = 75f;
				((Behaviour)helmetLight).enabled = !__instance.isPlayerDead && num3 > 0.01f && flag;
				if ((Object)(object)hdLightData != (Object)null)
				{
					hdLightData.intensity = (8f + (float)upgradeLevel) * num3;
					hdLightData.lightUnit = (LightUnit)0;
				}
			}
			else if ((__instance.isPlayerControlled || __instance.isPlayerDead) && !((Object)(object)___playerGlobalHead == (Object)null))
			{
				Transform val = ___playerGlobalHead.Find("V_HelmetLight");
				Transform val2 = ___playerGlobalHead.Find("V_VisorGlow");
				Light val4;
				HDAdditionalLightData val5;
				if ((Object)(object)val == (Object)null)
				{
					GameObject val3 = new GameObject("V_HelmetLight");
					val3.transform.SetParent(___playerGlobalHead, false);
					val3.transform.localPosition = new Vector3(0f, 0.225f, 0.25f);
					val3.transform.localRotation = Quaternion.identity;
					val4 = val3.AddComponent<Light>();
					val5 = val3.AddComponent<HDAdditionalLightData>();
				}
				else
				{
					val4 = ((Component)val).GetComponent<Light>();
					val5 = ((Component)val).GetComponent<HDAdditionalLightData>();
				}
				Light val7;
				HDAdditionalLightData val8;
				if ((Object)(object)val2 == (Object)null)
				{
					GameObject val6 = new GameObject("V_VisorGlow");
					val6.transform.SetParent(___playerGlobalHead, false);
					val6.transform.localPosition = new Vector3(0f, 0.225f, 0.25f);
					val6.transform.localRotation = Quaternion.identity;
					val7 = val6.AddComponent<Light>();
					val8 = val6.AddComponent<HDAdditionalLightData>();
				}
				else
				{
					val7 = ((Component)val2).GetComponent<Light>();
					val8 = ((Component)val2).GetComponent<HDAdditionalLightData>();
				}
				val4.type = (LightType)0;
				val4.color = new Color(0.8f, 0.95f, 1f);
				val4.range = 8f + (float)upgradeLevel2;
				val4.spotAngle = 125f;
				val4.innerSpotAngle = 75f;
				((Behaviour)val4).enabled = !__instance.isPlayerDead && num3 > 0.01f && flag;
				if ((Object)(object)val5 != (Object)null)
				{
					val5.intensity = (8f + (float)upgradeLevel) * num3;
					val5.lightUnit = (LightUnit)0;
				}
				val7.type = (LightType)2;
				val7.color = new Color(0.8f, 0.95f, 1f);
				val7.range = 0.5f;
				((Behaviour)val7).enabled = !__instance.isPlayerDead && num3 > 0.01f && flag;
				if ((Object)(object)val8 != (Object)null)
				{
					val8.intensity = (8f + (float)upgradeLevel) * num3;
					val8.lightUnit = (LightUnit)0;
				}
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CarryWeightPatch(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance == (Object)null || !__instance.isPlayerControlled)
			{
				return;
			}
			int num = ((LightingNetworkHandler.Instance != null) ? LightingNetworkHandler.Instance.GetUpgradeLevel("lightweight") : 0);
			if (num <= 0)
			{
				return;
			}
			float num2 = 0.15f;
			float num3 = 0f;
			if (num == 2)
			{
				num3 = 0.175f;
			}
			else if (num > 2)
			{
				num2 = 0.3f;
				num3 = 0.225f;
			}
			float num4 = 1f;
			float num5 = 0f;
			if (__instance.ItemSlots != null)
			{
				GrabbableObject[] itemSlots = __instance.ItemSlots;
				foreach (GrabbableObject val in itemSlots)
				{
					if (!((Object)(object)val != (Object)null) || !((Object)(object)val.itemProperties != (Object)null))
					{
						continue;
					}
					float num6 = val.itemProperties.weight - 1f;
					num4 += num6;
					float num7 = num6 * 105f;
					if (num7 > 0f)
					{
						if (num7 <= 12f)
						{
							num5 += num6 * num2;
						}
						else if (num7 <= 30f && num3 > 0f)
						{
							num5 += num6 * num3;
						}
					}
				}
			}
			__instance.carryWeight = Mathf.Max(1f, num4 - num5);
			if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)HUDManager.Instance != (Object)null)
			{
				int num8 = Mathf.RoundToInt((__instance.carryWeight - 1f) * 105f);
				if (num8 < 0)
				{
					num8 = 0;
				}
				if ((Object)(object)HUDManager.Instance.weightCounter != (Object)null)
				{
					((TMP_Text)HUDManager.Instance.weightCounter).text = $"{num8} lb";
				}
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CarryDistancePatch(PlayerControllerB __instance)
		{
			if (LightingNetworkHandler.Instance != null)
			{
				int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel("magneticgloves");
				float num = 5f;
				num += (float)upgradeLevel * 0.5f;
				__instance.grabDistance = num;
			}
		}

		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void UpdateSlotsOnLoad(PlayerControllerB __instance)
		{
			if (LightingNetworkHandler.Instance != null)
			{
				bool hasUpgrade = LightingNetworkHandler.Instance.GetUpgradeLevel("carryamount") > 0;
				Backpack.ApplyInventorySize(__instance, hasUpgrade);
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("PlayAudibleNoise")]
		[HarmonyPrefix]
		private static void NoiseMufflePatch(RoundManagerPatch __instance, Vector3 noisePosition, float noiseRange = 10f, float noiseLoudness = 0.5f, int timesPlayedInSameSpot = 0, bool noiseIsInsideClosedShip = false, int noiseID = 0)
		{
			if (LightingNetworkHandler.Instance != null)
			{
				int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel("acousticdampeners");
				if (upgradeLevel > 0)
				{
					float num = 1f - (float)upgradeLevel * 0.15f;
					noiseRange *= num;
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class UnlockableSyncPatch
	{
		private static int slotUpdateInt;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateSlots(StartOfRound __instance)
		{
			if (LightingNetworkHandler.Instance == null)
			{
				return;
			}
			slotUpdateInt++;
			if (slotUpdateInt < 60)
			{
				return;
			}
			slotUpdateInt = 0;
			bool hasUpgrade = LightingNetworkHandler.Instance.GetUpgradeLevel("carryamount") > 0;
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController != (Object)null)
			{
				Backpack.ApplyInventorySize(localPlayerController, hasUpgrade);
				int upgradeLevel = LightingNetworkHandler.Instance.GetUpgradeLevel("batterybank");
				if (upgradeLevel > 0)
				{
					Overcharger.Spawn(null, 0.9f);
				}
				else
				{
					Overcharger.Despawn();
				}
			}
		}
	}
}
namespace SomethingSomethingCompany.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}