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 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("CompanyTank")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CompanyTank")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bcf38fc9-8802-4caa-b374-7c36ed811c74")]
[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 CompanyTank;
[BepInPlugin("Swaggies.CompanyTank", "CompanyTank", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string _guid = "Swaggies.CompanyTank";
private const string _name = "CompanyTank";
private const string _ver = "1.0.0";
private readonly Harmony harmony = new Harmony("Swaggies.CompanyTank");
private static Plugin Instance;
private static ManualLogSource loggerarunieraous;
private static int damage;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
loggerarunieraous = Logger.CreateLogSource("Swaggies.CompanyTank");
harmony.PatchAll(typeof(Plugin));
loggerarunieraous.LogInfo((object)"CompanyTank up and running.");
}
[HarmonyPatch(typeof(VehicleController), "DealPermanentDamage")]
[HarmonyPrefix]
private static void Patch1(ref int damageAmount)
{
damageAmount = 0;
}
[HarmonyPatch(typeof(VehicleController), "DealDamageClientRpc")]
[HarmonyPrefix]
private static void Patch2(ref int amount)
{
amount = 0;
}
[HarmonyPatch(typeof(VehicleController), "SetInternalStress")]
[HarmonyPrefix]
private static void Patch3(ref VehicleController __instance, ref float carStressIncrease)
{
if (!((NetworkBehaviour)__instance).IsOwner || ((Object)(object)StartOfRound.Instance.testRoom == (Object)null && StartOfRound.Instance.inShipPhase))
{
return;
}
if (carStressIncrease <= 0f)
{
__instance.carStressChange = Mathf.Clamp(__instance.carStressChange - Time.deltaTime, -0.25f, 0.5f);
}
else
{
__instance.carStressChange = Mathf.Clamp(__instance.carStressChange + Time.deltaTime * carStressIncrease, 0f, 10f);
}
Traverse.Create((object)__instance).Field("underExtremeStress").SetValue((object)(carStressIncrease >= 1f));
__instance.carStress = Mathf.Clamp(__instance.carStress + __instance.carStressChange, 0f, 100f);
if (__instance.carStress > 7f)
{
__instance.carStress = 0f;
damage += 2;
if (damage >= 30 && !__instance.carDestroyed)
{
Traverse.Create((object)__instance).Field("timeAtLastDamage").SetValue((object)Time.realtimeSinceStartup);
__instance.carHP = 0;
__instance.DestroyCarServerRpc(-1);
}
}
}
[HarmonyPatch(typeof(VehicleController), "Update")]
[HarmonyPostfix]
private static void Patch4()
{
if (StartOfRound.Instance.inShipPhase)
{
damage = 0;
}
}
}