using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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("DimmingFlashlights")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DimmingFlashlights")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7df24742-83f2-4c85-a18b-1ad842eb3e5e")]
[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 DimmingFlashlights;
[BepInPlugin("Blink.DimmingFlashlights", "DimmingFlashlights", "1.0.1")]
public class DimmingFlashlights : BaseUnityPlugin
{
private const string modGUID = "Blink.DimmingFlashlights";
private const string modName = "DimmingFlashlights";
private const string modVersion = "1.0.1";
private readonly Harmony harmony = new Harmony("Blink.DimmingFlashlights");
private void Awake()
{
harmony.PatchAll();
}
}
[HarmonyPatch(typeof(FlashlightItem))]
internal class FlashlightItemPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void dimFlashlight(ref FlashlightItem __instance)
{
float val = Mathf.Lerp(0f, 1f, ((GrabbableObject)__instance).insertedBattery.charge / 0.6f);
val = Math.Max(val, 0.15f);
Light flashlightBulb = __instance.flashlightBulb;
flashlightBulb.intensity *= val;
}
}