Decompiled source of Flashlightier LC v1.0.0

plugins/Flashlightier_LC.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FlashlightierLC;
using FlashlightierLC.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("LethalCompanyModding")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows modifying various values of the flashlight/pro flashlight")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d041535a9fb1dd11420889b0ef5ddf96958b489e")]
[assembly: AssemblyProduct("Flashlightier_LC")]
[assembly: AssemblyTitle("dev.mamallama.lcmod.flashlightier")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/RobynLlama/Flashlightier-LC")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("dev.mamallama.lcmod.flashlightier", "Flashlightier_LC", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static FlashlightConfig Flashlights;

	private void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"Plugin Flashlightier_LC is loaded!");
		Flashlights = new FlashlightConfig(((BaseUnityPlugin)this).Config);
		Harmony val = new Harmony("dev.mamallama.lcmod.flashlightier");
		val.PatchAll(typeof(FlashLightItem_Patches));
		val.PatchAll(typeof(PlayerControllerB_Patches));
	}
}
internal static class LCMPluginInfo
{
	public const string PLUGIN_GUID = "dev.mamallama.lcmod.flashlightier";

	public const string PLUGIN_NAME = "Flashlightier_LC";

	public const string PLUGIN_VERSION = "1.0.0";
}
namespace FlashlightierLC
{
	internal class FlashlightConfig
	{
		internal class FlashlightDefinition
		{
			public readonly ConfigEntry<bool> Enabled;

			public readonly ConfigEntry<int> ColorTemp;

			public readonly ConfigEntry<float> Intensity;

			public readonly ConfigEntry<float> Size;

			internal FlashlightDefinition(ConfigEntry<bool> Enabled, ConfigEntry<int> ColorTemp, ConfigEntry<float> Intensity, ConfigEntry<float> Size)
			{
				this.Enabled = Enabled;
				this.ColorTemp = ColorTemp;
				this.Intensity = Intensity;
				this.Size = Size;
			}
		}

		public readonly FlashlightDefinition SmallFlashlight;

		public readonly FlashlightDefinition ProFlashlight;

		internal FlashlightConfig(ConfigFile Config)
		{
			SmallFlashlight = new FlashlightDefinition(Config.Bind<bool>("SmallFlash", "ReplaceEnabled", false, "Is this mod enabled for small flashlights?"), Config.Bind<int>("SmallFlash", "Color", 4678, "The temperature color of the light's beam.\n  2700 is a very warm orange\n  4650 is the in-game weak flashlight\n  5000-6500 is roughly daylight or a fluorescent light\n  8000 is the in-game pro flashlight "), Config.Bind<float>("SmallFlash", "Intensity", 397f, "The light's intensity.\nIf you have sensitive eyes lowering this to 275 can help"), Config.Bind<float>("SmallFlash", "Size", 55.4f, "The width of the beam as an angle."));
			ProFlashlight = new FlashlightDefinition(Config.Bind<bool>("ProFlash", "ReplaceEnabled", false, "Is this mod enabled for pro flashlights?"), Config.Bind<int>("ProFlash", "Color", 8088, "The temperature color of the light's beam.\n  2700 is a very warm orange\n  4650 is the in-game weak flashlight\n  5000-6500 is roughly daylight or a fluorescent light\n  8000 is the in-game pro flashlight "), Config.Bind<float>("ProFlash", "Intensity", 486f, "The light's intensity.\nIf you have sensitive eyes lowering this to 275 can help"), Config.Bind<float>("ProFlash", "Size", 73f, "The width of the beam as an angle."));
		}
	}
	internal static class LightExt
	{
		internal static void ModifyLight(this Light self, FlashlightConfig.FlashlightDefinition def)
		{
			if (def.Enabled.Value)
			{
				self.colorTemperature = def.ColorTemp.Value;
				self.intensity = def.Intensity.Value;
				self.spotAngle = def.Size.Value;
			}
		}

		internal static void ModifyFlashlight(this FlashlightItem self, FlashlightConfig.FlashlightDefinition def)
		{
			if (def.Enabled.Value)
			{
				self.initialIntensity = def.Intensity.Value;
				self.flashlightBulb.ModifyLight(def);
			}
		}
	}
}
namespace FlashlightierLC.Patches
{
	public class FlashLightItem_Patches
	{
		[HarmonyPatch(typeof(FlashlightItem), "Start")]
		[HarmonyPostfix]
		public static void OnStart(FlashlightItem __instance)
		{
			switch (__instance.flashlightTypeID)
			{
			case 0:
				__instance.ModifyFlashlight(Plugin.Flashlights.ProFlashlight);
				break;
			case 1:
				__instance.ModifyFlashlight(Plugin.Flashlights.SmallFlashlight);
				break;
			}
		}
	}
	public class PlayerControllerB_Patches
	{
		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPostfix]
		public static void OnStart(PlayerControllerB __instance)
		{
			__instance.allHelmetLights[0].ModifyLight(Plugin.Flashlights.ProFlashlight);
			__instance.allHelmetLights[1].ModifyLight(Plugin.Flashlights.SmallFlashlight);
		}
	}
}