Decompiled source of FlashlightExtendedRange v1.1.3

ExtendedFlashlightRange.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExtendedFlashlightRange.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("ExtendedFlashlightRange")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("The mod for the game flew a company that increases the radius of the lamps (works on the yellow and green lantern).")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d7aff02f4ddb3f37677c98f827c4e78350787113")]
[assembly: AssemblyProduct("ExtendedFlashlightRange")]
[assembly: AssemblyTitle("ExtendedFlashlightRange")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExtendedFlashlightRange
{
	[BepInPlugin("PC_Principal.ExtendedFlashlightRangeMod", "Extended Flashlight Range Mod", "1.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ExtendedFlashlightRangeModBase : BaseUnityPlugin
	{
		private const string modGUID = "PC_Principal.ExtendedFlashlightRangeMod";

		private const string modName = "Extended Flashlight Range Mod";

		private const string modVersion = "1.1.3";

		private readonly Harmony harmony = new Harmony("PC_Principal.ExtendedFlashlightRangeMod");

		private static ExtendedFlashlightRangeModBase Instance;

		internal ManualLogSource log_journal;

		public static ConfigEntry<float> FlashlightIntensity;

		public static ConfigEntry<float> FlashlightRange;

		public static ConfigEntry<float> HelmetIntensity;

		public static ConfigEntry<float> HelmetRange;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			log_journal = Logger.CreateLogSource("PC_Principal.ExtendedFlashlightRangeMod");
			log_journal.LogInfo((object)"Extended Flashlight Range Mod initiate started: v1.1.3");
			InitializeConfig();
			try
			{
				harmony.PatchAll(typeof(ExtendedFlashlightRangeModBase));
				harmony.PatchAll(typeof(FlashlightPatch));
				harmony.PatchAll(typeof(PlayerControllerBPatch));
				log_journal.LogInfo((object)"Extended Flashlight Range Mod harmony patch successfull");
			}
			catch
			{
				log_journal.LogError((object)"Extended Flashlight Range Mod: Error while harmony patching");
			}
		}

		private void InitializeConfig()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00ca: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0101: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_0138: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_016f: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			float num = 2000f;
			float num2 = 500f;
			float num3 = 2500f;
			float num4 = 800f;
			FlashlightIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Flashlight", "Intensity", num, "Flashlight Intensity");
			FlashlightRange = ((BaseUnityPlugin)this).Config.Bind<float>("Flashlight", "Range", num2, "Flashlight Range");
			HelmetIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Helmet", "Intensity", num3, "Helmet Intensity");
			HelmetRange = ((BaseUnityPlugin)this).Config.Bind<float>("Helmet", "Range", num4, "Helmet Range");
			ConfigEntry<float> flashlightIntensity = FlashlightIntensity;
			FloatSliderOptions val = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val).Min = 0f;
			((BaseRangeOptions<float>)val).Max = num * 2f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(flashlightIntensity, val));
			ConfigEntry<float> flashlightRange = FlashlightRange;
			FloatSliderOptions val2 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val2).Min = 0f;
			((BaseRangeOptions<float>)val2).Max = num2 * 2f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(flashlightRange, val2));
			ConfigEntry<float> helmetIntensity = HelmetIntensity;
			FloatSliderOptions val3 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val3).Min = 0f;
			((BaseRangeOptions<float>)val3).Max = num3 * 2f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(helmetIntensity, val3));
			ConfigEntry<float> helmetRange = HelmetRange;
			FloatSliderOptions val4 = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val4).Min = 0f;
			((BaseRangeOptions<float>)val4).Max = num4 * 2f;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(helmetRange, val4));
			LethalConfigManager.SetModDescription("Configurable helmet and flashlights range and intensity - as you asked, for the Company! Pls star it on githab repo :3");
			Sprite modIcon = ModInfo.GetModIcon();
			if ((Object)(object)modIcon != (Object)null)
			{
				LethalConfigManager.SetModIcon(modIcon);
			}
		}
	}
	public static class ModInfo
	{
		public static Sprite GetModIcon()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			Assembly assembly = typeof(ModInfo).Assembly;
			using Stream stream = assembly.GetManifestResourceStream("ExtendedFlashlightRange.thunderstore_package.icon.png");
			if (stream == null)
			{
				Debug.LogWarning((object)"Icon not found in resources");
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ExtendedFlashlightRange";

		public const string PLUGIN_NAME = "ExtendedFlashlightRange";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ExtendedFlashlightRange.Patches
{
	[HarmonyPatch(typeof(FlashlightItem))]
	internal class FlashlightPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchIntensityUpdate(ref FlashlightItem __instance)
		{
			if ((Object)(object)__instance.flashlightBulb != (Object)null)
			{
				__instance.flashlightBulb.intensity = ExtendedFlashlightRangeModBase.FlashlightIntensity.Value;
				__instance.flashlightBulb.range = ExtendedFlashlightRangeModBase.FlashlightRange.Value;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchIntensityUpdate(ref PlayerControllerB __instance)
		{
			if ((Object)(object)__instance.helmetLight != (Object)null)
			{
				__instance.helmetLight.intensity = ExtendedFlashlightRangeModBase.HelmetIntensity.Value;
				__instance.helmetLight.range = ExtendedFlashlightRangeModBase.HelmetRange.Value;
			}
		}
	}
}