using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BiggerBattery")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BiggerBattery")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1BFEAD94-08B6-4FCB-88CA-11E8762E4A12")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BiggerBattery
{
public static class ConfigSettings
{
public static ConfigEntry<float> FlashlightBatteryUsage;
public static ConfigEntry<float> ProFlashlightBatteryUsage;
public static ConfigEntry<float> LaserPointerBatteryUsage;
public static ConfigEntry<float> WalkieTalkieBatteryUsage;
public static ConfigEntry<float> JetpackBatteryUsage;
public static ConfigEntry<float> PatcherToolBatteryUsage;
public static ConfigEntry<float> BoomboxItemBatteryUsage;
public static void Init()
{
FlashlightBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("BiggerBattery", "FlashlightBatteryUsage", 300f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 140)");
ProFlashlightBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("BiggerBattery", "ProFlashlightBatteryUsage", 600f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 300)");
LaserPointerBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("BiggerBattery", "LaserPointerBatteryUsage", 450f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 300)");
WalkieTalkieBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("BiggerBattery", "WalkieTalkieBatteryUsage", 1500f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 820)");
JetpackBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("BiggerBattery", "JetpackBatteryUsage", 140f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 60)");
PatcherToolBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("BiggerBattery", "PatcherToolBatteryUsage", 66f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 22)");
BoomboxItemBatteryUsage = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("BiggerBattery", "BoomboxItemBatteryUsage", 600f, "The battery usage per update. The lower the value, the shorter the battery life. (Game Default: 350)");
}
}
public enum FlashlightType
{
ProFlashlight,
Flashlight,
LaserPointer
}
[BepInPlugin("dev.alexanderdiaz.biggerbattery", "Bigger Battery", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
private const string ModGuid = "dev.alexanderdiaz.biggerbattery";
private const string ModName = "Bigger Battery";
private const string ModVersion = "1.0.2";
private readonly Harmony _harmony = new Harmony("dev.alexanderdiaz.biggerbattery");
public static Plugin Instance;
private void Awake()
{
Instance = this;
_harmony.PatchAll();
ConfigSettings.Init();
Log("Plugin Bigger Battery-1.0.2 loaded!");
}
public static void Log(string message)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
}
}
public class PluginInfo
{
public const string PLUGIN_GUID = "dev.alexanderdiaz.biggerbattery";
public const string PLUGIN_NAME = "Bigger Battery";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace BiggerBattery.Patches
{
[HarmonyPatch(typeof(FlashlightItem))]
internal class FlashlightItemPatch
{
[HarmonyPatch("ItemActivate")]
[HarmonyPrefix]
private static void ModifyFlashlightBatteryUsage(ref FlashlightItem __instance)
{
FlashlightType flashlightTypeID = (FlashlightType)__instance.flashlightTypeID;
switch (flashlightTypeID)
{
case FlashlightType.ProFlashlight:
((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.ProFlashlightBatteryUsage.Value;
break;
case FlashlightType.Flashlight:
((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.FlashlightBatteryUsage.Value;
break;
case FlashlightType.LaserPointer:
((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.LaserPointerBatteryUsage.Value;
break;
default:
Plugin.Log($"Unknown FlashlightType: {flashlightTypeID}");
break;
}
}
}
[HarmonyPatch(typeof(JetpackItem))]
internal class JetpackItemPatch
{
[HarmonyPatch("ItemActivate")]
[HarmonyPrefix]
private static void ModifyJetpackBatteryUsage(ref JetpackItem __instance)
{
((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.JetpackBatteryUsage.Value;
}
}
[HarmonyPatch(typeof(PatcherTool))]
internal class PatcherToolPatch
{
[HarmonyPatch("ItemActivate")]
[HarmonyPrefix]
private static void ModifyPatcherToolBatteryUsage(ref PatcherTool __instance)
{
((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.PatcherToolBatteryUsage.Value;
}
}
[HarmonyPatch(typeof(BoomboxItem))]
internal class BoomboxItemPatch
{
[HarmonyPatch("ItemActivate")]
[HarmonyPrefix]
private static void ModifyBoomboxItemBatteryUsage(ref BoomboxItem __instance)
{
((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.BoomboxItemBatteryUsage.Value;
}
}
[HarmonyPatch(typeof(WalkieTalkie))]
internal class WalkieTalkieItemPatch
{
[HarmonyPatch("ItemActivate")]
[HarmonyPostfix]
private static void ModifyWalkieTalkieBatteryUsage(ref WalkieTalkie __instance)
{
((GrabbableObject)__instance).itemProperties.batteryUsage = ConfigSettings.WalkieTalkieBatteryUsage.Value;
}
}
}