using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TzpLeth.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("TestLethal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestLethal")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2ba0eb43-680c-46bc-9c38-f755dcb4f038")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TzpLeth
{
[BepInPlugin("Hotoni.TZPHEAL", "TZP Reworked: Healing", "1.1.0.0")]
public class TZPHEAL : BaseUnityPlugin
{
private const string modGUID = "Hotoni.TZPHEAL";
private const string modName = "TZP Reworked: Healing";
private const string modVersion = "1.1.0.0";
private readonly Harmony harmony = new Harmony("Hotoni.TZPHEAL");
private ConfigEntry<bool> configInfiniteFuel;
public static bool InfiniteFuel;
private ConfigEntry<bool> configShowBatteryIcon;
public static bool ShowBatteryIcon;
private static TZPHEAL Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Hotoni.TZPHEAL");
mls.LogInfo((object)"TZP HEAL loaded");
harmony.PatchAll(typeof(TZPHEAL));
harmony.PatchAll(typeof(PlayerControllerBPatch));
configInfiniteFuel = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Infinite TZP", false, "Prevent TZP from ever running out.");
InfiniteFuel = configInfiniteFuel.Value;
configShowBatteryIcon = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Battery Icon", true, "Show a battery icon with the current TZP Fuel");
ShowBatteryIcon = configShowBatteryIcon.Value;
}
}
}
namespace TzpLeth.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch(typeof(TetraChemicalItem))]
internal class PlayerControllerBPatch : GrabbableObject
{
[HarmonyPatch(typeof(TetraChemicalItem), "Update")]
[HarmonyPrefix]
private static void PatchBattery(ref Item ___itemProperties, ref Battery ___insertedBattery, ref float ___fuel)
{
___itemProperties.requiresBattery = false;
___insertedBattery.charge = ___fuel;
___insertedBattery.empty = false;
}
[HarmonyPatch(typeof(TetraChemicalItem), "Update")]
[HarmonyPostfix]
public static void healtzp(ref bool ___emittingGas, ref bool ___isHeld, PlayerControllerB __instance, ref float ___fuel, ref Item ___itemProperties, ref Battery ___insertedBattery)
{
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
if (TZPHEAL.InfiniteFuel && (int)(___fuel * 1000f) % 1000 < 500)
{
___fuel = 1f;
}
else if (TZPHEAL.ShowBatteryIcon)
{
___itemProperties.requiresBattery = true;
___insertedBattery.charge = ___fuel;
___insertedBattery.empty = false;
}
if (!(___emittingGas & ___isHeld) || !((NetworkBehaviour)__instance).IsOwner)
{
return;
}
int num = (int)(___fuel * 1000f) % 1000;
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = true;
if (((NetworkBehaviour)__instance).IsOwner && num % 30 == 0 && GameNetworkManager.Instance.localPlayerController.health < 100)
{
HUDManager.Instance.DisplayStatusEffect("Healing ... " + (GameNetworkManager.Instance.localPlayerController.health + 1) + "%");
GameNetworkManager.Instance.localPlayerController.DamagePlayer(-2, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
if (GameNetworkManager.Instance.localPlayerController.health >= 10 && GameNetworkManager.Instance.localPlayerController.criticallyInjured)
{
GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
}
HUDManager.Instance.HUDAnimator.ResetTrigger("SmallHit");
}
if (GameNetworkManager.Instance.localPlayerController.health >= 99)
{
HUDManager.Instance.DisplayStatusEffect("Healthy.\nGet to work!");
HUDManager.Instance.statusEffectAnimator.SetTrigger("IndicateStatus");
}
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = false;
}
}
}