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 MinecraftSpiderMod v2.0.1
MinecraftSpiderMod.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c0401e72-d71b-4f52-9d41-d01b9c860091")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MinecraftSpiderMod { [BepInPlugin("SkunkWerx.MinecraftSpiderMod", "MinecraftSpiderMod", "2.0.1")] public class MinecraftSpiderModBase : BaseUnityPlugin { private const string modGUID = "SkunkWerx.MinecraftSpiderMod"; private const string modName = "MinecraftSpiderMod"; private const string modVersion = "2.0.1"; private static readonly Harmony Harmony = new Harmony("SkunkWerx.MinecraftSpiderMod"); internal static ManualLogSource Log; internal static GameObject MCspider; internal static GameObject MCspiderCave; internal static VideoClip spiderVideo; internal static AudioClip SpiderStunSFX; internal static AudioClip SpiderHitSFX; internal static AudioClip SpiderDieSFX; internal static AudioClip SpiderAttackSFX; internal static AudioClip SpoolPlayerSFX; internal static AudioClip[] footstepSFX = (AudioClip[])(object)new AudioClip[1]; private static MinecraftSpiderModBase Instance; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Log = Logger.CreateLogSource("MinecraftSpiderMod"); Log.LogInfo((object)"MinecraftSpiderMod started, loading assets..."); AssetBundle val = AssetBundle.LoadFromMemory(GetResourceBytes("spider")); MCspider = val.LoadAsset<GameObject>("Assets/spiderPre.prefab"); MCspiderCave = val.LoadAsset<GameObject>("Assets/caveSpiderPre.prefab"); spiderVideo = val.LoadAsset<VideoClip>("assets/spiderVideo.mp4"); SpiderStunSFX = val.LoadAsset<AudioClip>("Assets/spider_stun.wav"); SpiderHitSFX = val.LoadAsset<AudioClip>("Assets/spider_hit.wav"); SpiderDieSFX = val.LoadAsset<AudioClip>("Assets/spider_die.wav"); SpiderAttackSFX = val.LoadAsset<AudioClip>("Assets/spider_hiss.wav"); SpoolPlayerSFX = val.LoadAsset<AudioClip>("Assets/spider_hiss.wav"); footstepSFX[0] = val.LoadAsset<AudioClip>("Assets/spider_walk.wav"); Log.LogInfo((object)"MinecraftSpiderMod assets loaded successfully."); Harmony.PatchAll(); } private static byte[] GetResourceBytes(string resourceName) { string name = "MinecraftSpiderMod.Resources." + resourceName; using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; return (stream.Read(array, 0, array.Length) < array.Length) ? null : array; } } } namespace MinecraftSpiderMod.Patches { [HarmonyPatch] internal class BaseEnemyAIPatch { [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(EnemyAI), "OnCollideWithPlayer")] public static void OnCollideWithPlayer(Collider other) { } } public class Coroutes : MonoBehaviour { private int coruns = 0; private int maxRuns = 3; private PlayerControllerB playercop; private SandSpiderAI spiderCop; public bool coroutRunning = false; public void StartCoRo(PlayerControllerB player, SandSpiderAI spiderInst) { playercop = player; spiderCop = spiderInst; if (coroutRunning) { maxRuns += 3; return; } ((MonoBehaviour)this).StartCoroutine(Poisoned(player, spiderInst)); coroutRunning = true; HUDManager.Instance.DisplayTip("Poisoned!", "You Have been poisoned by a cave spider.", false, false, "LC_Tip1"); } private IEnumerator Poisoned(PlayerControllerB player, SandSpiderAI spiderInst) { while (coruns < maxRuns) { player.DamagePlayer(10, true, true, (CauseOfDeath)6, 0, false, default(Vector3)); spiderInst.HitPlayerServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId); coruns++; yield return (object)new WaitForSecondsRealtime(1f); } coroutRunning = false; Object.Destroy((Object)(object)((Component)player).GetComponent<Coroutes>()); yield return null; } private void Update() { if (coroutRunning && coruns > maxRuns) { ((MonoBehaviour)this).StopCoroutine(Poisoned(playercop, spiderCop)); maxRuns = 0; Object.Destroy((Object)(object)((Component)playercop).GetComponent<Coroutes>()); } } } public class deathAnimCo : MonoBehaviour { private float timeElapsed = 0f; private float MaxTime = 0.35f; private float progress = 0f; private float zAngle = 0f; public void StartCoRo(Transform SpiderTrans) { MinecraftSpiderModBase.Log.LogInfo((object)"Starting Death Animation..."); ((MonoBehaviour)this).StartCoroutine(DeathAnim(SpiderTrans)); } private IEnumerator DeathAnim(Transform SpiderTrans) { Vector3 angles = SpiderTrans.localEulerAngles; SpiderTrans.localPosition = new Vector3(0f, 0f, 0f); Vector3 startingRot_v = new Vector3(angles.x, angles.y, angles.z); Vector3 endingRot_v = new Vector3(90f, angles.y, angles.z); while (progress < 1f) { timeElapsed += Time.deltaTime; progress = timeElapsed / MaxTime; MinecraftSpiderModBase.Log.LogInfo((object)("Animation Progress: " + progress)); zAngle = progress * 90f; SpiderTrans.localEulerAngles = Vector3.Lerp(startingRot_v, endingRot_v, progress); yield return null; } MinecraftSpiderModBase.Log.LogInfo((object)"Completed Death Animation, destroying instance..."); Object.Destroy((Object)(object)((Component)SpiderTrans).GetComponent<Coroutes>()); yield return null; } private void update() { } } [HarmonyPatch] internal class SandSpiderAIPatch { private static Dictionary<SandSpiderAI, float> _timeSinceMovingLegs; private static bool isCaveSpider; [HarmonyPatch(typeof(SandSpiderAI), "Start")] [HarmonyPrefix] public static void Start(SandSpiderAI __instance) { //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) if (_timeSinceMovingLegs == null) { _timeSinceMovingLegs = new Dictionary<SandSpiderAI, float>(); } _timeSinceMovingLegs.Add(__instance, Random.Range(0.1f, 0.9f)); ((Renderer)((Component)((Component)__instance).gameObject.transform.Find("MeshContainer/MeshRenderer")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false; Transform val = ((Component)__instance).gameObject.transform.Find("MeshContainer/AnimContainer/Armature/Head"); ((Renderer)((Component)val.Find("LeftFang")).gameObject.GetComponent<MeshRenderer>()).enabled = false; ((Renderer)((Component)val.Find("RightFang")).gameObject.GetComponent<MeshRenderer>()).enabled = false; int num = Random.Range(0, 4); GameObject val2; if (num == 1) { val2 = Object.Instantiate<GameObject>(MinecraftSpiderModBase.MCspiderCave, ((Component)__instance).gameObject.transform.Find("MeshContainer/ScanNode")); ((Component)__instance).transform.rotation = Quaternion.identity; val2.transform.localScale = new Vector3(3.5f, 3.5f, 3.5f); ((EnemyAI)__instance).enemyHP = 3; isCaveSpider = true; } else { val2 = Object.Instantiate<GameObject>(MinecraftSpiderModBase.MCspider, ((Component)__instance).gameObject.transform.Find("MeshContainer/ScanNode")); ((Component)__instance).transform.rotation = Quaternion.identity; val2.transform.localScale = new Vector3(5f, 5f, 5f); isCaveSpider = false; } val2.transform.rotation = Quaternion.Euler(-90f, 0f, 0f); val2.transform.localPosition = new Vector3(0f, 0.5f, 0f); Material material = ((Renderer)((Component)val).gameObject.GetComponentInChildren<MeshRenderer>()).material; Material material2 = ((Renderer)val2.GetComponent<MeshRenderer>()).material; material2.shader = material.shader; material2.renderQueue = material.renderQueue; ((EnemyAI)__instance).enemyType.stunSFX = MinecraftSpiderModBase.SpiderStunSFX; __instance.hitSpiderSFX = MinecraftSpiderModBase.SpiderHitSFX; ((EnemyAI)__instance).dieSFX = MinecraftSpiderModBase.SpiderDieSFX; __instance.attackSFX = MinecraftSpiderModBase.SpiderAttackSFX; __instance.spoolPlayerSFX = MinecraftSpiderModBase.SpoolPlayerSFX; __instance.footstepSFX = MinecraftSpiderModBase.footstepSFX; } [HarmonyPatch(typeof(SandSpiderAI), "Update")] [HarmonyPostfix] public static void Update(SandSpiderAI __instance) { _timeSinceMovingLegs[__instance] += Time.deltaTime; } [HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")] [HarmonyPrefix] public static bool OnCollideWithPlayer(SandSpiderAI __instance, Collider other) { //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) bool flag = false; try { Transform transform = ((Component)((Component)__instance).gameObject.transform.Find("MeshContainer/ScanNode/spiderPre(Clone)")).transform; } catch { flag = true; } BaseEnemyAIPatch.OnCollideWithPlayer(other); bool flag2 = (bool)Traverse.Create((object)__instance).Field("onWall").GetValue(); bool flag3 = (bool)Traverse.Create((object)__instance).Field("spoolingPlayerBody").GetValue(); float num = (float)Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").GetValue(); if (!((EnemyAI)__instance).isEnemyDead && !flag2) { PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, flag3, false); if ((Object)(object)val != (Object)null && num > 1f) { Traverse.Create((object)__instance).Field("timeSinceHittingPlayer").SetValue((object)0f); if (flag) { val.DamagePlayer(45, true, true, (CauseOfDeath)6, 0, false, default(Vector3)); __instance.HitPlayerServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId); try { Coroutes component = ((Component)other).gameObject.GetComponent<Coroutes>(); component.StartCoRo(val, __instance); } catch { Coroutes component = ((Component)other).gameObject.AddComponent<Coroutes>(); component.StartCoRo(val, __instance); } } else { val.DamagePlayer(90, true, true, (CauseOfDeath)6, 0, false, default(Vector3)); __instance.HitPlayerServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId); } } return false; } return false; } [HarmonyPatch(typeof(SandSpiderAI), "MoveLegsProcedurally")] [HarmonyPrefix] public static bool MoveLegsProcedurally(SandSpiderAI __instance) { if (_timeSinceMovingLegs[__instance] <= 0.2f) { return false; } _timeSinceMovingLegs[__instance] = 0f; return true; } [HarmonyPatch(typeof(SandSpiderAI), "KillEnemy")] [HarmonyPostfix] public static void KillEnemy(SandSpiderAI __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Transform transform; try { transform = ((Component)((Component)__instance).gameObject.transform.Find("MeshContainer/ScanNode/spiderPre(Clone)")).transform; } catch { transform = ((Component)((Component)__instance).gameObject.transform.Find("MeshContainer/ScanNode/caveSpiderPre(Clone)")).transform; } transform.rotation = Quaternion.Euler(90f, 0f, 0f); Vector3 localEulerAngles = transform.localEulerAngles; transform.localEulerAngles = new Vector3(localEulerAngles.x, localEulerAngles.y, -90f); transform.localPosition = new Vector3(0f, 0f, 0f); } } [HarmonyPatch] internal class TerminalPatch { [HarmonyPatch(typeof(Terminal), "Awake")] [HarmonyPostfix] public static void Awake(Terminal __instance) { __instance.enemyFiles[12].displayVideo = MinecraftSpiderModBase.spiderVideo; } } }