Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TruckPlus v1.0.1
TruckPlus.dll
Decompiled an hour agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TooRed")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+de377acac8a6a6ea049aecec3a235e0a5f169788")] [assembly: AssemblyProduct("TruckPlus")] [assembly: AssemblyTitle("TruckPlus")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RepoPlus { public class Hook { [HarmonyPatch(typeof(PlayerAvatar))] public static class PlayerAvatarHook { [HarmonyPatch("Update")] [HarmonyPostfix] public static void Update(PlayerAvatar __instance) { if (!((Object)(object)__instance == (Object)null)) { Truck.HealTick(__instance); } } [HarmonyPatch("PlayerDeathRPC")] [HarmonyPostfix] public static void PlayerDeathRPC(PlayerAvatar __instance) { if (!((Object)(object)__instance == (Object)null)) { Truck.AllPlayersDeathSet(); } } } [HarmonyPatch(typeof(PlayerDeathHead))] public static class PlayerDeathHeadTriggerHook { [HarmonyPatch("Update")] [HarmonyPostfix] public static void Update(PlayerDeathHead __instance) { Truck.CheckInstantRevive(__instance); } [HarmonyPatch("Trigger")] [HarmonyPostfix] public static void Trigger(PlayerDeathHead __instance) { Truck.ReviveToTruck(); } } [HarmonyPatch(typeof(EnemyHealth))] public static class EnemyHealthAwakeHook { [HarmonyPatch("DeathRPC")] [HarmonyPostfix] public static void DeathRPC(EnemyHealth __instance) { Truck.OnEnemyDeath(__instance); } } [HarmonyPatch(typeof(LevelGenerator))] public static class LevelGeneratorHook { [HarmonyPatch("StartRoomGeneration")] [HarmonyPrefix] public static void StartRoomGeneration() { Truck.ResetTruckRevive(); } } [HarmonyPatch(typeof(ChargingStation))] public static class ChargingStationHook { [HarmonyPatch("Start")] [HarmonyPostfix] public static void Start(ChargingStation __instance) { Truck.BatteryChargeCost(__instance); } } } [BepInPlugin("TooRed.TruckPlus", "TruckPlus", "1.0.1")] public class Main : BaseUnityPlugin { private const string PluginGuid = "TooRed.TruckPlus"; private const string PluginName = "TruckPlus"; private const string PluginVersion = "1.0.1"; private static Harmony Harmony; internal static ManualLogSource Log { get; private set; } public static ConfigEntry<string> DeBug { get; private set; } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony = new Harmony("TooRed.TruckPlus"); DeBug = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DebugMode", "Off", new ConfigDescription("Debug mode", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Off", "Debug", "All" }), Array.Empty<object>())); Truck.Init(((BaseUnityPlugin)this).Config); Harmony.PatchAll(); } public static void BugLog(string message) { if (!(DeBug.Value == "Off")) { if (DeBug.Value == "Debug") { Log.LogDebug((object)(message ?? "")); } else { Log.LogInfo((object)(message ?? "")); } } } } public static class Truck { public static ConfigEntry<bool> EnableKillCharge; public static ConfigEntry<int> PointsPerKill; public static ConfigEntry<float> Diff1Mul; public static ConfigEntry<float> Diff2Mul; public static ConfigEntry<float> Diff3Mul; public static ConfigEntry<bool> EnableTruckHeal; public static ConfigEntry<int> TruckHealAmount; public static ConfigEntry<int> TruckHealInterval; public static int TruckReviveCredits; public static bool allPlayersDead; public static bool TeamWipeUsed; private static readonly Dictionary<PlayerDeathHead, float> headLastCheck = new Dictionary<PlayerDeathHead, float>(); private static readonly Dictionary<PlayerAvatar, float> healTimers = new Dictionary<PlayerAvatar, float>(); public static ConfigEntry<float> CostMultiplier { get; private set; } public static ConfigEntry<int> TruckReviveLimit { get; private set; } public static ConfigEntry<bool> InstantRevive { get; private set; } public static ConfigEntry<float> InstantReviveInterval { get; private set; } public static ConfigEntry<int> TruckReviveHealth { get; private set; } public static ConfigEntry<bool> AutoReviveAllPlayers { get; private set; } internal static void Init(ConfigFile config) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown string text = "Truck"; CostMultiplier = config.Bind<float>(text, "ChargeCostMultiplier", 0.9f, new ConfigDescription("Charging station power cost multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); EnableKillCharge = config.Bind<bool>(text, "EnableKillCharge", true, "Recharge the charging station by killing enemies"); PointsPerKill = config.Bind<int>(text, "PointsPerKill", 30, new ConfigDescription("Charge points per kill", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>())); Diff1Mul = config.Bind<float>(text, "KillChargeDifficulty1", 0.1f, new ConfigDescription("Difficulty 1 multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); Diff2Mul = config.Bind<float>(text, "KillChargeDifficulty2", 0.2f, new ConfigDescription("Difficulty 2 multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); Diff3Mul = config.Bind<float>(text, "KillChargeDifficulty3", 0.3f, new ConfigDescription("Difficulty 3 multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); AutoReviveAllPlayers = config.Bind<bool>(text, "AutoReviveAllPlayers", false, "Auto revive all players when the whole team dies during a level"); TruckReviveLimit = config.Bind<int>(text, "TruckReviveLimit", 10, new ConfigDescription("Max truck revives per level", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 99), Array.Empty<object>())); InstantRevive = config.Bind<bool>(text, "InstantRevive", true, "Instantly revive when a death head reaches the extraction point"); InstantReviveInterval = config.Bind<float>(text, "InstantReviveInterval", 1f, new ConfigDescription("Revive check interval (seconds)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); TruckReviveHealth = config.Bind<int>(text, "TruckReviveHealth", 19, new ConfigDescription("Health after a truck revive", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 49), Array.Empty<object>())); TruckReviveCredits = TruckReviveLimit.Value; EnableTruckHeal = config.Bind<bool>(text, "EnableTruckHeal", true, "Continuously heal while inside the truck"); TruckHealAmount = config.Bind<int>(text, "TruckHealAmount", 1, new ConfigDescription("Health restored per tick", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>())); TruckHealInterval = config.Bind<int>(text, "TruckHealInterval", 5, new ConfigDescription("Heal interval (seconds)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); Main.Log.LogInfo((object)"TruckPlus loaded"); } internal static void BatteryChargeCost(ChargingStation station) { station.batteryChargeCost *= CostMultiplier.Value; } internal static void OnEnemyDeath(EnemyHealth health) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 if (EnableKillCharge.Value && SemiFunc.IsMasterClientOrSingleplayer() && !RunManager.instance.restarting && SemiFunc.RunIsLevel()) { EnemyParent val = health.enemy?.EnemyParent; float num = 1f; if ((Object)(object)val != (Object)null) { Difficulty difficulty = val.difficulty; float num2 = (((int)difficulty == 0) ? Diff1Mul.Value : (((int)difficulty != 1) ? Diff3Mul.Value : Diff2Mul.Value)); num = num2; } AddCharge((float)PointsPerKill.Value * num); } } private static void AddCharge(float batteryPoints) { if (!(batteryPoints <= 0f)) { ChargingStation instance = ChargingStation.instance; instance.chargeFloat = Mathf.Clamp01(instance.chargeFloat + batteryPoints * 0.001f); instance.chargeTotal = Mathf.Clamp(Mathf.RoundToInt(instance.chargeFloat * 100f), 0, 100); StatsManager.instance.runStats["chargingStationChargeTotal"] = instance.chargeTotal; Main.BugLog($"Charging station charge increased by {batteryPoints}, current: {instance.chargeTotal}"); } } internal static void ResetTruckRevive() { headLastCheck.Clear(); healTimers.Clear(); allPlayersDead = false; if (SemiFunc.RunIsLevel()) { TruckReviveCredits = TruckReviveLimit.Value; TeamWipeUsed = false; Main.BugLog($"Truck revive credits reset to: {TruckReviveCredits}"); } } internal static void OnTeamWipe(int playerCount) { if (SemiFunc.RunIsLevel() && !TeamWipeUsed) { TruckReviveCredits += playerCount; allPlayersDead = false; Main.BugLog($"Team wipe: truck revive credits +{playerCount}, current: {TruckReviveCredits}"); } } internal static void CheckInstantRevive(PlayerDeathHead head) { if (!InstantRevive.Value || !SemiFunc.IsMasterClientOrSingleplayer() || (headLastCheck.TryGetValue(head, out var value) && Time.time - value < InstantReviveInterval.Value)) { return; } headLastCheck[head] = Time.time; if (head.roomVolumeCheck.inTruck) { if (TruckReviveCredits <= 0) { Main.BugLog("Out of truck revive credits"); return; } head.playerAvatar.Revive(true); head.playerAvatar.playerHealth.HealOther(TruckReviveHealth.Value, true); TruckReviveCredits--; Main.BugLog($"Truck revive, credits left: {TruckReviveCredits}"); } } internal static void HealTick(PlayerAvatar avatar) { if (!EnableTruckHeal.Value || !SemiFunc.IsMasterClientOrSingleplayer() || avatar.isDisabled || avatar.deadSet || !SemiFunc.RunIsLevel()) { return; } if (!avatar.RoomVolumeCheck.inTruck) { healTimers[avatar] = 0f; return; } PlayerHealth playerHealth = avatar.playerHealth; if (playerHealth.health > 0 && playerHealth.health < playerHealth.maxHealth) { healTimers.TryGetValue(avatar, out var value); value += Time.deltaTime; healTimers[avatar] = value; if (!(value < (float)TruckHealInterval.Value)) { healTimers[avatar] = 0f; playerHealth.HealOther(Mathf.Min(TruckHealAmount.Value, playerHealth.maxHealth - playerHealth.health), false); } } } internal static void ReviveToTruck() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!AutoReviveAllPlayers.Value || !SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel() || !allPlayersDead || TeamWipeUsed) { return; } TruckSafetySpawnPoint instance = TruckSafetySpawnPoint.instance; Transform val = ((instance != null) ? ((Component)instance).transform : null); if ((Object)(object)val == (Object)null) { return; } TeamWipeUsed = true; Main.BugLog("Whole team dead, teleporting all death heads to the truck for auto revive"); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (item.deadSet) { item.playerDeathHead.triggeredTimer = 0f; item.playerDeathHead.physGrabObject.Teleport(val.position, Quaternion.identity); } } } internal static void AllPlayersDeathSet() { if (!SemiFunc.IsMultiplayer() || !PhotonNetwork.IsMasterClient) { return; } List<PlayerAvatar> list = SemiFunc.PlayerGetList(); bool flag = true; foreach (PlayerAvatar item in list) { if (!item.deadSet) { flag = false; break; } } if (flag) { allPlayersDead = true; Main.BugLog("All players are dead"); OnTeamWipe(list.Count); } } } }