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 InfiniteWalkieTalkie.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("InfiniteWalkieTalkie")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InfiniteWalkieTalkie")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2033099f-002e-4b05-a8a0-6525bb3627d8")]
[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 InfiniteWalkieTalkie
{
[BepInPlugin("InfiniteWalkieTalkie", "Infinite Walkie Talkie", "1.0.0")]
public class BaseInfiniteWT : BaseUnityPlugin
{
private const string modGUID = "InfiniteWalkieTalkie";
private const string modName = "Infinite Walkie Talkie";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("InfiniteWalkieTalkie");
private static BaseInfiniteWT Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("InfiniteWalkieTalkie");
mls.LogInfo((object)"Infinite Walkie Talkie Loaded!");
harmony.PatchAll(typeof(BaseInfiniteWT));
harmony.PatchAll(typeof(WalkieTalkieInfinitePatch));
}
}
}
namespace InfiniteWalkieTalkie.Patches
{
[HarmonyPatch(typeof(WalkieTalkie))]
internal class WalkieTalkieInfinitePatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void InfiniteWalkiePatch(WalkieTalkie __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;
}
}
}
}