Decompiled source of LocalFlashlight v1.4.13

LocalFlashlight.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LocalFlashlight.NetcodePatcher;
using LocalFlashlight.Networking;
using Microsoft.CodeAnalysis;
using TMPro;
using TerminalApi;
using TerminalApi.Classes;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.InputSystem;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LocalFlashlight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0b1e44eae724efbb9a787ce025ca3bc0af57ca0d")]
[assembly: AssemblyProduct("LocalFlashlight")]
[assembly: AssemblyTitle("LocalFlashlight")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
public enum BatteryDisplayOptions
{
	Disabled,
	Bar,
	Percentage,
	VerticalBar,
	CircularBar,
	All
}
public enum TextDisplayOptions
{
	Percent,
	AccuratePercent,
	Time,
	All
}
public enum SoundOptions
{
	OriginalLightSounds,
	InGameFlashlight,
	OtherwordlyLight
}
public enum RechargeOptions
{
	Time,
	Shake,
	Dynamo,
	ShipRecharge,
	FacilityPowered
}
public enum GlobalFlashlightOptions
{
	CrewUpgrade,
	Unrestricted
}
namespace LocalFlashlight
{
	internal class LightScript : MonoBehaviour
	{
		private PlayerControllerB player_controller;

		public ulong clientId;

		private GameObject player;

		private GameObject cameraObject;

		private GameObject dynamoLightObj;

		private static GameObject lightObject;

		public static AudioClip[] flashlightClips = (AudioClip[])(object)new AudioClip[25];

		public static int[] activeClips = new int[15];

		private static AudioSource flashSource;

		private static AudioSource dynamoAudioSource;

		private Light localLight;

		private bool flashState;

		public static bool publicFlashState;

		private bool canToggle = true;

		private SoundOptions selectedSoundOption;

		private RechargeOptions selectedRechargeOption;

		private float playerMovementSpeed;

		public static float UIHideTime;

		public static float maxBatteryTime;

		public static float BatteryPercent;

		public static float truePercentBattery;

		public static float BatteryClamped;

		public static float batteryTime = maxBatteryTime;

		private float batteryRegen;

		private float regenCool;

		private float batteryCooldown;

		private float burnOutCooldown;

		private float shakeCool;

		private float soundCool;

		private float lastShakeTime = 0f;

		private bool rechargeKeyHeld = false;

		private float targetVolume = 0f;

		private float targetPitch = 0f;

		private float windRechargeMult = 0f;

		public static Color flashColor;

		private int toggleAmount = 0;

		private float flashOnTime = 0f;

		private int timesCommandUsed = 0;

		private void Start()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			Plugin.mls.LogInfo((object)"Mod script started, setting mod values and making light...");
			FindLocalPlayer();
			if (!(((Object)(object)player == (Object)null) | ((Object)(object)cameraObject == (Object)null)))
			{
				SetModValues();
				SetFlashlightSounds();
				MakeLocalLight();
				if (Plugin.enableNetworking.Value)
				{
					LFNetworkHandler.Instance.RequestAllLightsUpdateServerRpc();
				}
				((Behaviour)localLight).enabled = false;
				TerminalApi.AddCommand("LocalFlashlight", new CommandInfo
				{
					Category = "other",
					Description = (Plugin.enableNetworking.Value ? "Shows the state of the flashlight upgrade if you already have it unlocked. If not, use \"LocalFlashlight buy\" to buy it instead!" : "Displays statistics about the flashlight's usage"),
					DisplayTextSupplier = onCommandParse
				}, (string)null, true);
			}
		}

		public void Update()
		{
			if (((Object)(object)player == (Object)null) | ((Object)(object)player_controller == (Object)null) | ((Object)(object)cameraObject == (Object)null) | ((Object)(object)lightObject == (Object)null))
			{
				return;
			}
			try
			{
				UpdateModValues();
				if (batteryTime > maxBatteryTime)
				{
					batteryTime = maxBatteryTime;
					if (selectedRechargeOption == RechargeOptions.Time)
					{
						PlayNoise(activeClips[3], 0.7f, playForWorld: true);
					}
				}
				if (flashState)
				{
					batteryTime -= Time.deltaTime;
					flashOnTime += Time.deltaTime;
					if (batteryTime < 0f)
					{
						if (Plugin.flickerOnBatteryBurn.Value)
						{
							((MonoBehaviour)this).StartCoroutine(FlickerAndStop());
						}
						else
						{
							Toggle();
						}
					}
				}
				if (((double)BatteryPercent <= 99.75) | flashState)
				{
					UIHideTime = Plugin.HideUIDelay.Value;
				}
				if ((double)BatteryPercent > 99.75 && !flashState)
				{
					UIHideTime -= Time.deltaTime;
				}
				UpdateBatteryValues();
				if (Plugin.flashlightToggleInstance.toggleKey.triggered)
				{
					if (player_controller.quickMenuManager.isMenuOpen | player_controller.isPlayerDead | player_controller.inTerminalMenu | player_controller.isTypingChat | player_controller.inSpecialInteractAnimation | ((Object)(object)localLight == (Object)null))
					{
						return;
					}
					if (batteryTime > 0f)
					{
						if (flashState)
						{
							Toggle();
						}
						else if (!flashState && canToggle)
						{
							Toggle();
						}
						else if (Patches.isFlashlightHeld)
						{
							PlayNoise(22, 0.3f, playForWorld: false);
						}
					}
					else
					{
						PlayNoise(22, 0.7f, playForWorld: false);
					}
				}
				if (Plugin.flashlightToggleInstance.switchLightPosKey.triggered && !(player_controller.quickMenuManager.isMenuOpen | player_controller.isPlayerDead | player_controller.inTerminalMenu | player_controller.isTypingChat | player_controller.inSpecialInteractAnimation | ((Object)(object)localLight == (Object)null)))
				{
					ChangeLightPosition();
				}
			}
			catch (Exception arg)
			{
				Plugin.mls.LogError((object)$"something went wrong in the update script!! might be either from battery update, mod value update, or whatever else there is in this script:\n{arg}");
			}
		}

		private void Toggle()
		{
			if ((Object)(object)player == (Object)null || (Object)(object)cameraObject == (Object)null)
			{
				return;
			}
			flashState = !flashState;
			publicFlashState = flashState;
			((Behaviour)localLight).enabled = flashState;
			if (Plugin.enableNetworking.Value)
			{
				LFNetworkHandler.Instance.ToggleLightServerRpc(player_controller.playerClientId, flashState);
			}
			if (flashState)
			{
				PlayNoise(activeClips[0], 0.3f, playForWorld: true);
				toggleAmount++;
				return;
			}
			if (batteryTime <= 0f && Plugin.BatteryBurnOut.Value)
			{
				regenCool = burnOutCooldown;
			}
			else
			{
				regenCool = batteryCooldown;
				toggleAmount++;
			}
			if (batteryTime <= 0f)
			{
				PlayNoise(activeClips[2], 0.5f, playForWorld: true);
			}
			else
			{
				PlayNoise(activeClips[1], 0.6f, playForWorld: true);
			}
		}

		private void ChangeLightPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			float x = lightObject.transform.localPosition.x;
			float y = lightObject.transform.localRotation.y;
			lightObject.transform.localPosition = new Vector3(0f - x, -0.55f, 0.5f);
			lightObject.transform.localRotation = Quaternion.Euler(-10f, 0f - y, 0f);
			PlayNoise(21, 0.3f, playForWorld: false);
		}

		public static void PlayNoise(int clipIndex, float volume, bool playForWorld)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			AudioSource obj = flashSource;
			if (obj != null)
			{
				obj.PlayOneShot(flashlightClips[clipIndex]);
			}
			if (playForWorld)
			{
				Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(lightObject.transform.position, 8f, volume, 0, StartOfRound.Instance.localPlayerController.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
				if (Plugin.enableNetworking.Value)
				{
					LFNetworkHandler.Instance.PlayNetworkedSoundServerRpc(StartOfRound.Instance.localPlayerController.playerClientId, clipIndex);
				}
			}
		}

		private void holdCallback(CallbackContext context)
		{
			if (!((selectedRechargeOption != RechargeOptions.Dynamo) | player_controller.quickMenuManager.isMenuOpen | player_controller.isPlayerDead | player_controller.inTerminalMenu | player_controller.isTypingChat))
			{
				targetVolume = (float)Plugin.FlashVolume.Value / 200f;
				targetPitch = 1f;
				if ((Object)(object)dynamoAudioSource != (Object)null)
				{
					dynamoAudioSource.loop = true;
					dynamoAudioSource.clip = flashlightClips[activeClips[5]];
					dynamoAudioSource.Play();
				}
				rechargeKeyHeld = true;
			}
		}

		private void releaseCallback(CallbackContext context)
		{
			if (selectedRechargeOption == RechargeOptions.Dynamo)
			{
				targetVolume = 0f;
				targetPitch = 0f;
				if ((Object)(object)dynamoAudioSource != (Object)null)
				{
					dynamoAudioSource.loop = false;
				}
				soundCool = 0.25f;
				rechargeKeyHeld = false;
			}
		}

		private void SetFlashlightSounds()
		{
			try
			{
				selectedSoundOption = Plugin.soundOption.Value;
				flashlightClips[0] = Plugin.bundle.LoadAsset<AudioClip>("lighton");
				flashlightClips[1] = Plugin.bundle.LoadAsset<AudioClip>("lighton1");
				flashlightClips[2] = Plugin.bundle.LoadAsset<AudioClip>("lighton2");
				flashlightClips[3] = Plugin.bundle.LoadAsset<AudioClip>("lightoff");
				flashlightClips[4] = Plugin.bundle.LoadAsset<AudioClip>("lighton1");
				flashlightClips[5] = Plugin.bundle.LoadAsset<AudioClip>("lighton2");
				flashlightClips[6] = Plugin.bundle.LoadAsset<AudioClip>("lowtoggle");
				flashlightClips[7] = Plugin.bundle.LoadAsset<AudioClip>("lowtoggle2");
				flashlightClips[8] = Plugin.bundle.LoadAsset<AudioClip>("lowtoggle1");
				flashlightClips[9] = Plugin.bundle.LoadAsset<AudioClip>("recharged");
				flashlightClips[10] = Plugin.bundle.LoadAsset<AudioClip>("recharged1");
				flashlightClips[11] = Plugin.bundle.LoadAsset<AudioClip>("recharged2");
				flashlightClips[12] = Plugin.bundle.LoadAsset<AudioClip>("reloadlight");
				flashlightClips[13] = Plugin.bundle.LoadAsset<AudioClip>("reloadlight");
				flashlightClips[14] = Plugin.bundle.LoadAsset<AudioClip>("reloadlight");
				flashlightClips[15] = Plugin.bundle.LoadAsset<AudioClip>("dynamo");
				flashlightClips[16] = Plugin.bundle.LoadAsset<AudioClip>("dynamo1");
				flashlightClips[17] = Plugin.bundle.LoadAsset<AudioClip>("dynamo2");
				flashlightClips[18] = Plugin.bundle.LoadAsset<AudioClip>("flashDown");
				flashlightClips[19] = Plugin.bundle.LoadAsset<AudioClip>("flashDown1");
				flashlightClips[20] = Plugin.bundle.LoadAsset<AudioClip>("flashDown2");
				flashlightClips[21] = Plugin.bundle.LoadAsset<AudioClip>("changepos.ogg");
				flashlightClips[22] = Plugin.bundle.LoadAsset<AudioClip>("denytoggle");
				Plugin.mls.LogDebug((object)"loaded assets...");
				switch (selectedSoundOption)
				{
				case SoundOptions.OriginalLightSounds:
					activeClips[0] = 0;
					activeClips[1] = 3;
					activeClips[2] = 6;
					activeClips[3] = 9;
					activeClips[4] = 12;
					activeClips[5] = 16;
					activeClips[6] = 19;
					break;
				case SoundOptions.OtherwordlyLight:
					activeClips[0] = 1;
					activeClips[1] = 4;
					activeClips[2] = 7;
					activeClips[3] = 11;
					activeClips[4] = 13;
					activeClips[5] = 17;
					activeClips[6] = 18;
					break;
				case SoundOptions.InGameFlashlight:
					activeClips[0] = 2;
					activeClips[1] = 5;
					activeClips[2] = 8;
					activeClips[3] = 10;
					activeClips[4] = 14;
					activeClips[5] = 15;
					activeClips[6] = 20;
					break;
				}
			}
			catch (Exception arg)
			{
				Plugin.mls.LogError((object)$"error while setting localflashlight mod sounds:\n{arg}");
			}
		}

		private void SetModValues()
		{
			try
			{
				flashState = false;
				canToggle = true;
				rechargeKeyHeld = false;
				maxBatteryTime = Plugin.BatteryLife.Value;
				batteryTime = maxBatteryTime;
				batteryRegen = Plugin.RechargeMult.Value;
				burnOutCooldown = Plugin.BurnOutCool.Value;
				batteryCooldown = Plugin.BatteryCool.Value;
				UIHideTime = 2f + Plugin.HideUIDelay.Value;
				selectedRechargeOption = Plugin.rechargeOption.Value;
				shakeCool = Plugin.shakeActionCooldown.Value;
				playerMovementSpeed = player_controller.movementSpeed;
				ColorUtility.TryParseHtmlString(Plugin.flashlightColorHex.Value, ref flashColor);
			}
			catch (Exception arg)
			{
				Plugin.mls.LogError((object)$"error while setting initial localflashlight mod values:\n{arg}");
			}
		}

		private void FindLocalPlayer()
		{
			if ((Object)(object)player != (Object)null)
			{
				return;
			}
			try
			{
				Plugin.mls.LogInfo((object)"Attempting to find local player controller!");
				player = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject;
				if ((Object)(object)player != (Object)null)
				{
					player_controller = player.GetComponent<PlayerControllerB>();
					cameraObject = ((Component)player_controller.gameplayCamera).gameObject;
					clientId = GameNetworkManager.Instance.localPlayerController.playerClientId;
				}
			}
			catch (Exception arg)
			{
				Plugin.mls.LogError((object)$"error while finding the local player controller! it may be null or the mod just can't find it for whatever reason\n{arg}");
			}
		}

		private void MakeLocalLight()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			if ((Object)(object)player == (Object)null)
			{
				Plugin.mls.LogError((object)"no player!!!!!!!");
				return;
			}
			try
			{
				AudioMixerGroup outputAudioMixerGroup = ((Component)GameNetworkManager.Instance.localPlayerController.itemAudio).GetComponent<AudioSource>().outputAudioMixerGroup;
				lightObject = new GameObject();
				lightObject.transform.SetParent(cameraObject.transform, false);
				((Object)lightObject).name = "lightObject (LOCAL)";
				localLight = lightObject.AddComponent<Light>();
				localLight.type = (LightType)0;
				localLight.shape = (LightShape)0;
				localLight.color = flashColor;
				localLight.intensity = Plugin.Intensity.Value;
				localLight.range = Plugin.Range.Value;
				localLight.shadows = (LightShadows)1;
				localLight.spotAngle = Plugin.Angle.Value;
				flashSource = lightObject.AddComponent<AudioSource>();
				flashSource.loop = false;
				flashSource.playOnAwake = false;
				flashSource.volume = (float)Plugin.FlashVolume.Value / 100f;
				flashSource.priority = 0;
				flashSource.spatialize = true;
				flashSource.outputAudioMixerGroup = outputAudioMixerGroup;
				lightObject.transform.localPosition = new Vector3(-0.15f, -0.55f, 0.5f);
				lightObject.transform.Rotate(new Vector3(-12f, 3f, 0f));
				if (selectedRechargeOption == RechargeOptions.Dynamo)
				{
					dynamoLightObj = new GameObject("DynamoAudioSource (ONLY USED FOR DYNAMO RECHARGE)");
					dynamoLightObj.transform.SetParent(lightObject.transform, false);
					dynamoAudioSource = dynamoLightObj.AddComponent<AudioSource>();
					((Object)dynamoAudioSource).name = "yeah no idea why this happens but every time its a nullreferenceexception per frame if i dont keep this, nevermind i fixed it";
					dynamoAudioSource.loop = true;
					dynamoAudioSource.priority = 0;
					dynamoAudioSource.spatialize = true;
					dynamoAudioSource.outputAudioMixerGroup = outputAudioMixerGroup;
				}
				if (Plugin.ShadowsEnabled.Value)
				{
					HDAdditionalLightData val = lightObject.AddComponent<HDAdditionalLightData>();
					val.EnableShadows(true);
					val.SetShadowNearPlane(0.35f);
				}
				lightObject.SetActive(true);
				Plugin.mls.LogInfo((object)"light up and working!");
			}
			catch (Exception arg)
			{
				Plugin.mls.LogError((object)$"error while creating the light object:\n{arg}");
			}
		}

		private void UpdateModValues()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			regenCool -= Time.deltaTime;
			BatteryPercent = (int)Math.Ceiling(batteryTime / maxBatteryTime * 100f);
			BatteryClamped = batteryTime / maxBatteryTime;
			truePercentBattery = BatteryClamped * 100f;
			ColorUtility.TryParseHtmlString(Plugin.flashlightColorHex.Value, ref flashColor);
			localLight.color = flashColor;
			localLight.range = Plugin.Range.Value;
			localLight.spotAngle = Plugin.Angle.Value;
			flashSource.volume = (float)Plugin.FlashVolume.Value / 100f;
			if (selectedRechargeOption == RechargeOptions.Dynamo && (Object)(object)dynamoAudioSource != (Object)null)
			{
				dynamoAudioSource.volume = Mathf.Lerp(dynamoAudioSource.volume, targetVolume, Time.deltaTime * 6f);
				dynamoAudioSource.pitch = Mathf.Lerp(dynamoAudioSource.pitch, targetPitch, Time.deltaTime * 6f);
			}
			canToggle = !Plugin.flashlightToggleModSynergyquestionmark.Value || (!((Behaviour)player_controller.helmetLight).enabled && !Patches.isFlashlightPocketed && !Patches.isFlashlightHeld);
			if (player_controller.isPlayerDead)
			{
				flashState = false;
				((Behaviour)localLight).enabled = false;
				batteryTime = maxBatteryTime;
				regenCool = 0f;
				canToggle = true;
				rechargeKeyHeld = false;
			}
			float val = Mathf.Lerp(0f, 1f, BatteryClamped);
			val = Math.Max(val, (float)Plugin.flashlightStopDimBatteryValue.Value / 100f);
			if (FlashlightItem.globalFlashlightInterferenceLevel >= 1)
			{
				localLight.intensity = Plugin.Intensity.Value * ((selectedRechargeOption == RechargeOptions.FacilityPowered) ? Plugin.apparaticeFlashlightIntensityMult.Value : 1f) * Patches.randomLightInterferenceMultiplier;
			}
			else
			{
				localLight.intensity = (Plugin.dimEnabled.Value ? (Plugin.Intensity.Value * val) : Plugin.Intensity.Value);
			}
		}

		private void UpdateBatteryValues()
		{
			switch (selectedRechargeOption)
			{
			case RechargeOptions.Time:
				if (!flashState && (double)batteryTime <= (double)maxBatteryTime - 0.001 && regenCool < 0f)
				{
					batteryTime += batteryRegen * Time.deltaTime;
				}
				break;
			case RechargeOptions.Shake:
				if (Plugin.flashlightToggleInstance.rechargeKey.triggered && Time.time - lastShakeTime > shakeCool && !player_controller.quickMenuManager.isMenuOpen && !player_controller.isPlayerDead && !player_controller.inTerminalMenu && !player_controller.isTypingChat)
				{
					if (player_controller.sprintMeter > 0.25f)
					{
						batteryTime += maxBatteryTime * 0.07f * batteryRegen;
						PlayNoise(activeClips[4], 0.6f, playForWorld: true);
						PlayerControllerB obj = player_controller;
						obj.sprintMeter -= (float)Plugin.shakeStaminaConsume.Value / 100f;
						lastShakeTime = Time.time;
					}
					else
					{
						PlayNoise(22, 0.7f, playForWorld: false);
					}
				}
				break;
			case RechargeOptions.Dynamo:
				if (!player_controller.quickMenuManager.isMenuOpen || !player_controller.isPlayerDead || !player_controller.isTypingChat || !player_controller.inSpecialInteractAnimation)
				{
					Plugin.flashlightToggleInstance.rechargeKey.performed += holdCallback;
					Plugin.flashlightToggleInstance.rechargeKey.canceled += releaseCallback;
				}
				else
				{
					Plugin.flashlightToggleInstance.rechargeKey.performed -= holdCallback;
				}
				if (rechargeKeyHeld)
				{
					WindUpFlashlight();
					windRechargeMult += Time.deltaTime * 3f;
				}
				else if (windRechargeMult > 0f)
				{
					windRechargeMult -= Time.deltaTime * 5f;
				}
				batteryTime += Time.deltaTime * batteryRegen * windRechargeMult;
				windRechargeMult = Mathf.Clamp(windRechargeMult, 0f, 1.5f);
				player_controller.movementSpeed = (rechargeKeyHeld ? (playerMovementSpeed * Plugin.dynamoUseMoveMult.Value) : playerMovementSpeed);
				break;
			case RechargeOptions.FacilityPowered:
				if (Patches.isFacilityPowered)
				{
					batteryTime = maxBatteryTime;
				}
				break;
			case RechargeOptions.ShipRecharge:
				batteryTime = (player_controller.isInHangarShipRoom ? maxBatteryTime : batteryTime);
				break;
			}
		}

		private void WindUpFlashlight()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (selectedRechargeOption == RechargeOptions.Dynamo)
			{
				PlayerControllerB obj = player_controller;
				obj.sprintMeter -= Time.deltaTime * 0.03f;
				if (soundCool < 0f)
				{
					Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)player_controller).transform.position, 8f, 0.5f, 0, player_controller.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
					soundCool = 0.4f;
				}
				soundCool -= Time.deltaTime;
			}
		}

		private IEnumerator FlickerAndStop()
		{
			regenCool = 0.3f + (Plugin.BatteryBurnOut.Value ? burnOutCooldown : batteryCooldown);
			flashState = false;
			publicFlashState = flashState;
			PlayNoise(8, 0.6f, playForWorld: true);
			if (Plugin.enableNetworking.Value)
			{
				LFNetworkHandler.Instance.FlickerOutServerRpc(player_controller.playerClientId);
			}
			((Behaviour)localLight).enabled = false;
			yield return (object)new WaitForSeconds(0.1f);
			((Behaviour)localLight).enabled = true;
			yield return (object)new WaitForSeconds(0.1f);
			((Behaviour)localLight).enabled = false;
		}

		private string onCommandParse()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			string text = null;
			text += "the command isn't fully implemented, nor is the upgrade system, so here's some stats from your entire game session up to this point\n\n";
			text = text + "Flashlight toggle count: " + toggleAmount + "\n";
			text = text + "Time spent using the light: " + $"{flashOnTime:.00}" + " seconds\n";
			text = text + "Flashlight recharge method: " + selectedRechargeOption.ToString() + "\n";
			timesCommandUsed++;
			text = text + "Times you used this command: " + timesCommandUsed + "\n";
			if (timesCommandUsed <= 1)
			{
				text += "\nsadly these stats will get reset when starting up the game again but i'll try making it an actual mini-save file if it turns out to be a good feature to add in\n";
			}
			if (Plugin.enableNetworking.Value)
			{
				TerminalApi.AddCommand("Localflashlight sayhi", new CommandInfo
				{
					DisplayTextSupplier = terminalSayHi,
					Category = null
				}, (string)null, true);
			}
			return text;
		}

		private string terminalSayHi()
		{
			LFNetworkHandler.Instance.SayHiServerRpc(player_controller.playerClientId);
			return "Said hello to all the people in the server!\n\nhow'd you find this anyway?\n";
		}
	}
	internal class Patches : MonoBehaviour
	{
		private static GameObject UIContainer;

		private static GameObject frameObj;

		private static GameObject meterObj;

		private static GameObject textObj;

		private static GameObject warningObj;

		private static TextMeshProUGUI textmesh;

		private static Image frameImage;

		private static Image meterImage;

		private static Image warningImage;

		private static Sprite frame;

		private static Sprite meter;

		private static readonly Sprite warning = Plugin.bundle.LoadAsset<Sprite>("warning");

		public static Color UIColorHex;

		private static bool warningEnabled = Plugin.UIDisabledLowBatteryWarning.Value;

		private static float warningPercent = Plugin.LowBatteryWarningPercentage.Value;

		private static BatteryDisplayOptions selectedStyle;

		private static TextDisplayOptions selectedText;

		private static RechargeOptions selectedRecharge;

		private static float elemScale;

		public static bool isFlashlightHeld = false;

		public static bool isFlashlightPocketed = false;

		public static bool isFacilityPowered = true;

		public static float randomLightInterferenceMultiplier;

		private static float targetAlpha;

		private static float soundCd = 1f;

		private static float lastSoundTime = 0f;

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		internal static void MakeLightController()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			GameObject val = new GameObject("LightController");
			val.transform.SetParent(((Component)StartOfRound.Instance.localPlayerController).transform, false);
			val.AddComponent<LightScript>();
			StartOfRound.Instance.localPlayerController.nightVision.intensity = StartOfRound.Instance.localPlayerController.nightVision.intensity * ((float)Plugin.DarkVisionMult.Value / 100f);
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
		[HarmonyPostfix]
		internal static void DestroyLightController()
		{
			GameObject val = GameObject.Find("LightController");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
			TerminalApi.DeleteKeyword("LocalFlashlight");
		}

		[HarmonyPatch(typeof(HUDManager), "Awake")]
		[HarmonyPostfix]
		internal static void GetBatteryUI(ref HUDManager __instance)
		{
			selectedStyle = Plugin.BatteryDisplay.Value;
			selectedText = Plugin.TextDisplay.Value;
			warningEnabled = Plugin.UIDisabledLowBatteryWarning.Value;
			warningPercent = Plugin.LowBatteryWarningPercentage.Value;
			elemScale = Plugin.UIScale.Value;
			selectedRecharge = Plugin.rechargeOption.Value;
			isFacilityPowered = true;
			ColorUtility.TryParseHtmlString(Plugin.HUDColorHex.Value, ref UIColorHex);
			MakeIndicator(__instance);
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		internal static void UpdateBatteryInfo(ref HUDManager __instance)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: 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_0256: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)UIContainer == (Object)null)
			{
				MakeIndicator(__instance);
				return;
			}
			try
			{
				float batteryTime = LightScript.batteryTime;
				float num = Mathf.FloorToInt(batteryTime / 60f);
				float num2 = Mathf.FloorToInt(batteryTime % 60f);
				UIContainer.transform.localPosition = Vector2.op_Implicit(new Vector2(Plugin.UIPositionX.Value, Plugin.UIPositionY.Value));
				elemScale = Plugin.UIScale.Value;
				UIContainer.transform.localScale = new Vector3(elemScale, elemScale, elemScale);
				UIContainer.GetComponent<CanvasGroup>().alpha = Mathf.Lerp(UIContainer.GetComponent<CanvasGroup>().alpha, targetAlpha, Time.deltaTime * 6f);
				if ((selectedStyle == BatteryDisplayOptions.Percentage) | (selectedStyle == BatteryDisplayOptions.Bar) | (selectedStyle == BatteryDisplayOptions.VerticalBar) | (selectedStyle == BatteryDisplayOptions.CircularBar) | (selectedStyle == BatteryDisplayOptions.All))
				{
					targetAlpha = ((!Plugin.HideUI.Value) ? 1f : ((LightScript.UIHideTime < 0f) ? Plugin.UIHiddenAlpha.Value : 1f));
					if (selectedStyle != BatteryDisplayOptions.Percentage)
					{
						meterImage.fillAmount = LightScript.BatteryClamped;
					}
				}
				if (selectedStyle == BatteryDisplayOptions.Disabled)
				{
					UIContainer.SetActive(warningEnabled && LightScript.truePercentBattery <= warningPercent);
				}
				ColorUtility.TryParseHtmlString(Plugin.HUDColorHex.Value, ref UIColorHex);
				if ((Object)(object)frameObj != (Object)null && selectedStyle == BatteryDisplayOptions.Bar)
				{
					((Graphic)frameImage).color = UIColorHex;
				}
				if ((Object)(object)meterObj != (Object)null)
				{
					((Graphic)meterImage).color = UIColorHex;
				}
				if ((Object)(object)warningObj != (Object)null)
				{
					((Graphic)warningImage).color = UIColorHex;
					warningPercent = Plugin.LowBatteryWarningPercentage.Value;
					warningEnabled = Plugin.UIDisabledLowBatteryWarning.Value;
				}
				if ((Object)(object)textObj != (Object)null)
				{
					((Graphic)textmesh).color = UIColorHex;
				}
				if (!((selectedStyle == BatteryDisplayOptions.All) | (selectedStyle == BatteryDisplayOptions.Percentage)) || (Object)(object)textmesh == (Object)null)
				{
					return;
				}
				switch (selectedText)
				{
				case TextDisplayOptions.Percent:
					if (LightScript.batteryTime > 0f || LightScript.batteryTime < LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = LightScript.BatteryPercent + "%";
					}
					if (LightScript.batteryTime <= 0f)
					{
						((TMP_Text)textmesh).text = "0%";
					}
					if (LightScript.batteryTime >= LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = "100%";
					}
					break;
				case TextDisplayOptions.AccuratePercent:
					if (LightScript.batteryTime > 0f || LightScript.batteryTime < LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = LightScript.truePercentBattery.ToString("0.0") + "%";
					}
					if (LightScript.batteryTime <= 0f)
					{
						((TMP_Text)textmesh).text = "0.0%";
					}
					if (LightScript.batteryTime >= LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = "100.0%";
					}
					break;
				case TextDisplayOptions.Time:
					if (LightScript.batteryTime > 0f || LightScript.batteryTime < LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = $"{num:0}:{num2:00}";
					}
					if (LightScript.batteryTime <= 0f)
					{
						((TMP_Text)textmesh).text = "0:00";
					}
					if (LightScript.batteryTime >= LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = $"{Mathf.FloorToInt(LightScript.maxBatteryTime / 60f):0}:{Mathf.RoundToInt(LightScript.maxBatteryTime % 60f):00}";
					}
					break;
				case TextDisplayOptions.All:
					if (LightScript.batteryTime > 0f || LightScript.batteryTime < LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = LightScript.truePercentBattery.ToString("0.0") + "%" + $" | {num:0}:{num2:00}";
					}
					if (LightScript.batteryTime <= 0f)
					{
						((TMP_Text)textmesh).text = "0.0% | 0:00";
					}
					if (LightScript.batteryTime >= LightScript.maxBatteryTime)
					{
						((TMP_Text)textmesh).text = "100.0%" + $" | {Mathf.FloorToInt(LightScript.maxBatteryTime / 60f):0}:{Mathf.RoundToInt(LightScript.maxBatteryTime % 60f):00}";
					}
					break;
				}
			}
			catch (Exception arg)
			{
				Plugin.mls.LogError((object)$"error while updating hud!! is the light script even there?? is the hud even there????\n{arg}");
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")]
		[HarmonyPostfix]
		internal static void ReDisableHUD()
		{
			if (selectedRecharge == RechargeOptions.FacilityPowered)
			{
				UIContainer.SetActive(false);
			}
			isFacilityPowered = true;
			if (StartOfRound.Instance.localPlayerController.isPlayerDead)
			{
				StartOfRound.Instance.localPlayerController.pocketedFlashlight = null;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")]
		[HarmonyPostfix]
		internal static void FixValues()
		{
			isFlashlightHeld = false;
			isFlashlightPocketed = false;
			randomLightInterferenceMultiplier = Random.Range(0.1f, 0.4f);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		internal static void PocketedFlashlightChecks()
		{
			try
			{
				PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
				if ((!((NetworkBehaviour)localPlayerController).IsOwner || !localPlayerController.isPlayerControlled || (((NetworkBehaviour)localPlayerController).IsServer && !localPlayerController.isHostPlayerObject)) && !localPlayerController.isTestingPlayer)
				{
					return;
				}
				if (!localPlayerController.isPlayerDead)
				{
					if (localPlayerController.currentlyHeldObjectServer is FlashlightItem && (Object)(object)localPlayerController.currentlyHeldObjectServer != (Object)(object)localPlayerController.pocketedFlashlight)
					{
						localPlayerController.pocketedFlashlight = localPlayerController.currentlyHeldObjectServer;
					}
					if (!((Object)(object)localPlayerController.pocketedFlashlight == (Object)null))
					{
						if (localPlayerController.currentlyHeldObjectServer is FlashlightItem && localPlayerController.isHoldingObject && !localPlayerController.pocketedFlashlight.insertedBattery.empty)
						{
							isFlashlightHeld = true;
						}
						else
						{
							isFlashlightHeld = false;
						}
						if (localPlayerController.pocketedFlashlight is FlashlightItem && localPlayerController.pocketedFlashlight.isHeld && !localPlayerController.pocketedFlashlight.insertedBattery.empty)
						{
							isFlashlightPocketed = true;
						}
						else
						{
							isFlashlightPocketed = false;
						}
					}
				}
				else
				{
					localPlayerController.pocketedFlashlight = null;
					isFlashlightHeld = false;
					isFlashlightPocketed = false;
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
		[HarmonyPostfix]
		internal static void ClearLightA(ref PlayerControllerB __instance)
		{
			__instance.pocketedFlashlight = null;
			isFlashlightHeld = false;
			isFlashlightPocketed = false;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		internal static void ClearLightB()
		{
			isFlashlightHeld = false;
			isFlashlightPocketed = false;
		}

		[HarmonyPatch(typeof(RoundManager), "PowerSwitchOnClientRpc")]
		[HarmonyPostfix]
		private static void TurnOnFlashlightPower()
		{
			isFacilityPowered = true;
			if (selectedRecharge == RechargeOptions.FacilityPowered)
			{
				UIContainer.SetActive(!isFacilityPowered);
			}
			lastSoundTime = Time.time;
		}

		[HarmonyPatch(typeof(RoundManager), "PowerSwitchOffClientRpc")]
		[HarmonyPostfix]
		private static void TurnOffFlashlightPower()
		{
			isFacilityPowered = false;
			if (selectedRecharge == RechargeOptions.FacilityPowered)
			{
				UIContainer.SetActive(!isFacilityPowered);
				if (Time.time - lastSoundTime > soundCd)
				{
					LightScript.PlayNoise(LightScript.activeClips[6], 0.2f, playForWorld: false);
				}
			}
		}

		private static void MakeIndicator(HUDManager hudManager)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01e3: Expected O, but got Unknown
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: 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_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f1: Expected O, but got Unknown
			//IL_094f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0964: Unknown result type (might be due to invalid IL or missing references)
			//IL_0969: Unknown result type (might be due to invalid IL or missing references)
			//IL_0988: Unknown result type (might be due to invalid IL or missing references)
			//IL_098d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c7: Expected O, but got Unknown
			//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a67: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Expected O, but got Unknown
			//IL_0724: Unknown result type (might be due to invalid IL or missing references)
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Expected O, but got Unknown
			//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_082b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0830: Unknown result type (might be due to invalid IL or missing references)
			//IL_084f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0854: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Expected O, but got Unknown
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: 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_04cb: Expected O, but got Unknown
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Expected O, but got Unknown
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aeb: Expected O, but got Unknown
			//IL_0b2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b59: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				UIContainer = new GameObject("LocalFlashlightHUDElements", new Type[2]
				{
					typeof(RectTransform),
					typeof(CanvasGroup)
				});
				UIContainer.transform.SetParent(hudManager.HUDContainer.transform, false);
				UIContainer.transform.localPosition = Vector2.op_Implicit(new Vector2(Plugin.UIPositionX.Value, Plugin.UIPositionY.Value));
				UIContainer.transform.localScale = new Vector3(elemScale, elemScale, elemScale);
				switch (selectedStyle)
				{
				case BatteryDisplayOptions.Bar:
					frame = Plugin.bundle.LoadAsset<Sprite>("frame.png");
					meter = Plugin.bundle.LoadAsset<Sprite>("meter.png");
					frameObj = new GameObject("FrameHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					frameObj.transform.SetParent(UIContainer.transform, false);
					frameObj.GetComponent<RectTransform>();
					frameImage = frameObj.GetComponent<Image>();
					frameImage.sprite = frame;
					((Graphic)frameImage).color = UIColorHex;
					frameObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					frameObj.transform.localScale = Vector2.op_Implicit(new Vector2(1.5f, 1.25f));
					meterObj = new GameObject("MeterHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					meterObj.transform.SetParent(UIContainer.transform, false);
					meterObj.GetComponent<RectTransform>();
					meterImage = meterObj.GetComponent<Image>();
					meterImage.sprite = meter;
					((Graphic)meterImage).color = UIColorHex;
					meterImage.type = (Type)3;
					meterImage.fillMethod = (FillMethod)0;
					meterObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					meterObj.transform.localScale = Vector2.op_Implicit(new Vector2(1.5f, 1.25f));
					UIContainer.SetActive(selectedRecharge != RechargeOptions.FacilityPowered || !isFacilityPowered);
					frameObj.SetActive(true);
					meterObj.SetActive(true);
					break;
				case BatteryDisplayOptions.Percentage:
				{
					textmesh = UIContainer.AddComponent<TextMeshProUGUI>();
					RectTransform rectTransform = ((TMP_Text)textmesh).rectTransform;
					((Transform)rectTransform).SetParent(UIContainer.transform, false);
					((TMP_Text)textmesh).font = ((TMP_Text)hudManager.controlTipLines[0]).font;
					((Graphic)textmesh).color = UIColorHex;
					((TMP_Text)textmesh).fontSize = 23f;
					((TMP_Text)textmesh).overflowMode = (TextOverflowModes)0;
					((Behaviour)textmesh).enabled = true;
					((TMP_Text)textmesh).text = "";
					UIContainer.SetActive(selectedRecharge != RechargeOptions.FacilityPowered || !isFacilityPowered);
					break;
				}
				case BatteryDisplayOptions.All:
				{
					frame = Plugin.bundle.LoadAsset<Sprite>("meter.png");
					meter = Plugin.bundle.LoadAsset<Sprite>("meter.png");
					textObj = new GameObject("TextHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(TextMeshProUGUI)
					});
					textObj.transform.SetParent(UIContainer.transform, false);
					textObj.GetComponent<RectTransform>();
					textmesh = textObj.GetComponent<TextMeshProUGUI>();
					RectTransform rectTransform2 = ((TMP_Text)textmesh).rectTransform;
					((Transform)rectTransform2).SetParent(textObj.transform, false);
					((Transform)rectTransform2).localPosition = Vector2.op_Implicit(new Vector2(15f, 0f));
					((TMP_Text)textmesh).font = ((TMP_Text)hudManager.controlTipLines[0]).font;
					((Graphic)textmesh).color = UIColorHex;
					((TMP_Text)textmesh).fontSize = 20f;
					((TMP_Text)textmesh).overflowMode = (TextOverflowModes)0;
					((Behaviour)textmesh).enabled = true;
					((TMP_Text)textmesh).text = "";
					frameObj = new GameObject("FrameHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					frameObj.transform.SetParent(UIContainer.transform, false);
					frameObj.GetComponent<RectTransform>();
					frameImage = frameObj.GetComponent<Image>();
					frameImage.sprite = frame;
					((Graphic)frameImage).color = new Color(0f, 0f, 0f, 0.5f);
					frameObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					frameObj.transform.localScale = Vector2.op_Implicit(new Vector2(2.625f, 0.875f));
					meterObj = new GameObject("MeterHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					meterObj.transform.SetParent(UIContainer.transform, false);
					meterObj.GetComponent<RectTransform>();
					meterImage = meterObj.GetComponent<Image>();
					meterImage.sprite = meter;
					((Graphic)meterImage).color = UIColorHex;
					meterImage.type = (Type)3;
					meterImage.fillMethod = (FillMethod)0;
					meterObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					meterObj.transform.localScale = Vector2.op_Implicit(new Vector2(2.625f, 0.875f));
					UIContainer.SetActive(selectedRecharge != RechargeOptions.FacilityPowered || !isFacilityPowered);
					break;
				}
				case BatteryDisplayOptions.CircularBar:
					frame = Plugin.bundle.LoadAsset<Sprite>("meter2.png");
					meter = Plugin.bundle.LoadAsset<Sprite>("meter2.png");
					frameObj = new GameObject("FrameHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					frameObj.transform.SetParent(UIContainer.transform, false);
					frameObj.GetComponent<RectTransform>();
					frameImage = frameObj.GetComponent<Image>();
					frameImage.sprite = frame;
					((Graphic)frameImage).color = new Color(0f, 0f, 0f, 0.3f);
					frameObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					frameObj.transform.localScale = Vector2.op_Implicit(new Vector2(0.7f, 0.7f));
					meterObj = new GameObject("MeterHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					meterObj.transform.SetParent(UIContainer.transform, false);
					meterObj.GetComponent<RectTransform>();
					meterImage = meterObj.GetComponent<Image>();
					meterImage.sprite = meter;
					((Graphic)meterImage).color = UIColorHex;
					meterImage.type = (Type)3;
					meterImage.fillMethod = (FillMethod)4;
					meterImage.fillClockwise = false;
					meterImage.fillOrigin = 2;
					meterObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					meterObj.transform.localScale = Vector2.op_Implicit(new Vector2(0.7f, 0.7f));
					UIContainer.SetActive(selectedRecharge != RechargeOptions.FacilityPowered || !isFacilityPowered);
					frameObj.SetActive(true);
					meterObj.SetActive(true);
					break;
				case BatteryDisplayOptions.VerticalBar:
					frame = Plugin.bundle.LoadAsset<Sprite>("meter3.png");
					meter = Plugin.bundle.LoadAsset<Sprite>("meter3.png");
					frameObj = new GameObject("FrameHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					frameObj.transform.SetParent(UIContainer.transform, false);
					frameObj.GetComponent<RectTransform>();
					frameImage = frameObj.GetComponent<Image>();
					frameImage.sprite = frame;
					((Graphic)frameImage).color = new Color(0f, 0f, 0f, 0.5f);
					frameObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					frameObj.transform.localScale = Vector2.op_Implicit(new Vector2(1.25f, 3f));
					meterObj = new GameObject("MeterHUD", new Type[2]
					{
						typeof(RectTransform),
						typeof(Image)
					});
					meterObj.transform.SetParent(UIContainer.transform, false);
					meterObj.GetComponent<RectTransform>();
					meterImage = meterObj.GetComponent<Image>();
					meterImage.sprite = meter;
					((Graphic)meterImage).color = UIColorHex;
					meterImage.type = (Type)3;
					meterImage.fillMethod = (FillMethod)1;
					meterObj.transform.localPosition = Vector2.op_Implicit(Vector2.zero);
					meterObj.transform.localScale = Vector2.op_Implicit(new Vector2(1.25f, 3f));
					UIContainer.SetActive(selectedRecharge != RechargeOptions.FacilityPowered || !isFacilityPowered);
					frameObj.SetActive(true);
					meterObj.SetActive(true);
					break;
				case BatteryDisplayOptions.Disabled:
					if (warningEnabled)
					{
						warningObj = new GameObject("WarningHUD", new Type[2]
						{
							typeof(RectTransform),
							typeof(Image)
						});
						warningObj.transform.SetParent(UIContainer.transform, false);
						warningObj.GetComponent<RectTransform>();
						warningObj.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
						warningImage = warningObj.GetComponent<Image>();
						warningImage.sprite = warning;
						((Graphic)warningImage).color = UIColorHex;
					}
					UIContainer.SetActive(false);
					break;
				}
			}
			catch (Exception arg)
			{
				Plugin.mls.LogError((object)$"error while making the hud?\n{arg}");
			}
		}
	}
	public class ToggleButton : LcInputActions
	{
		[InputAction("<Keyboard>/f", Name = "Toggle key")]
		public InputAction toggleKey { get; set; }

		[InputAction("<Keyboard>/h", Name = "Position and angle switch key")]
		public InputAction switchLightPosKey { get; set; }

		[InputAction("<Keyboard>/q", Name = "Recharge key")]
		public InputAction rechargeKey { get; set; }
	}
	[BepInPlugin("command.localFlashlight", "LocalFlashlight", "1.4.13")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string VERSION = "1.4.13";

		public const string GUID = "command.localFlashlight";

		public const string NAME = "LocalFlashlight";

		public static AssetBundle bundle;

		internal static ToggleButton flashlightToggleInstance = new ToggleButton();

		private readonly Harmony har = new Harmony("command.localFlashlight");

		private static string sceneName;

		public static ConfigEntry<float> Intensity { get; private set; }

		public static ConfigEntry<float> Range { get; private set; }

		public static ConfigEntry<float> Angle { get; private set; }

		public static ConfigEntry<float> BatteryLife { get; private set; }

		public static ConfigEntry<float> RechargeMult { get; private set; }

		public static ConfigEntry<float> BurnOutCool { get; private set; }

		public static ConfigEntry<bool> BatteryBurnOut { get; private set; }

		public static ConfigEntry<float> BatteryCool { get; private set; }

		public static ConfigEntry<BatteryDisplayOptions> BatteryDisplay { get; private set; }

		public static ConfigEntry<TextDisplayOptions> TextDisplay { get; private set; }

		public static ConfigEntry<SoundOptions> soundOption { get; private set; }

		public static ConfigEntry<RechargeOptions> rechargeOption { get; private set; }

		public static ConfigEntry<bool> HideUI { get; private set; }

		public static ConfigEntry<float> HideUIDelay { get; private set; }

		public static ConfigEntry<float> UIScale { get; private set; }

		public static ConfigEntry<float> UIHiddenAlpha { get; private set; }

		public static ConfigEntry<bool> UIDisabledLowBatteryWarning { get; private set; }

		public static ConfigEntry<int> LowBatteryWarningPercentage { get; private set; }

		public static ConfigEntry<int> FlashVolume { get; private set; }

		public static ConfigEntry<float> UIPositionX { get; private set; }

		public static ConfigEntry<float> UIPositionY { get; private set; }

		public static ConfigEntry<bool> ShadowsEnabled { get; private set; }

		public static ConfigEntry<bool> soundAggros { get; private set; }

		public static ConfigEntry<bool> flashlightToggleModSynergyquestionmark { get; private set; }

		public static ConfigEntry<int> shakeStaminaConsume { get; private set; }

		public static ConfigEntry<float> shakeActionCooldown { get; private set; }

		public static ConfigEntry<float> apparaticeFlashlightIntensityMult { get; private set; }

		public static ConfigEntry<float> dynamoUseMoveMult { get; private set; }

		public static ConfigEntry<bool> dimEnabled { get; private set; }

		public static ConfigEntry<int> flashlightStopDimBatteryValue { get; private set; }

		public static ConfigEntry<bool> flickerOnBatteryBurn { get; private set; }

		public static ConfigEntry<bool> enableNetworking { get; private set; }

		public static ConfigEntry<string> flashlightColorHex { get; private set; }

		public static ConfigEntry<string> HUDColorHex { get; private set; }

		public static ConfigEntry<int> DarkVisionMult { get; private set; }

		public static ConfigEntry<bool> rechargeInOrbit { get; private set; }

		public static ManualLogSource mls { get; private set; }

		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Expected O, but got Unknown
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Expected O, but got Unknown
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Expected O, but got Unknown
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Expected O, but got Unknown
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Expected O, but got Unknown
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Expected O, but got Unknown
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Expected O, but got Unknown
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: 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_03bc: Expected O, but got Unknown
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Expected O, but got Unknown
			//IL_03ce: Expected O, but got Unknown
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Expected O, but got Unknown
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Expected O, but got Unknown
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Expected O, but got Unknown
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Expected O, but got Unknown
			//IL_0441: Expected O, but got Unknown
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Expected O, but got Unknown
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Expected O, but got Unknown
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Expected O, but got Unknown
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Expected O, but got Unknown
			//IL_04b4: Expected O, but got Unknown
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Expected O, but got Unknown
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Expected O, but got Unknown
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Expected O, but got Unknown
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Expected O, but got Unknown
			//IL_0527: Expected O, but got Unknown
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Expected O, but got Unknown
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Expected O, but got Unknown
			//IL_0570: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Expected O, but got Unknown
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Expected O, but got Unknown
			//IL_059a: Expected O, but got Unknown
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Expected O, but got Unknown
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Expected O, but got Unknown
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Expected O, but got Unknown
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Expected O, but got Unknown
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Expected O, but got Unknown
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Expected O, but got Unknown
			//IL_063a: Expected O, but got Unknown
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Expected O, but got Unknown
			//IL_0660: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Expected O, but got Unknown
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_067c: Expected O, but got Unknown
			//IL_068e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Expected O, but got Unknown
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Expected O, but got Unknown
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Expected O, but got Unknown
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Expected O, but got Unknown
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Expected O, but got Unknown
			//IL_0719: Unknown result type (might be due to invalid IL or missing references)
			//IL_071e: Unknown result type (might be due to invalid IL or missing references)
			//IL_072b: Expected O, but got Unknown
			//IL_0726: Unknown result type (might be due to invalid IL or missing references)
			//IL_0730: Expected O, but got Unknown
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Expected O, but got Unknown
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_076f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_077e: Expected O, but got Unknown
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Expected O, but got Unknown
			//IL_078d: Expected O, but got Unknown
			//IL_0788: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Expected O, but got Unknown
			//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Expected O, but got Unknown
			//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d9: Expected O, but got Unknown
			//IL_080c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0813: Expected O, but got Unknown
			//IL_0825: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Expected O, but got Unknown
			//IL_0832: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Expected O, but got Unknown
			//IL_0863: Unknown result type (might be due to invalid IL or missing references)
			//IL_0869: Expected O, but got Unknown
			//IL_0879: Unknown result type (might be due to invalid IL or missing references)
			//IL_0883: Expected O, but got Unknown
			//IL_08b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c8: Expected O, but got Unknown
			//IL_08c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cd: Expected O, but got Unknown
			//IL_08f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Expected O, but got Unknown
			//IL_0907: Unknown result type (might be due to invalid IL or missing references)
			//IL_090e: Expected O, but got Unknown
			//IL_0920: Unknown result type (might be due to invalid IL or missing references)
			//IL_092a: Expected O, but got Unknown
			//IL_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_094a: Expected O, but got Unknown
			//IL_0971: Unknown result type (might be due to invalid IL or missing references)
			//IL_0978: Expected O, but got Unknown
			//IL_098a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0994: Expected O, but got Unknown
			//IL_0997: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a1: Expected O, but got Unknown
			//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cf: Expected O, but got Unknown
			//IL_09e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09eb: Expected O, but got Unknown
			//IL_09ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f8: Expected O, but got Unknown
			//IL_0a1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Expected O, but got Unknown
			//IL_0a32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a46: Expected O, but got Unknown
			//IL_0a47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4f: Expected O, but got Unknown
			//IL_0a55: Expected O, but got Unknown
			//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5a: Expected O, but got Unknown
			//IL_0a81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a88: Expected O, but got Unknown
			//IL_0a9a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa4: Expected O, but got Unknown
			//IL_0aa7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab1: Expected O, but got Unknown
			//IL_0adc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af4: Expected O, but got Unknown
			//IL_0af5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b00: Expected O, but got Unknown
			//IL_0b06: Expected O, but got Unknown
			//IL_0b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0b: Expected O, but got Unknown
			//IL_0b36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4e: Expected O, but got Unknown
			//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5a: Expected O, but got Unknown
			//IL_0b60: Expected O, but got Unknown
			//IL_0b5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b65: Expected O, but got Unknown
			//IL_0b90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b95: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba8: Expected O, but got Unknown
			//IL_0ba9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb4: Expected O, but got Unknown
			//IL_0bba: Expected O, but got Unknown
			//IL_0bb5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbf: Expected O, but got Unknown
			//IL_0bdc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be6: Expected O, but got Unknown
			//IL_0bf1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bfe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c05: Expected O, but got Unknown
			//IL_0c06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c0e: Expected O, but got Unknown
			//IL_0c14: Expected O, but got Unknown
			//IL_0c0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c19: Expected O, but got Unknown
			//IL_0c44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5c: Expected O, but got Unknown
			//IL_0c5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c68: Expected O, but got Unknown
			//IL_0c6e: Expected O, but got Unknown
			//IL_0c69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c73: Expected O, but got Unknown
			//IL_0c9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca4: Expected O, but got Unknown
			//IL_0cb4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cbe: Expected O, but got Unknown
			//IL_0cd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce2: Expected O, but got Unknown
			//IL_0d09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d10: Expected O, but got Unknown
			//IL_0d22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d2c: Expected O, but got Unknown
			//IL_0d2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d39: Expected O, but got Unknown
			mls = ((BaseUnityPlugin)this).Logger;
			Intensity = ((BaseUnityPlugin)this).Config.Bind<float>("Flashlight", "Light intensity", 350f, new ConfigDescription("The intensity of the light (in lumens, i think)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 5000f), Array.Empty<object>()));
			ConfigEntry<float> intensity = Intensity;
			FloatInputFieldOptions val = new FloatInputFieldOptions();
			((BaseOptions)val).RequiresRestart = false;
			((BaseOptions)val).CanModifyCallback = new CanModifyDelegate(modifySpecialConfig);
			((BaseRangeOptions<float>)(object)val).Min = 10f;
			((BaseRangeOptions<float>)(object)val).Max = 5000f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(intensity, val));
			Range = ((BaseUnityPlugin)this).Config.Bind<float>("Flashlight", "Light range", 17f, new ConfigDescription("The range of the light (in units)", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<float> range = Range;
			val = new FloatInputFieldOptions();
			((BaseOptions)val).RequiresRestart = false;
			((BaseOptions)val).CanModifyCallback = new CanModifyDelegate(modifySpecialConfig);
			((BaseRangeOptions<float>)(object)val).Min = 1f;
			((BaseRangeOptions<float>)(object)val).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(range, val));
			Angle = ((BaseUnityPlugin)this).Config.Bind<float>("Flashlight", "Light angle", 55f, new ConfigDescription("The size of the light's circle (Spot angle)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>()));
			ConfigEntry<float> angle = Angle;
			val = new FloatInputFieldOptions();
			((BaseOptions)val).RequiresRestart = false;
			((BaseOptions)val).CanModifyCallback = new CanModifyDelegate(modifySpecialConfig);
			((BaseRangeOptions<float>)(object)val).Min = 1f;
			((BaseRangeOptions<float>)(object)val).Max = 120f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(angle, val));
			BatteryLife = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "Battery life", 12f, new ConfigDescription("The battery life of the flashlight (in seconds)", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<float> batteryLife = BatteryLife;
			val = new FloatInputFieldOptions();
			((BaseOptions)val).RequiresRestart = false;
			((BaseOptions)val).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			((BaseRangeOptions<float>)(object)val).Min = 1f;
			((BaseRangeOptions<float>)(object)val).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(batteryLife, val));
			RechargeMult = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "Recharge Multiplier", 0.8f, new ConfigDescription("The flashlight's battery recharge multiplier (For instance, setting it to 1 will make it recharge at about the same rate that it is depleted when using the Time recharge method, however this config also applies to other recharge methods)", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<float> rechargeMult = RechargeMult;
			val = new FloatInputFieldOptions();
			((BaseOptions)val).RequiresRestart = false;
			((BaseOptions)val).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			((BaseRangeOptions<float>)(object)val).Min = 0f;
			((BaseRangeOptions<float>)(object)val).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(rechargeMult, val));
			BatteryDisplay = ((BaseUnityPlugin)this).Config.Bind<BatteryDisplayOptions>("Indicator", "Battery Details", BatteryDisplayOptions.Bar, "How the indicator displays the flashlight's remaining battery time");
			ConfigEntry<BatteryDisplayOptions> batteryDisplay = BatteryDisplay;
			EnumDropDownOptions val2 = new EnumDropDownOptions();
			((BaseOptions)val2).RequiresRestart = false;
			((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<BatteryDisplayOptions>(batteryDisplay, val2));
			TextDisplay = ((BaseUnityPlugin)this).Config.Bind<TextDisplayOptions>("Indicator", "Battery text display", TextDisplayOptions.Percent, "(Only applies to \"Text\" and \"All\" indicator display options) Wherether the mod should display the battery information text in percents, accurate percents or time left");
			ConfigEntry<TextDisplayOptions> textDisplay = TextDisplay;
			val2 = new EnumDropDownOptions();
			((BaseOptions)val2).RequiresRestart = false;
			((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<TextDisplayOptions>(textDisplay, val2));
			HideUI = ((BaseUnityPlugin)this).Config.Bind<bool>("Indicator", "Indicator fading", true, "When true, the indicator will hide after a while of not using the flashlight");
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(HideUI, new BoolCheckBoxOptions
			{
				RequiresRestart = false
			}));
			HideUIDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Indicator", "Battery indicator fade delay", 1.5f, new ConfigDescription("The delay before fading out the indicator (in seconds)", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<float> hideUIDelay = HideUIDelay;
			FloatInputFieldOptions val3 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val3).Min = 0f;
			((BaseRangeOptions<float>)val3).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(hideUIDelay, val3));
			UIHiddenAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("Indicator", "Indicator faded out opacity", 0.2f, new ConfigDescription("The opacity of the indicator when the indicator is faded out", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ConfigEntry<float> uIHiddenAlpha = UIHiddenAlpha;
			FloatInputFieldOptions val4 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val4).Min = 0f;
			((BaseRangeOptions<float>)val4).Max = 1f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(uIHiddenAlpha, val4));
			UIScale = ((BaseUnityPlugin)this).Config.Bind<float>("Indicator", "Indicator scale", 1f, new ConfigDescription("The scale of the indicator, updates in-game", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			ConfigEntry<float> uIScale = UIScale;
			FloatInputFieldOptions val5 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val5).Min = 0.1f;
			((BaseRangeOptions<float>)val5).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(uIScale, val5));
			UIPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("Indicator", "IndicatorPositionX", 350f, new ConfigDescription("The position of the UI on the X axis, updates in-game", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-450f, 450f), Array.Empty<object>()));
			ConfigEntry<float> uIPositionX = UIPositionX;
			FloatSliderOptions val6 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val6).Min = -450f;
			((BaseRangeOptions<float>)val6).Max = 450f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(uIPositionX, val6));
			UIPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("Indicator", "IndicatorPositionY", -150f, new ConfigDescription("The position of the UI on the Y axis, updates in-game", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-280f, 280f), Array.Empty<object>()));
			ConfigEntry<float> uIPositionY = UIPositionY;
			FloatSliderOptions val7 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val7).Min = -280f;
			((BaseRangeOptions<float>)val7).Max = 280f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(uIPositionY, val7));
			UIDisabledLowBatteryWarning = ((BaseUnityPlugin)this).Config.Bind<bool>("Indicator", "Low Battery Warning Toggle", true, "(Only applies to when the indicator is disabled) When true, shows a warning on the HUD when the battery reaches a certain percentage");
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(UIDisabledLowBatteryWarning, new BoolCheckBoxOptions
			{
				RequiresRestart = false
			}));
			LowBatteryWarningPercentage = ((BaseUnityPlugin)this).Config.Bind<int>("Indicator", "Low Battery Warning Percentage", 30, new ConfigDescription("(Only applies when the indicator is disabled) The percentage at which the low battery warning shows up", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ConfigEntry<int> lowBatteryWarningPercentage = LowBatteryWarningPercentage;
			IntInputFieldOptions val8 = new IntInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val8).Min = 0;
			((BaseRangeOptions<int>)val8).Max = 100;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(lowBatteryWarningPercentage, val8));
			flashlightColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Flashlight Color (Hex)", "#FFFFFF", new ConfigDescription("very important, add the # before the hex! if it breaks or doesn't work, try resetting the config and typing the code in manually", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<string> obj = flashlightColorHex;
			TextInputFieldOptions val9 = new TextInputFieldOptions();
			((BaseOptions)val9).RequiresRestart = false;
			((BaseOptions)val9).CanModifyCallback = new CanModifyDelegate(modifySpecialConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(obj, val9));
			HUDColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Indicator Color (Hex)", "#FFFFFF", new ConfigDescription("very important, add the # before the hex! if it breaks or doesn't work, try resetting the config and typing the code in manually", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(HUDColorHex, new TextInputFieldOptions
			{
				RequiresRestart = false
			}));
			flashlightToggleModSynergyquestionmark = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Prioritize flashlights in player inventory", true, "Setting this to true will prevent the light turning on while you have a flashlight in your inventory, however the local flashlight can still be turned off in case you picked up an active flashlight");
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(flashlightToggleModSynergyquestionmark, new BoolCheckBoxOptions
			{
				RequiresRestart = false
			}));
			FlashVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Other", "Flashlight volume", 50, new ConfigDescription("Volume of all of the sounds that the flashlight makes. Does not apply to how well others can hear it.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ConfigEntry<int> flashVolume = FlashVolume;
			IntSliderOptions val10 = new IntSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val10).Min = 0;
			((BaseRangeOptions<int>)val10).Max = 100;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(flashVolume, val10));
			soundOption = ((BaseUnityPlugin)this).Config.Bind<SoundOptions>("Other", "Sound options", SoundOptions.InGameFlashlight, "The flashlight has different sounds depending on what you chose. Does not apply to other players if you have networking enabled.");
			ConfigEntry<SoundOptions> obj2 = soundOption;
			val2 = new EnumDropDownOptions();
			((BaseOptions)val2).RequiresRestart = false;
			((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<SoundOptions>(obj2, val2));
			ShadowsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable shadows", true, "When set to true, the light will also emit shadows");
			ConfigEntry<bool> shadowsEnabled = ShadowsEnabled;
			BoolCheckBoxOptions val11 = new BoolCheckBoxOptions();
			((BaseOptions)val11).RequiresRestart = false;
			((BaseOptions)val11).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(shadowsEnabled, val11));
			rechargeOption = ((BaseUnityPlugin)this).Config.Bind<RechargeOptions>("Other", "Recharge method", RechargeOptions.Time, "The way that the flashlight can be recharged. Time, Shake and Dynamo are intended for shorter battery times while FacilityPowered and ShipRecharge are intended for longer battery times");
			ConfigEntry<RechargeOptions> obj3 = rechargeOption;
			val2 = new EnumDropDownOptions();
			((BaseOptions)val2).RequiresRestart = false;
			((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<RechargeOptions>(obj3, val2));
			rechargeInOrbit = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Fully recharge in orbit", true, "When set to true, fully recharges the flashlight when reaching orbit (when the round ends)");
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(rechargeInOrbit, new BoolCheckBoxOptions
			{
				RequiresRestart = false
			}));
			DarkVisionMult = ((BaseUnityPlugin)this).Config.Bind<int>("Other", "Ambient light intensity multiplier", 100, new ConfigDescription("Sets the multiplier of the ambient light. Useful if you feel like forcing yourself to use the flashlight more", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ConfigEntry<int> darkVisionMult = DarkVisionMult;
			IntSliderOptions val12 = new IntSliderOptions();
			((BaseOptions)val12).RequiresRestart = false;
			((BaseOptions)val12).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			((BaseRangeOptions<int>)(object)val12).Min = 0;
			((BaseRangeOptions<int>)(object)val12).Max = 100;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(darkVisionMult, val12));
			flickerOnBatteryBurn = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable light flickering", true, "When true, the flashlight attempts to flicker like the in-game flashlights, and also flickers when its battery runs out");
			ConfigEntry<bool> obj4 = flickerOnBatteryBurn;
			val11 = new BoolCheckBoxOptions();
			((BaseOptions)val11).RequiresRestart = false;
			((BaseOptions)val11).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(obj4, val11));
			dimEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable light dimming", false, "When true, the intensity of the light dims down to a certain point");
			ConfigEntry<bool> obj5 = dimEnabled;
			val11 = new BoolCheckBoxOptions();
			((BaseOptions)val11).RequiresRestart = false;
			((BaseOptions)val11).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(obj5, val11));
			flashlightStopDimBatteryValue = ((BaseUnityPlugin)this).Config.Bind<int>("Other", "Minimum battery amount dim", 15, new ConfigDescription("The battery percentage at which the light stops dimming", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ConfigEntry<int> obj6 = flashlightStopDimBatteryValue;
			IntInputFieldOptions val13 = new IntInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val13).Min = 0;
			((BaseRangeOptions<int>)val13).Max = 100;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(obj6, val13));
			BatteryBurnOut = ((BaseUnityPlugin)this).Config.Bind<bool>("Time battery recharge configs", "Battery burnout", true, "When true, if the flashlight turns off with no battery left, the cooldown before starting to recharge lasts longer");
			ConfigEntry<bool> batteryBurnOut = BatteryBurnOut;
			val11 = new BoolCheckBoxOptions();
			((BaseOptions)val11).RequiresRestart = false;
			((BaseOptions)val11).CanModifyCallback = new CanModifyDelegate(modifyConfig);
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(batteryBurnOut, val11));
			BatteryCool = ((BaseUnityPlugin)this).Config.Bind<float>("Time battery recharge configs", "Battery recharge cooldown", 1f, "The cooldown before the battery starts recharging normally");
			ConfigEntry<float> batteryCool = BatteryCool;
			FloatInputFieldOptions val14 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val14).Min = 0f;
			((BaseRangeOptions<float>)val14).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(batteryCool, val14));
			BurnOutCool = ((BaseUnityPlugin)this).Config.Bind<float>("Time battery recharge configs", "Battery recharge cooldown (no battery)", 3f, "The cooldown before the battery starts recharging when it is fully depleted");
			ConfigEntry<float> burnOutCool = BurnOutCool;
			FloatInputFieldOptions val15 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val15).Min = 0f;
			((BaseRangeOptions<float>)val15).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(burnOutCool, val15));
			shakeActionCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Shake battery recharge configs", "Shake cooldown", 0.2f, "The time needed to wait before you can recharge the flashlight again via shaking it");
			ConfigEntry<float> obj7 = shakeActionCooldown;
			FloatInputFieldOptions val16 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val16).Min = 0f;
			((BaseRangeOptions<float>)val16).Max = float.PositiveInfinity;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(obj7, val16));
			shakeStaminaConsume = ((BaseUnityPlugin)this).Config.Bind<int>("Shake battery recharge configs", "Consumed stamina amount", 3, new ConfigDescription("The amount of stamina shaking the flashlight consumes", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigEntry<int> obj8 = shakeStaminaConsume;
			IntInputFieldOptions val17 = new IntInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<int>)val17).Min = 0;
			((BaseRangeOptions<int>)val17).Max = 100;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(obj8, val17));
			dynamoUseMoveMult = ((BaseUnityPlugin)this).Config.Bind<float>("Dynamo battery recharge configs", "Movespeed multiplier when recharging", 0.75f, "The multiplier of the player's normal movement speed while recharging the flashlight");
			ConfigEntry<float> obj9 = dynamoUseMoveMult;
			FloatInputFieldOptions val18 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val18).Min = 0f;
			((BaseRangeOptions<float>)val18).Max = 1f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(obj9, val18));
			apparaticeFlashlightIntensityMult = ((BaseUnityPlugin)this).Config.Bind<float>("Facility powered battery recharge configs", "Light intensity multiplier", 0.5f, "The multiplier of the light intensity when using the Facility Powered recharge option");
			ConfigEntry<float> obj10 = apparaticeFlashlightIntensityMult;
			val = new FloatInputFieldOptions();
			((BaseOptions)val).RequiresRestart = false;
			((BaseOptions)val).CanModifyCallback = new CanModifyDelegate(modifySpecialConfig);
			((BaseRangeOptions<float>)(object)val).Min = 0f;
			((BaseRangeOptions<float>)(object)val).Max = 1f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(obj10, val));
			enableNetworking = ((BaseUnityPlugin)this).Config.Bind<bool>("Networking", "(EXPERIMENTAL) Enable networking", false, "Enables networking. While this is enabled, you cannot join other servers without this mod and its networking also enabled. However, you can see other players' lights (alongside the intensity, range, angle and color they set) and hear their flashlight sounds");
			ConfigEntry<bool> obj11 = enableNetworking;
			val11 = new BoolCheckBoxOptions();
			((BaseOptions)val11).RequiresRestart = true;
			((BaseOptions)val11).CanModifyCallback = new CanModifyDelegate(denyNetworkConfigModify);
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(obj11, val11));
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "localbundle");
			bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)bundle == (Object)null)
			{
				mls.LogError((object)"failed to get mod assets!");
			}
			SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
			har.PatchAll(typeof(Patches));
			if (enableNetworking.Value)
			{
				mls.LogWarning((object)"NETWORKING ENABLED!!!! this is EXPERIMENTAL territory, and you're pretty much stuck joining servers where the host has LocalFlashlight and also has networking enabled! you may also encounter many many bugs!!!!! if you didn't mean to have this enabled, go back to the mod manager of your choice, disable the enable networking config that resides in the Networking category, and then restart the game.");
				har.PatchAll(typeof(NetworkingPatches));
				NetcodePatcher();
			}
			else
			{
				mls.LogInfo((object)"Networking disabled");
			}
		}

		private static void SceneManager_activeSceneChanged(Scene arg0, Scene arg1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			sceneName = ((Scene)(ref activeScene)).name;
		}

		private static CanModifyResult modifyConfig()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			return CanModifyResult.op_Implicit((sceneName == "MainMenu", "This setting cannot be changed while in a lobby."));
		}

		private static CanModifyResult denyNetworkConfigModify()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			return CanModifyResult.op_Implicit((false, "Enabling or disabling networking cannot be done while the game is open.\nEdit it from your mod manager of choice instead."));
		}

		private static CanModifyResult modifySpecialConfig()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (enableNetworking.Value)
			{
				return CanModifyResult.op_Implicit((sceneName == "MainMenu", "Setting cannot be changed while in a lobby when networking is enabled."));
			}
			return CanModifyResult.op_Implicit((true, "?"));
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace LocalFlashlight.Networking
{
	public class LFNetworkHandler : NetworkBehaviour
	{
		public static LFNetworkHandler Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				LFNetworkHandler instance = Instance;
				if (instance != null)
				{
					((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestAllLightsUpdateServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4188426817u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4188426817u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					Plugin.mls.LogInfo((object)"Recieved request to update lights on all clients!!");
					AcceptAllLightUpdateRequestClientRpc();
				}
			}
		}

		[ClientRpc]
		public void AcceptAllLightUpdateRequestClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4106604540u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4106604540u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Plugin.mls.LogInfo((object)"Updating local light for all clients!");
					Color color = default(Color);
					ColorUtility.TryParseHtmlString(Plugin.flashlightColorHex.Value, ref color);
					MakeLightServerRpc(StartOfRound.Instance.localPlayerController.playerClientId, color, Plugin.Intensity.Value, Plugin.Range.Value, Plugin.Angle.Value, LightScript.publicFlashState);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void MakeLightServerRpc(ulong clientId, Color color, float intensity, float range, float angle, bool currentState)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be du