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 PirMod v1.0.5
PirMod.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PirMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b8f7f4ac7f795ded649d4fbe18d26017611d5dd6")] [assembly: AssemblyProduct("PirMod")] [assembly: AssemblyTitle("PirMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 PirMod { [BepInPlugin("PirMod", "PirMod", "1.0.5")] public class PirMod : BaseUnityPlugin { public static ConfigEntry<bool> cfgInfiniteSprint; public static ConfigEntry<bool> cfgMineMonster; public static ConfigEntry<bool> cfgStarterShovel; public static ConfigEntry<bool> cfgTurretTweaks; public static ConfigEntry<bool> cfgWeedSprayBees; public const string PLUGIN_GUID = "PirMod"; public const string PLUGIN_NAME = "PirMod"; public const string PLUGIN_VERSION = "1.0.5"; public static PirMod Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; cfgInfiniteSprint = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "InfiniteSprint", false, "Enable infinite stamina."); cfgMineMonster = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "MineMonster", true, "Monsters can step on and trigger landmines."); cfgStarterShovel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "StarterShovel", true, "Spawn a shovel when the game starts."); cfgTurretTweaks = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "TurretTweaks", true, "Allow hitting turrets with a shovel to disable them."); cfgWeedSprayBees = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "WeedSprayBees", true, "Weed spray exterminates bees, but destroys the hive if sprayed too close."); Patch(); Logger.LogInfo((object)"PirMod v1.0.5 has loaded!"); } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("PirMod"); } Logger.LogDebug((object)"[PirMod] Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"[PirMod] Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"[PirMod] Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"[PirMod] Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "PirMod"; public const string PLUGIN_NAME = "PirMod"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace PirMod.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal class InfiniteSprintPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void InfiniteStamina(PlayerControllerB __instance) { if (PirMod.cfgInfiniteSprint.Value && !((Object)(object)NetworkManager.Singleton == (Object)null) && ((NetworkBehaviour)__instance).IsOwner) { __instance.sprintMeter = 1f; } } } [HarmonyPatch(typeof(NetworkManager))] internal static class NetworkPrefabPatch2 { private static readonly string MOD_GUID = "PirMod"; [HarmonyPostfix] [HarmonyPatch("SetSingleton")] private static void RegisterPrefab() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent<NetworkObject>(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } [HarmonyPatch(typeof(Landmine))] internal class MineMonsterPatch { [HarmonyPatch("OnTriggerEnter")] [HarmonyPrefix] private static void MonsterTrigger(Landmine __instance, Collider other) { if (PirMod.cfgMineMonster.Value && !__instance.hasExploded && NetworkManager.Singleton.IsServer) { EnemyAI componentInParent = ((Component)other).gameObject.GetComponentInParent<EnemyAI>(); if ((Object)(object)componentInParent != (Object)null && !componentInParent.isEnemyDead) { Debug.Log((object)("[MyFirstMod] " + componentInParent.enemyType.enemyName + " stepped on a mine! BOOM!")); __instance.ExplodeMineServerRpc(); componentInParent.KillEnemyServerRpc(false); } } } } [HarmonyPatch(typeof(StartOfRound))] internal class StarterShovelPatch { [HarmonyPatch("StartGame")] [HarmonyPostfix] private static void SpawnItemOnLanding(StartOfRound __instance) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (PirMod.cfgStarterShovel.Value && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)) { Item val = ((IEnumerable<Item>)__instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item i) => i.itemName == "Shovel")); if ((Object)(object)val != (Object)null) { Vector3 val2 = __instance.playerSpawnPositions[0].position + new Vector3(0f, 1f, 0f); GameObject val3 = Object.Instantiate<GameObject>(val.spawnPrefab, val2, Quaternion.identity); val3.GetComponent<GrabbableObject>().fallTime = 0f; val3.transform.SetParent(__instance.elevatorTransform, true); val3.GetComponent<NetworkObject>().Spawn(false); PirMod.Logger.LogInfo((object)"[PirMod] Starter Shovel spawned successfully!"); } } } } [HarmonyPatch] internal class TurretTweaks { private static int mapHazardLayer = LayerMask.GetMask(new string[1] { "MapHazards" }); [HarmonyPatch(typeof(Shovel), "HitShovel")] [HarmonyPostfix] private static void CheckForTurretHit(Shovel __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (!PirMod.cfgTurretTweaks.Value) { return; } PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; if ((Object)(object)playerHeldBy == (Object)null) { return; } Vector3 position = ((Component)playerHeldBy.gameplayCamera).transform.position; Vector3 forward = ((Component)playerHeldBy.gameplayCamera).transform.forward; RaycastHit val = default(RaycastHit); if (Physics.SphereCast(position, 0.5f, forward, ref val, 1.5f, mapHazardLayer)) { Turret componentInParent = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponentInParent<Turret>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.turretActive && ((Behaviour)componentInParent).enabled) { RoundManager.Instance.PlayAudibleNoise(((RaycastHit)(ref val)).point, 10f, 1f, 0, false, 0); playerHeldBy.playerBodyAnimator.SetTrigger("shovelHit"); __instance.shovelAudio.PlayOneShot(__instance.reelUp); componentInParent.ToggleTurretServerRpc(false); } } } [HarmonyPatch(typeof(Turret), "ToggleTurretClientRpc")] [HarmonyPostfix] private static void FinalV80TurretKill(Turret __instance, bool __0) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (PirMod.cfgTurretTweaks.Value && !__0) { PirMod.Logger.LogInfo((object)"V80: Aggressively killing turret and disabling script component."); __instance.turretMode = (TurretMode)0; AudioSource[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<AudioSource>(); AudioSource[] array = componentsInChildren; foreach (AudioSource val in array) { val.Stop(); val.clip = null; } ((Behaviour)__instance).enabled = false; } } } [HarmonyPatch] internal class WeedSprayBeesPatch { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnServerReceiveBeeKill; public static HandleNamedMessageDelegate <1>__OnServerReceiveHiveKill; } private static float checkTimer; private const string SPRAY_BEES_MSG = "PirMod_SprayBees"; private const string SPRAY_HIVE_MSG = "PirMod_SprayHive"; [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void RegisterMessages() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>O.<0>__OnServerReceiveBeeKill; if (obj == null) { HandleNamedMessageDelegate val = OnServerReceiveBeeKill; <>O.<0>__OnServerReceiveBeeKill = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("PirMod_SprayBees", (HandleNamedMessageDelegate)obj); CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager; object obj2 = <>O.<1>__OnServerReceiveHiveKill; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnServerReceiveHiveKill; <>O.<1>__OnServerReceiveHiveKill = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("PirMod_SprayHive", (HandleNamedMessageDelegate)obj2); } } [HarmonyPatch(typeof(GrabbableObject), "Update")] [HarmonyPostfix] private static void SprayCheck(GrabbableObject __instance) { //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) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) if (!PirMod.cfgWeedSprayBees.Value || (Object)(object)__instance.itemProperties == (Object)null || (Object)(object)__instance.playerHeldBy == (Object)null || !((NetworkBehaviour)__instance.playerHeldBy).IsOwner || !__instance.itemProperties.itemName.Contains("Weed killer") || !__instance.isBeingUsed) { return; } checkTimer += Time.deltaTime; if (checkTimer < 0.25f) { return; } checkTimer = 0f; PlayerControllerB playerHeldBy = __instance.playerHeldBy; Vector3 position = ((Component)playerHeldBy.gameplayCamera).transform.position; Vector3 forward = ((Component)playerHeldBy.gameplayCamera).transform.forward; GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); GrabbableObject[] array2 = array; FastBufferWriter val2 = default(FastBufferWriter); foreach (GrabbableObject val in array2) { if (!((Object)(object)val.itemProperties != (Object)null) || !(val.itemProperties.itemName == "Hive") || !((NetworkBehaviour)val).IsSpawned) { continue; } float num = Vector3.Distance(position, ((Component)val).transform.position); if (num < 4.5f) { if (NetworkManager.Singleton.IsServer) { DestroyHiveOnServer(val); continue; } ((FastBufferWriter)(ref val2))..ctor(8, (Allocator)2, -1); ulong networkObjectId = ((Component)val).GetComponent<NetworkObject>().NetworkObjectId; ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("PirMod_SprayHive", 0uL, val2, (NetworkDelivery)3); } } RedLocustBees[] array3 = Object.FindObjectsOfType<RedLocustBees>(); RedLocustBees[] array4 = array3; FastBufferWriter val5 = default(FastBufferWriter); foreach (RedLocustBees val3 in array4) { if (((EnemyAI)val3).isEnemyDead) { continue; } float num2 = Vector3.Distance(position, ((Component)val3).transform.position); if (!(num2 < 6f)) { continue; } Vector3 val4 = ((Component)val3).transform.position - position; Vector3 normalized = ((Vector3)(ref val4)).normalized; float num3 = Vector3.Dot(forward, normalized); if (num3 > 0.2f) { if (NetworkManager.Singleton.IsServer) { KillBeesOnServer(val3); continue; } ((FastBufferWriter)(ref val5))..ctor(8, (Allocator)2, -1); ulong networkObjectId = ((Component)val3).GetComponent<NetworkObject>().NetworkObjectId; ((FastBufferWriter)(ref val5)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("PirMod_SprayBees", 0uL, val5, (NetworkDelivery)3); } } } private static void OnServerReceiveBeeKill(ulong senderId, FastBufferReader payload) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { return; } ulong key = default(ulong); ((FastBufferReader)(ref payload)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(key, out var value)) { RedLocustBees component = ((Component)value).GetComponent<RedLocustBees>(); if ((Object)(object)component != (Object)null && !((EnemyAI)component).isEnemyDead) { KillBeesOnServer(component); } } } private static void OnServerReceiveHiveKill(ulong senderId, FastBufferReader payload) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { return; } ulong key = default(ulong); ((FastBufferReader)(ref payload)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(key, out var value)) { GrabbableObject component = ((Component)value).GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null) { DestroyHiveOnServer(component); } } } private static void KillBeesOnServer(RedLocustBees bees) { PirMod.Logger.LogInfo((object)"[PirMod] Weed spray exterminated the bees!"); ((EnemyAI)bees).isEnemyDead = true; ((Component)bees).gameObject.GetComponent<NetworkObject>().Despawn(true); } private static void DestroyHiveOnServer(GrabbableObject hive) { PirMod.Logger.LogInfo((object)"[PirMod] Weed spray contaminated the hive! Destroying it."); ((Component)hive).GetComponent<NetworkObject>().Despawn(true); } } }