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 SpectateEnemies v1.0.0
SpectateEnemies.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using SpectateEnemies.Managers; using SpectateEnemies.Patches; 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("SpectateEnemies")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SpectateEnemies")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("510a54e9-60a5-4010-98a1-56bb2c2aee54")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace SpectateEnemies { [BepInPlugin("DougHRito.SpectateEnemies", "Spectate Enemies", "1.0.0")] public class SpectateEnemiesBase : BaseUnityPlugin { private const string modGUID = "DougHRito.SpectateEnemies"; private const string modName = "Spectate Enemies"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("DougHRito.SpectateEnemies"); public ConfigEntry<string> _GnomeSpectateName; public ConfigEntry<string> _ReaperSpectateName; public ConfigEntry<string> _HuntsmanSpectateName; public ConfigEntry<string> _ApexPredatorSpectateName; public ConfigEntry<string> _AnimalSpectateName; public ConfigEntry<string> _BangerSpectateName; public ConfigEntry<string> _ClownSpectateName; public ConfigEntry<string> _BowtieSpectateName; public ConfigEntry<string> _PeeperSpectateName; public ConfigEntry<string> _MentalistSpectateName; public ConfigEntry<string> _HiddenSpectateName; public ConfigEntry<string> _RobeSpectateName; public ConfigEntry<string> _SpewerSpectateName; public ConfigEntry<string> _TrudgeSpectateName; public ConfigEntry<string> _ShadowChildSpectateName; public ConfigEntry<string> _ChefSpectateName; public ConfigEntry<string> _UpscreamSpectateName; public ConfigEntry<string> _RugratSpectateName; public ConfigEntry<string> _HeadmanSpectateName; public ConfigEntry<float> _SpectateYSensitivity; public ConfigEntry<float> _SpectateOrbitSensitivity; public ConfigEntry<float> _SpectateZoomSensitivity; public static SpectateEnemiesBase Instance; internal ManualLogSource mls; private void Awake() { //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Expected O, but got Unknown //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("DougHRito.SpectateEnemies"); mls.LogInfo((object)"The Dougin has commenced"); _GnomeSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Gnome Spectate Name", "Gnome", "Sets the name for the Gnome in the top left corner of the screen while spectating them."); _ReaperSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Reaper Spectate Name", "Reaper", "Sets the name for the Reaper in the top left corner of the screen while spectating them."); _HuntsmanSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Huntsman Spectate Name", "Huntsman", "Sets the name for the Huntsman in the top left corner of the screen while spectating them."); _ApexPredatorSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Apex Predator Spectate Name", "Apex Predator", "Sets the name for the Apex Predator in the top left corner of the screen while spectating them."); _AnimalSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Animal Spectate Name", "Animal", "Sets the name for the Animal in the top left corner of the screen while spectating them."); _BangerSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Banger Spectate Name", "Banger", "Sets the name for the Banger in the top left corner of the screen while spectating them."); _ClownSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Clown Spectate Name", "Clown", "Sets the name for the Clown in the top left corner of the screen while spectating them."); _BowtieSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Bowtie Spectate Name", "Bowtie", "Sets the name for the Bowtie in the top left corner of the screen while spectating them."); _PeeperSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Peeper Spectate Name", "Peeper", "Sets the name for the Peeper in the top left corner of the screen while spectating them."); _MentalistSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Mentalist Spectate Name", "Mentalist", "Sets the name for the Mentalist in the top left corner of the screen while spectating them."); _HiddenSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Hidden Spectate Name", "Hidden", "Sets the name for the Hidden in the top left corner of the screen while spectating them."); _RobeSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Robe Spectate Name", "Robe", "Sets the name for the Robe in the top left corner of the screen while spectating them."); _SpewerSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Spewer Spectate Name", "Spewer", "Sets the name for the Spewer in the top left corner of the screen while spectating them."); _TrudgeSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Trudge Spectate Name", "Trudge", "Sets the name for the Trudge in the top left corner of the screen while spectating them."); _ShadowChildSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Shadow Child Spectate Name", "Shadow Child", "Sets the name for the Shadow Child in the top left corner of the screen while spectating them."); _ChefSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Chef Spectate Name", "Chef", "Sets the name for the Chef in the top left corner of the screen while spectating them."); _UpscreamSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Upscream Spectate Name", "Upscream", "Sets the name for the Upscream in the top left corner of the screen while spectating them."); _RugratSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Rugrat Spectate Name", "Rugrat", "Sets the name for the Rugrat in the top left corner of the screen while spectating them."); _HeadmanSpectateName = ((BaseUnityPlugin)this).Config.Bind<string>("Enemy Names", "Headman Spectate Name", "Headman", "Sets the name for the Headman in the top left corner of the screen while spectating them."); _SpectateYSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Spectate Sensitivity", "Y-Axis Sensitivity", 1f, new ConfigDescription("Sets the sensitivity of the camera's Y-Axis inputs (W for up, S for down)", (AcceptableValueBase)new AcceptableValueRange<float>(0.01f, 5f), Array.Empty<object>())); _SpectateOrbitSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Spectate Sensitivity", "Orbit Sensitivity", 1f, new ConfigDescription("Sets the sensitivity of the camera's rotation while orbiting the enemy (Controlled by mouse movement)", (AcceptableValueBase)new AcceptableValueRange<float>(0.01f, 5f), Array.Empty<object>())); _SpectateZoomSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Spectate Sensitivity", "Zoom Sensitivity", 1f, new ConfigDescription("Sets the sensitivity of the camera's zoom (Scroll Up/Down)", (AcceptableValueBase)new AcceptableValueRange<float>(0.01f, 5f), Array.Empty<object>())); harmony.PatchAll(typeof(SpectateEnemiesBase)); harmony.PatchAll(typeof(EnemyParentPatch)); harmony.PatchAll(typeof(SpectateCameraPatch)); harmony.PatchAll(typeof(RunManagerPatch)); harmony.PatchAll(typeof(ChatManagerPatch)); } } } namespace SpectateEnemies.Patches { [HarmonyPatch(typeof(SpectateCamera))] internal class SpectateCameraPatch { [HarmonyPatch("LateUpdate")] [HarmonyPostfix] private static void tinyBoiPatch(ref Camera ___MainCamera, ref PlayerAvatar ___player, ref Transform ___normalTransformDistance) { //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) CameraManager.checkInputs(); if (CameraManager.checkSpectateEnemy()) { try { Transform transform = ((Component)___MainCamera).transform; transform.eulerAngles += new Vector3((0f - CameraManager.mouseY) * 1.2f, CameraManager.mouseX * 1.2f, 0f); if (((Component)___MainCamera).transform.eulerAngles.x > 85f && ((Component)___MainCamera).transform.eulerAngles.x < 180f) { ((Component)___MainCamera).transform.eulerAngles = new Vector3(85f, ((Component)___MainCamera).transform.eulerAngles.y, ((Component)___MainCamera).transform.eulerAngles.z); } if (((Component)___MainCamera).transform.eulerAngles.x < 275f && ((Component)___MainCamera).transform.eulerAngles.x > 180f) { ((Component)___MainCamera).transform.eulerAngles = new Vector3(275f, ((Component)___MainCamera).transform.eulerAngles.y, ((Component)___MainCamera).transform.eulerAngles.z); } ((Component)___MainCamera).transform.position = CameraManager.getEnemyTransform().position + new Vector3(0f, CameraManager.spectateY, 0f) - ((Component)___MainCamera).transform.forward * CameraManager.orbitRadius; ((Component)___MainCamera).transform.LookAt(CameraManager.getEnemyTransform().position + new Vector3(0f, CameraManager.spectateY, 0f)); return; } catch (Exception) { return; } } try { SemiFunc.HUDSpectateSetName(SemiFunc.PlayerGetName(___player)); ((Component)___MainCamera).transform.position = ___normalTransformDistance.position; ((Component)___MainCamera).transform.rotation = ___normalTransformDistance.rotation; } catch (Exception) { } } } [HarmonyPatch(typeof(EnemyParent))] internal class EnemyParentPatch { [HarmonyPostfix] [HarmonyPatch(typeof(EnemyParent), "SpawnRPC")] public static void EnemySpawned(ref Enemy ___Enemy) { while (GameDirector.instance.PlayerList.Count == 0) { } CameraManager.addEnemyToList(___Enemy); } [HarmonyPostfix] [HarmonyPatch(typeof(EnemyParent), "DespawnRPC")] public static void EnemyDespawned(ref Enemy ___Enemy) { while (GameDirector.instance.PlayerList.Count == 0) { } CameraManager.removeEnemyFromList(___Enemy); } } [HarmonyPatch(typeof(RunManager))] internal class RunManagerPatch { [HarmonyPatch("ChangeLevel")] [HarmonyPrefix] private static void wipeVariables() { CameraManager.cleanupVariable(); } } [HarmonyPatch(typeof(ChatManager))] internal class ChatManagerPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void toggleControls(ref ChatManager ___instance) { if (___instance.StateIsActive()) { CameraManager.setChatBoxActive(isActive: true); } else { CameraManager.setChatBoxActive(isActive: false); } } } } namespace SpectateEnemies.Managers { internal class CameraManager { public static List<Enemy> Enemies = new List<Enemy>(); public static int currentEnemyToSpectate = 0; public static bool spectateEnemy = false; public static float spectateSwitchDelay; public static bool chatBoxActive; public static float orbitRadius = 5f; public static float spectateY; public static float mouseX = 0f; public static float mouseY = 0f; public static void addEnemyToList(Enemy enemy) { bool flag = false; for (int i = 0; i < Enemies.Count; i++) { if ((Object)(object)Enemies[i] == (Object)(object)enemy) { flag = true; } } if (!flag) { Enemies.Add(enemy); } } public static void setChatBoxActive(bool isActive) { chatBoxActive = isActive; } public static void cleanupVariable() { Enemies.Clear(); currentEnemyToSpectate = 0; spectateEnemy = false; spectateSwitchDelay = 0f; chatBoxActive = false; spectateY = 0f; } public static void removeEnemyFromList(Enemy enemy) { for (int i = 0; i < Enemies.Count; i++) { if ((Object)(object)Enemies[i] == (Object)(object)enemy) { if (currentEnemyToSpectate > i) { currentEnemyToSpectate--; } Enemies.RemoveAt(i); } } } public static Transform getEnemyTransform() { string text = ((Object)((Component)Enemies[currentEnemyToSpectate]).GetComponentInParent<EnemyParent>()).name; switch (text) { case "Enemy - Gnome(Clone)": text = SpectateEnemiesBase.Instance._GnomeSpectateName.Value; break; case "Enemy - Runner(Clone)": text = SpectateEnemiesBase.Instance._ReaperSpectateName.Value; break; case "Enemy - Hunter(Clone)": text = SpectateEnemiesBase.Instance._HuntsmanSpectateName.Value; break; case "Enemy - Duck(Clone)": text = SpectateEnemiesBase.Instance._ApexPredatorSpectateName.Value; break; case "Enemy - Animal(Clone)": text = SpectateEnemiesBase.Instance._AnimalSpectateName.Value; break; case "Enemy - Bang(Clone)": text = SpectateEnemiesBase.Instance._BangerSpectateName.Value; break; case "Enemy - Beamer(Clone)": text = SpectateEnemiesBase.Instance._ClownSpectateName.Value; break; case "Enemy - Bowtie(Clone)": text = SpectateEnemiesBase.Instance._BowtieSpectateName.Value; break; case "Enemy - Ceiling Eye(Clone)": text = SpectateEnemiesBase.Instance._PeeperSpectateName.Value; break; case "Enemy - Floater(Clone)": text = SpectateEnemiesBase.Instance._MentalistSpectateName.Value; break; case "Enemy - Hidden(Clone)": text = SpectateEnemiesBase.Instance._HiddenSpectateName.Value; break; case "Enemy - Robe(Clone)": text = SpectateEnemiesBase.Instance._RobeSpectateName.Value; break; case "Enemy - Slow Mouth(Clone)": text = SpectateEnemiesBase.Instance._SpewerSpectateName.Value; break; case "Enemy - Slow Walker(Clone)": text = SpectateEnemiesBase.Instance._TrudgeSpectateName.Value; break; case "Enemy - Thin Man(Clone)": text = SpectateEnemiesBase.Instance._ShadowChildSpectateName.Value; break; case "Enemy - Tumbler(Clone)": text = SpectateEnemiesBase.Instance._ChefSpectateName.Value; break; case "Enemy - Upscream(Clone)": text = SpectateEnemiesBase.Instance._UpscreamSpectateName.Value; break; case "Enemy - Valuable Thrower(Clone)": text = SpectateEnemiesBase.Instance._RugratSpectateName.Value; break; case "Enemy - Head(Clone)": text = SpectateEnemiesBase.Instance._HeadmanSpectateName.Value; break; } SemiFunc.HUDSpectateSetName(text); return ((Component)Enemies[currentEnemyToSpectate]).transform; } public static bool checkSpectateEnemy() { return spectateEnemy; } public static void checkInputs() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (spectateSwitchDelay > 0f) { spectateSwitchDelay -= Time.deltaTime; } mouseX = Input.GetAxis("Mouse X") * SpectateEnemiesBase.Instance._SpectateOrbitSensitivity.Value; mouseY = Input.GetAxis("Mouse Y") * SpectateEnemiesBase.Instance._SpectateOrbitSensitivity.Value; orbitRadius -= Input.mouseScrollDelta.y / (7.5f / SpectateEnemiesBase.Instance._SpectateZoomSensitivity.Value); orbitRadius = Mathf.Clamp(orbitRadius, 2f, 5f); if (!chatBoxActive) { if (Input.GetKeyDown((KeyCode)114)) { if (Enemies.Count > 0 && !spectateEnemy && spectateSwitchDelay <= 0f) { spectateEnemy = true; spectateSwitchDelay = 0.1f; } else if (spectateEnemy && spectateSwitchDelay <= 0f) { spectateEnemy = false; spectateSwitchDelay = 0.1f; } if (Enemies.Count > 0) { CameraGlitch.Instance.PlayTiny(); } } if (Input.GetKeyDown((KeyCode)101) && spectateSwitchDelay <= 0f && spectateEnemy) { currentEnemyToSpectate++; if (Enemies.Count <= currentEnemyToSpectate) { currentEnemyToSpectate = 0; } spectateSwitchDelay = 0.1f; if (Enemies.Count > 1) { CameraGlitch.Instance.PlayTiny(); } } if (Input.GetKeyDown((KeyCode)113) && spectateSwitchDelay <= 0f && spectateEnemy) { currentEnemyToSpectate--; if (currentEnemyToSpectate < 0) { currentEnemyToSpectate = Enemies.Count - 1; } spectateSwitchDelay = 0.1f; if (Enemies.Count > 1) { CameraGlitch.Instance.PlayTiny(); } } if (Input.GetKey((KeyCode)119) && spectateEnemy) { spectateY += Time.deltaTime * SpectateEnemiesBase.Instance._SpectateYSensitivity.Value; spectateY = Mathf.Clamp(spectateY, -1f, 3f); } if (Input.GetKey((KeyCode)115) && spectateEnemy) { spectateY -= Time.deltaTime * SpectateEnemiesBase.Instance._SpectateYSensitivity.Value; spectateY = Mathf.Clamp(spectateY, -1f, 3f); } } if (Enemies.Count <= 0) { spectateEnemy = false; } } } }