Decompiled source of Infinite Flashlight v1.0.1

InfiniteFlashlight.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using InfiniteFlashlight.Patches;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("InfiniteFlashlight")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InfiniteFlashlight")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e4fd6b08-428c-4acf-bf71-c59dccf44d71")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace InfiniteFlashlight
{
	[BepInPlugin("Hades.InfiniteFlashlight", "Infinite Flashlight", "1.0.1")]
	public class InfiniteFlashlightBase : BaseUnityPlugin
	{
		private const string modGUID = "Hades.InfiniteFlashlight";

		private const string modName = "Infinite Flashlight";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("Hades.InfiniteFlashlight");

		private static InfiniteFlashlightBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Hades.InfiniteFlashlight");
			mls.LogInfo((object)"The test mod has awaken :)");
			harmony.PatchAll(typeof(InfiniteFlashlightBase));
			harmony.PatchAll(typeof(FlashlightItemPatch));
		}
	}
}
namespace InfiniteFlashlight.Patches
{
	[HarmonyPatch(typeof(FlashlightItem))]
	internal class FlashlightItemPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void InfiniteFlashlightPatch(FlashlightItem __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && ((NetworkBehaviour)__instance).IsOwner && ((GrabbableObject)__instance).isBeingUsed && ((GrabbableObject)__instance).itemProperties.requiresBattery && ((GrabbableObject)__instance).insertedBattery.charge > 0f && !((GrabbableObject)__instance).itemProperties.itemIsTrigger)
			{
				Battery insertedBattery = ((GrabbableObject)__instance).insertedBattery;
				insertedBattery.charge += Time.deltaTime / ((GrabbableObject)__instance).itemProperties.batteryUsage;
			}
		}
	}
}