Please disclose if your mod was created primarily 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 GrugThumper v1.0.2
GrugThumper.dll
Decompiled 10 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; 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("GrugThumper")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("GrugThumper")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d44ae3a1-4086-418f-a725-2326d9f6c419")] [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 GrugThumper; [BepInPlugin("GrugThumper", "GrugThumper", "1.0.0")] public class Plugin : BaseUnityPlugin { public static AudioClip SmashAndGrabAudio; public static GameObject GrugModel; public static string pluginDir; public static AssetBundle GrugBundle; private void Awake() { pluginDir = ((BaseUnityPlugin)this).Info.Location; LoadAssets(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"GrugThumper: Plugin loaded."); } private void LoadAssets() { try { GrugBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginDir), "grug")); if ((Object)(object)GrugBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"GrugThumper: Failed to load AssetBundle 'grugbundle'."); return; } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("GrugThumper: AssetBundle failed to load -- " + ex.Message)); return; } try { SmashAndGrabAudio = GrugBundle.LoadAsset<AudioClip>("smash_grab"); GrugModel = GrugBundle.LoadAsset<GameObject>("GrugModel"); if ((Object)(object)SmashAndGrabAudio == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"GrugThumper: smash_grab audio clip not found in bundle."); } if ((Object)(object)GrugModel == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"GrugThumper: GrugModel prefab not found in bundle."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"GrugThumper: Successfully loaded assets. RELEASE THE BABY!"); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("GrugThumper: Failed to load assets -- " + ex2.Message)); } } } [HarmonyPatch(typeof(CrawlerAI))] internal class GrugThumperPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void ReplaceModel(CrawlerAI __instance) { Transform transform = ((Component)__instance).transform; Renderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { val.enabled = false; } InstantiateGrugModel(transform); } private static void InstantiateGrugModel(Transform parent) { //IL_002f: 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_0060: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.GrugModel != (Object)null) { GameObject val = Object.Instantiate<GameObject>(Plugin.GrugModel); val.transform.SetParent(parent); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = new Vector3(1.8f, 1.8f, 1.8f); MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(); if ((Object)(object)componentInChildren != (Object)null) { ((Renderer)componentInChildren).enabled = true; } } } [HarmonyPatch("BeginChasingPlayerClientRpc")] [HarmonyPostfix] private static void PlayChaseSound(CrawlerAI __instance) { if ((Object)(object)Plugin.SmashAndGrabAudio != (Object)null) { if ((Object)(object)((EnemyAI)(__instance?)).creatureSFX != (Object)null) { ((EnemyAI)__instance).creatureSFX.PlayOneShot(Plugin.SmashAndGrabAudio, 0.6f); WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureSFX, Plugin.SmashAndGrabAudio, 0.6f); } } } [HarmonyPatch("EatPlayerBodyClientRpc")] [HarmonyPostfix] public static void StopChaseSound(CrawlerAI __instance) { if ((Object)(object)((EnemyAI)(__instance?)).creatureSFX != (Object)null && ((EnemyAI)__instance).creatureSFX.isPlaying) { ((EnemyAI)__instance).creatureSFX.Stop(); } } }