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 StadiaJungleBossFork v1.1.8
ZetaArcade-StadiaJungleBossFork/StadiaJungleBoss.dll
Decompiled 12 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using IL.RoR2; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using R2API; using R2API.Utils; using RoR2; using RoR2.Navigation; using StadiaJungleBoss.Components; using StadiaJungleBoss.Setup; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("StadiaJungleBoss")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("StadiaJungleBoss")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a6f16744-d914-4f76-ac36-c1e4709acd21")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace StadiaJungleBoss { public static class Assets { public static class Prefabs { public static GameObject Button; public static GameObject Encounter; } public static AssetBundle mainAssetBundle; public static void PopulateAssets() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)mainAssetBundle)) { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("StadiaJungleBoss.stadiabossbundle")) { mainAssetBundle = AssetBundle.LoadFromStream(stream); } Prefabs.Button = mainAssetBundle.LoadAsset<GameObject>("BossButton"); Shader shader = LegacyResourcesAPI.Load<Shader>("Shaders/Deferred/hgstandard"); Material material = ((Renderer)Prefabs.Button.GetComponentInChildren<SkinnedMeshRenderer>()).material; material.shader = shader; Prefabs.Button.AddComponent<BossButtonController>(); Prefabs.Button.AddComponent<NetworkIdentity>(); PrefabAPI.RegisterNetworkPrefab(Prefabs.Button); GameObject val = mainAssetBundle.LoadAsset<GameObject>("StadiaJungleEncounter"); val.AddComponent<NetworkIdentity>(); TeamFilter val2 = val.AddComponent<TeamFilter>(); val2.defaultTeam = (TeamIndex)2; BossGroup val3 = val.AddComponent<BossGroup>(); val3.dropTable = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/Common/dtTier3Item.asset").WaitForCompletion(); val3.bossDropChance = 0f; val3.scaleRewardsByPlayerCount = true; val3.shouldDisplayHealthBarOnHud = true; ScriptedCombatEncounter val4 = val.AddComponent<ScriptedCombatEncounter>(); val4.grantUniqueBonusScaling = true; val4.spawnOnStart = false; val4.teamIndex = (TeamIndex)2; SpawnInfo val5 = default(SpawnInfo); val5.cullChance = 0f; val5.spawnCard = (SpawnCard)(object)Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/RoboBallBoss/cscSuperRoboBallBoss.asset").WaitForCompletion(); SpawnInfo val6 = val5; val4.spawns = (SpawnInfo[])(object)new SpawnInfo[1] { val6 }; EncounterController encounterController = val.AddComponent<EncounterController>(); PrefabAPI.RegisterNetworkPrefab(val); Prefabs.Encounter = val; } } } internal static class MagmaWormChanges { public static bool enabled; public static ItemDef StatItem; private static BodyIndex MagmaWormIndex; public static void Initialize() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown if (enabled) { InitItem(); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(GetBodyIndex)); CharacterBody.GetDisplayName += new hook_GetDisplayName(ReplaceName); CharacterBody.GetSubtitle += new hook_GetSubtitle(ReplaceSubtitle); Util.GetBestBodyName += new Manipulator(SuppressMendingName); } } private static void SuppressMendingName(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, typeof(CharacterBody), "HasBuff") }); val.Emit(OpCodes.Ldloc_0); val.EmitDelegate<Func<BuffIndex, CharacterBody, BuffIndex>>((Func<BuffIndex, CharacterBody, BuffIndex>)((BuffIndex buffIndex, CharacterBody body) => (buffIndex == Buffs.EliteEarth.buffIndex && CheckForWorm(body)) ? ((BuffIndex)(-1)) : buffIndex)); } private static string ReplaceSubtitle(orig_GetSubtitle orig, CharacterBody self) { if (CheckForWorm(self)) { return Language.GetString("STADIAJUNGLEBOSS_BODY_SUBTITLE"); } return orig.Invoke(self); } private static string ReplaceName(orig_GetDisplayName orig, CharacterBody self) { if (CheckForWorm(self)) { return Language.GetString("STADIAJUNGLEBOSS_BODY_NAME"); } return orig.Invoke(self); } private static void GetBodyIndex() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) MagmaWormIndex = BodyCatalog.FindBodyIndex("MagmaWormBody"); } private static void InitItem() { //IL_0021: 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_0085: Expected O, but got Unknown StatItem = ScriptableObject.CreateInstance<ItemDef>(); ((Object)StatItem).name = "StadiaBossMagmaWormItem"; StatItem.deprecatedTier = (ItemTier)5; StatItem.nameToken = "Stadia Worm"; StatItem.pickupToken = "Changes the attacks of Magma Worms."; StatItem.descriptionToken = "Changes the attacks of Magma Worms."; ItemDef statItem = StatItem; ItemTag[] array = new ItemTag[3]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); statItem.tags = (ItemTag[])(object)array; ItemDisplayRule[] array2 = (ItemDisplayRule[])(object)new ItemDisplayRule[0]; ItemAPI.Add(new CustomItem(StatItem, array2)); } private static bool CheckForWorm(CharacterBody body) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (body.bodyIndex == MagmaWormIndex && Object.op_Implicit((Object)(object)body.inventory)) { return body.inventory.GetItemCount(StatItem) > 0; } return false; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Moffein.StadiaJungleBoss", "Stadia Jungle Boss", "1.1.8")] public class StadiaJungleBossPlugin : BaseUnityPlugin { public static PluginInfo pluginInfo; public static bool RemoveChestsConfig; private static string LevelNamesConfigRaw; public static string[] LevelNames; internal static EquipmentDef EliteEarthEquipment = Addressables.LoadAssetAsync<EquipmentDef>((object)"RoR2/DLC1/EliteEarth/EliteEarthEquipment.asset").WaitForCompletion(); private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown pluginInfo = ((BaseUnityPlugin)this).Info; Assets.PopulateAssets(); Tokens.LoadLanguage(); ReadConfig(); SceneDirector.Start += new hook_Start(StageSetup.SceneDirectorHook); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(CreateSpawnCard)); MagmaWormChanges.Initialize(); } private void ReadConfig() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown //IL_007b: 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) //IL_009a: Expected O, but got Unknown //IL_009a: Expected O, but got Unknown MagmaWormChanges.enabled = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Magma Worm", "Enable Changes"), true, new ConfigDescription("Modify the Mending Magma Worm spawned by this mod, replacing its name and some other stuff.", (AcceptableValueBase)null, Array.Empty<object>())).Value; RemoveChestsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Remove Legendary Chest", "Remove Chest Toggle"), true, new ConfigDescription("Whether to delete the existing Legendary Chest, set to True by default.", (AcceptableValueBase)null, Array.Empty<object>())).Value; LevelNamesConfigRaw = ((BaseUnityPlugin)this).Config.Bind<string>(new ConfigDefinition("Stage List (Unstable)", "List of Stages"), "rootjungle", new ConfigDescription("List of stages to add the buttons to and to attempt to remove the Legendary Chest from, seperated by commas and using internal scene names. This will likely break though on other maps than Sundered Grove (rootjungle), and is just a temporary dev feature for debugging/testing stuff.", (AcceptableValueBase)null, Array.Empty<object>())).Value; LevelNames = LevelNamesConfigRaw.ToString().Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); } private void CreateSpawnCard() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) CharacterSpawnCard val = ScriptableObject.CreateInstance<CharacterSpawnCard>(); ((SpawnCard)val).directorCreditCost = 800; ((SpawnCard)val).eliteRules = (EliteRules)1; val.noElites = false; ((SpawnCard)val).prefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/MagmaWorm/MagmaWormMaster.prefab").WaitForCompletion(); ((SpawnCard)val).sendOverNetwork = true; ((SpawnCard)val).requiredFlags = (NodeFlags)0; ((SpawnCard)val).forbiddenFlags = (NodeFlags)2; ((SpawnCard)val).occupyPosition = false; ((SpawnCard)val).nodeGraphType = (GraphType)0; ((SpawnCard)val).hullSize = (HullClassification)1; if (MagmaWormChanges.enabled) { val.itemsToGrant = (ItemCountPair[])(object)new ItemCountPair[2] { new ItemCountPair { itemDef = Items.TeleportWhenOob, count = 1 }, new ItemCountPair { itemDef = MagmaWormChanges.StatItem, count = 1 } }; } else { val.itemsToGrant = (ItemCountPair[])(object)new ItemCountPair[1] { new ItemCountPair { itemDef = Items.TeleportWhenOob, count = 1 } }; } val.equipmentToGrant = (EquipmentDef[])(object)new EquipmentDef[1] { EliteEarthEquipment }; val.forbiddenAsBoss = true; EncounterController.bossCard = val; } } } namespace StadiaJungleBoss.Setup { internal static class StageSetup { internal static void SceneDirectorHook(orig_Start orig, SceneDirector self) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_0079: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)("Number of stages found in config: " + StadiaJungleBossPlugin.LevelNames.Length)); string[] levelNames = StadiaJungleBossPlugin.LevelNames; foreach (string text in levelNames) { Debug.Log((object)("Level = " + text)); } bool flag = false; string[] levelNames2 = StadiaJungleBossPlugin.LevelNames; Scene activeScene = SceneManager.GetActiveScene(); if (levelNames2.Contains(((Scene)(ref activeScene)).name)) { activeScene = SceneManager.GetActiveScene(); Debug.Log((object)("Current stage " + ((Scene)(ref activeScene)).name + " found in config")); flag = true; } else { activeScene = SceneManager.GetActiveScene(); Debug.Log((object)("Current stage " + ((Scene)(ref activeScene)).name + " not found in config, so the no changes will apply")); flag = false; } if (flag) { BossButtonController.buttonsPressed = 0; BossButtonController.totalButtons = 0; GameObject val = GameObject.Find("HOLDER: Randomization"); if (!Object.op_Implicit((Object)(object)val)) { return; } Transform val2 = val.transform.Find("GROUP: Large Treasure Chests"); if (Object.op_Implicit((Object)(object)val2)) { PlaceButtons(val2); GameObject val3 = Object.Instantiate<GameObject>(Assets.Prefabs.Encounter); NetworkServer.Spawn(val3); } } orig.Invoke(self); } internal static void PlaceButtons(Transform LargeChestTransform) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < LargeChestTransform.childCount; i++) { Transform child = LargeChestTransform.GetChild(i); if (!Object.op_Implicit((Object)(object)child)) { continue; } bool flag = false; if (((Component)child).gameObject.activeSelf) { flag = true; } if (flag && !StadiaJungleBossPlugin.RemoveChestsConfig) { Debug.Log((object)"StadiaJungleBoss: Skipping button placement because this is where the Legendary Chest goes"); continue; } ((Component)child).gameObject.SetActive(true); Transform val = child.Find("GoldChest"); if (Object.op_Implicit((Object)(object)val)) { if (NetworkServer.active) { Debug.Log((object)"StadiaJungleBoss: Placing button."); GameObject val2 = Object.Instantiate<GameObject>(Assets.Prefabs.Button); val2.transform.position = val.position - 1.2f * Vector3.up; val2.transform.rotation = val.rotation; NetworkServer.Spawn(val2); } if (StadiaJungleBossPlugin.RemoveChestsConfig) { Debug.Log((object)"StadiaJungleBoss: Destroying potential gold chest."); Object.Destroy((Object)(object)((Component)val).gameObject); } else if (!flag) { ((Component)child).gameObject.SetActive(false); } } else { Debug.Log((object)("StadiaJungleBoss: No chest found in category " + i)); } } } } internal static class Tokens { internal static string assemblyDir => Path.GetDirectoryName(StadiaJungleBossPlugin.pluginInfo.Location); internal static string languageRoot => Path.Combine(assemblyDir, "language"); internal static void LoadLanguage() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Language.SetFolders += new hook_SetFolders(fixme); } private static void fixme(orig_SetFolders orig, Language self, IEnumerable<string> newFolders) { if (Directory.Exists(languageRoot)) { IEnumerable<string> second = Directory.EnumerateDirectories(Path.Combine(languageRoot), self.name); orig.Invoke(self, newFolders.Union(second)); } else { orig.Invoke(self, newFolders); } } } } namespace StadiaJungleBoss.Components { public class BossButtonController : NetworkBehaviour { public delegate void OnButtonPressed(); public static OnButtonPressed OnButtonPressedActions; public static int totalButtons; public static int buttonsPressed; [SyncVar] public bool isPressedServer = false; public bool isPressedLocal = false; private bool enableOverlapSphere; private float overlapSphereRadius; private float overlapSphereStopwatch; private float overlapSphereFrequency; private Animator animator; private void Awake() { animator = ((Component)this).GetComponent<Animator>(); if (!Object.op_Implicit((Object)(object)animator)) { Debug.LogError((object)"StadiaJungleBoss: Could not find button animator"); } if (NetworkServer.active) { isPressedServer = false; } isPressedLocal = false; overlapSphereRadius = 1.5f; overlapSphereFrequency = 5f; enableOverlapSphere = true; if (totalButtons < 4) { totalButtons++; } } private void FixedUpdate() { if (NetworkServer.active) { FixedUpdateServer(); } if (!isPressedLocal && isPressedServer) { Pressed(); } } private void FixedUpdateServer() { //IL_005e: 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_0073: Unknown result type (might be due to invalid IL or missing references) if (isPressedServer || !enableOverlapSphere) { return; } float num = 1f / overlapSphereFrequency; overlapSphereStopwatch += Time.fixedDeltaTime; if (overlapSphereStopwatch >= num) { overlapSphereStopwatch -= num; if (HGPhysics.DoesOverlapSphere(((Component)this).transform.position, overlapSphereRadius, LayerMask.op_Implicit(CommonMasks.characterBodiesOrDefault) | LayerMask.op_Implicit(CommonMasks.fakeActorLayers), (QueryTriggerInteraction)0)) { isPressedServer = true; buttonsPressed++; OnButtonPressedActions?.Invoke(); } } } private void Pressed() { isPressedLocal = true; enableOverlapSphere = false; if (Object.op_Implicit((Object)(object)animator)) { animator.SetBool("pressed", true); } Util.PlaySound("Play_item_proc_bandolierSpawn", ((Component)this).gameObject); } } public class EncounterController : MonoBehaviour { public float spawnDelay = 3f; public static CharacterSpawnCard bossCard; private ScriptedCombatEncounter scriptedCombatEncounter; private bool showedWarning = false; private bool spawnedBoss = false; private float spawnDelayCountdown = 0f; private void Awake() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) scriptedCombatEncounter = ((Component)this).GetComponent<ScriptedCombatEncounter>(); for (int i = 0; i < scriptedCombatEncounter.spawns.Length; i++) { scriptedCombatEncounter.spawns[i].spawnCard = (SpawnCard)(object)bossCard; } BossButtonController.OnButtonPressedActions = (BossButtonController.OnButtonPressed)Delegate.Combine(BossButtonController.OnButtonPressedActions, new BossButtonController.OnButtonPressed(CheckButtons)); BossGroup component = ((Component)this).GetComponent<BossGroup>(); GameObject val = new GameObject(); val.layer = LayerIndex.noCollision.intVal; val.transform.position = new Vector3(-156f, 100f, -152.5f); Object.Instantiate<GameObject>(val); component.dropPosition = val.transform; } private void OnDestroy() { BossButtonController.OnButtonPressedActions = (BossButtonController.OnButtonPressed)Delegate.Remove(BossButtonController.OnButtonPressedActions, new BossButtonController.OnButtonPressed(CheckButtons)); } private void CheckButtons() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_006f: 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_0084: Expected O, but got Unknown if (!showedWarning && BossButtonController.buttonsPressed == BossButtonController.totalButtons - 1) { showedWarning = true; Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "STADIAJUNGLEBOSS_SPAWN_WARNING" }); } if (!spawnedBoss && BossButtonController.buttonsPressed >= BossButtonController.totalButtons) { spawnedBoss = true; spawnDelayCountdown = spawnDelay; Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = "STADIAJUNGLEBOSS_SPAWN_BEGIN" }); } } private void FixedUpdate() { if (NetworkServer.active && spawnDelayCountdown > 0f) { spawnDelayCountdown -= Time.fixedDeltaTime; if (spawnDelayCountdown <= 0f) { DoSpawn(); } } } private void DoSpawn() { scriptedCombatEncounter.BeginEncounter(); } } }