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 EnhancedTZP.Control;
using EnhancedTZP.Heal;
using GameNetcodeStuff;
using HarmonyLib;
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("EnhancedTZP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EnhancedTZP")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f322a722-b739-46ad-a36a-811e2fe87987")]
[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 EnhancedTZP
{
[BepInPlugin("xAsc3nt.EnhancedTZP", "EnhancedTZP", "1.1.1")]
public class EnhancedTZP : BaseUnityPlugin
{
private const string modGUID = "xAsc3nt.EnhancedTZP";
private const string modName = "EnhancedTZP";
private const string modVersion = "1.1.1";
private readonly Harmony harmony = new Harmony("xAsc3nt.EnhancedTZP");
private ConfigEntry<bool> configInfiniteFuel;
public static bool InfiniteFuel;
private ConfigEntry<bool> configShowBatteryIcon;
public static bool ShowBatteryIcon;
public static EnhancedTZP Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("xAsc3nt.EnhancedTZP");
mls.LogInfo((object)"EnhancedTZP is activated :)");
harmony.PatchAll(typeof(EnhancedTZP));
harmony.PatchAll(typeof(PlayerControllerBPatch1));
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 EnhancedTZP.Heal
{
[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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
if (EnhancedTZP.InfiniteFuel && (int)(___fuel * 1000f) % 1000 < 500)
{
___fuel = 1f;
}
if (EnhancedTZP.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("Strengthening...\nHealing ... " + (GameNetworkManager.Instance.localPlayerController.health + 1) + "%");
GameNetworkManager.Instance.localPlayerController.DamagePlayer(-5, 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;
}
}
}
namespace EnhancedTZP.Control
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch1
{
private static float? originalJumpForce;
private static float? originalmovementSpeed;
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void LongerDuration(ref float ___drunknessInertia, ref bool ___increasingDrunknessThisFrame, ref float ___drunkness, ref float ___drunknessSpeed, ref float ___movementSpeed, ref float ___jumpForce, ref float ___sprintMeter)
{
if (!originalJumpForce.HasValue)
{
originalJumpForce = 13f;
originalmovementSpeed = 4.6f;
}
if (___increasingDrunknessThisFrame)
{
return;
}
if (___drunkness > 0f)
{
___movementSpeed = 5.75f;
___jumpForce = 15.75f;
if (___drunkness > 0.3f)
{
___movementSpeed = 5.75f;
___jumpForce = 15.75f;
if (___drunkness > 0.8f)
{
___movementSpeed = 6.5f;
___jumpForce = 20f;
___sprintMeter = 1f;
}
}
}
else
{
if (originalJumpForce.HasValue)
{
___jumpForce = originalJumpForce.Value;
___movementSpeed = originalmovementSpeed.Value;
originalJumpForce = null;
originalmovementSpeed = null;
}
___drunknessInertia = 0f;
}
}
}
}