using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BTD_Mod_Helper; using BTD_Mod_Helper.Api; using BTD_Mod_Helper.Api.Components; using BTD_Mod_Helper.Api.Data; using BTD_Mod_Helper.Api.Helpers; using BTD_Mod_Helper.Api.Legends; using BTD_Mod_Helper.Api.ModOptions; using BTD_Mod_Helper.Extensions; using HarmonyLib; using Il2Cpp; using Il2CppAssets.Scripts.Data; using Il2CppAssets.Scripts.Data.Artifacts; using Il2CppAssets.Scripts.Data.Legends; using Il2CppAssets.Scripts.Models; using Il2CppAssets.Scripts.Models.Artifacts; using Il2CppAssets.Scripts.Models.Artifacts.Behaviors; using Il2CppAssets.Scripts.Models.Bloons; using Il2CppAssets.Scripts.Models.Bloons.Behaviors; using Il2CppAssets.Scripts.Models.Effects; using Il2CppAssets.Scripts.Models.Entities; using Il2CppAssets.Scripts.Models.Gameplay.Mods; using Il2CppAssets.Scripts.Models.GenericBehaviors; using Il2CppAssets.Scripts.Models.Profile; using Il2CppAssets.Scripts.Models.ServerEvents; using Il2CppAssets.Scripts.Models.SimulationBehaviors; using Il2CppAssets.Scripts.Models.TowerSets; using Il2CppAssets.Scripts.Models.Towers; using Il2CppAssets.Scripts.Models.Towers.Behaviors; using Il2CppAssets.Scripts.Models.Towers.Behaviors.Abilities.Behaviors; using Il2CppAssets.Scripts.Models.Towers.Behaviors.Attack; using Il2CppAssets.Scripts.Models.Towers.Behaviors.Attack.Behaviors; using Il2CppAssets.Scripts.Models.Towers.Behaviors.Emissions; using Il2CppAssets.Scripts.Models.Towers.Behaviors.Emissions.Behaviors; using Il2CppAssets.Scripts.Models.Towers.Filters; using Il2CppAssets.Scripts.Models.Towers.Projectiles; using Il2CppAssets.Scripts.Models.Towers.Projectiles.Behaviors; using Il2CppAssets.Scripts.Models.Towers.TowerFilters; using Il2CppAssets.Scripts.Models.Towers.Upgrades; using Il2CppAssets.Scripts.Models.Towers.Weapons; using Il2CppAssets.Scripts.Models.Towers.Weapons.Behaviors; using Il2CppAssets.Scripts.Simulation; using Il2CppAssets.Scripts.Simulation.Artifacts; using Il2CppAssets.Scripts.Simulation.Artifacts.Behaviors; using Il2CppAssets.Scripts.Simulation.Objects; using Il2CppAssets.Scripts.Simulation.SMath; using Il2CppAssets.Scripts.Simulation.Towers; using Il2CppAssets.Scripts.Simulation.Towers.Behaviors; using Il2CppAssets.Scripts.Unity; using Il2CppAssets.Scripts.Unity.Analytics; using Il2CppAssets.Scripts.Unity.Bridge; using Il2CppAssets.Scripts.Unity.UI_New.GameOver; using Il2CppAssets.Scripts.Unity.UI_New.InGame; using Il2CppAssets.Scripts.Unity.UI_New.InGame.StoreMenu; using Il2CppAssets.Scripts.Unity.UI_New.Legends; using Il2CppAssets.Scripts.Unity.UI_New.Main.HeroSelect; using Il2CppAssets.Scripts.Unity.UI_New.Main.PowersSelect; using Il2CppAssets.Scripts.Unity.UI_New.Popups; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppNinjaKiwi.Common; using Il2CppNinjaKiwi.Common.ResourceUtils; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.IO; using Il2CppSystem.Linq; using Il2CppSystem.Reflection; using MelonLoader; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using RogueRemix; using RogueRemix.NewArtifacts; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem.Utilities; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(RogueRemixMod), "Rogue Remix", "1.2.20", "doombubbles", null)] [assembly: MelonGame("Ninja Kiwi", "BloonsTD6")] [assembly: MelonGame("Ninja Kiwi", "BloonsTD6-Epic")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("RogueRemix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b0cccfb8ef693d2b70d9346adf347640a7bfa1ab")] [assembly: AssemblyProduct("RogueRemix")] [assembly: AssemblyTitle("RogueRemix")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object? IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object? value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object? value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object? value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object? value) { throw new NotSupportedException(); } void IList.Remove(object? value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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 RogueRemix { public static class Animations { [HarmonyPatch(typeof(RogueMonkeyMovement), "UpdateMovement")] internal static class RogueMonkeyMovement_Update { [HarmonyPrefix] internal static void Prefix(RogueMonkeyMovement __instance) { __instance.movementSpeed = 1f / ModSettingDouble.op_Implicit((ModSettingDouble)(object)RogueRemixMod.RogueMapAnimationSpeed); } [HarmonyPostfix] internal static void Postfix(RogueMonkeyMovement __instance) { __instance.movementSpeed = 1f / ModSettingDouble.op_Implicit((ModSettingDouble)(object)RogueRemixMod.RogueMapAnimationSpeed); } } [HarmonyPatch(typeof(RogueMap), "Update")] internal static class RogueMap_Update { [HarmonyPostfix] internal static void Postfix(RogueMap __instance) { __instance.tileInteractDelay = 1f / ModSettingDouble.op_Implicit((ModSettingDouble)(object)RogueRemixMod.RogueMapAnimationSpeed); __instance.bossDeathAnimTime = 7f / ModSettingDouble.op_Implicit((ModSettingDouble)(object)RogueRemixMod.RogueMapAnimationSpeed); __instance.smallPopupTime = 2f / ModSettingDouble.op_Implicit((ModSettingDouble)(object)RogueRemixMod.RogueMapAnimationSpeed); } } [HarmonyPatch(typeof(RogueMapScreen), "Open")] internal static class RogueMapScreen_Open { [HarmonyPostfix] internal static void Postfix() { Time.timeScale = ModSettingDouble.op_Implicit((ModSettingDouble)(object)RogueRemixMod.RogueMapAnimationSpeed); } } [HarmonyPatch(typeof(RogueMapScreen), "Close")] internal static class RogueMapScreen_Close { [HarmonyPostfix] internal static void Postfix() { Time.timeScale = 1f; } } } public static class ArtifactSelling { [HarmonyPatch(typeof(DisplayArtifactsPanel), "PopulateArtifacts")] internal static class DisplayArtifactsPanel_PopulateArtifacts { [HarmonyPrefix] internal static void Prefix(DisplayArtifactsPanel __instance) { TransformExtensions.DestroyAllChildren(__instance.artifactsInventoryContainer.transform); __instance.activeArtifactIcons.Clear(); } } [HarmonyPatch(typeof(DisplayArtifactsPanel), "OpenShowInventory")] internal static class DisplayArtifactsPanel_OpenShowInventory { [HarmonyPostfix] internal static void Postfix(DisplayArtifactsPanel __instance) { int count = __instance.activeArtifactIcons.Count; RogueArtifactDisplayIcon val = Il2CppGenerics.FirstOrDefault(__instance.activeArtifactIcons, (Func)((RogueArtifactDisplayIcon icon) => icon.artifactModel.baseId == "Token")); List val2 = Il2CppGenerics.Where(__instance.activeArtifactIcons, (Func)((RogueArtifactDisplayIcon icon) => !icon.artifactModel.IsBoost)); List val3 = Il2CppGenerics.Where(__instance.activeArtifactIcons, (Func)((RogueArtifactDisplayIcon icon) => icon.artifactModel.IsBoost)); if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled) { ((Component)val).transform.SetSiblingIndex(0); } Enumerator enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { RogueArtifactDisplayIcon current = enumerator.Current; ((Component)current).transform.SetSiblingIndex(count - 1); } if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled) { ((Component)val).transform.SetSiblingIndex(val2.Count - 1); while (((Component)val).transform.GetSiblingIndex() % 8 > 0) { AddSpacer(__instance.artifactsInventoryContainer.transform, val2.Count - 1); } } } } [HarmonyPatch(typeof(DisplayArtifactsPanel), "DiscardClicked")] internal static class DisplayArtifactsPanel_DiscardClicked { [HarmonyPrefix] internal static bool Prefix(DisplayArtifactsPanel __instance) { if (!ModSettingBool.op_Implicit(RogueRemixMod.SellingReplacesDiscarding)) { return true; } PopupScreen.instance.ShowPopup((Placement)0, StringExt.Localize(SellArtifact), StringExt.Localize(SellArtifactDescription), ReturnCallback.op_Implicit((Action)__instance.DiscardArtifact), StringExt.Localize("OK"), (ReturnCallback)null, StringExt.Localize("Cancel"), (TransitionAnim)1, (BackGround)1, false, false); return false; } } [HarmonyPatch(typeof(DisplayArtifactsPanel), "DiscardArtifact")] internal static class DisplayArtifactsPanel_DiscardArtifact { [HarmonyPrefix] internal static bool Prefix(DisplayArtifactsPanel __instance) { if (!ModSettingBool.op_Implicit(RogueRemixMod.SellingReplacesDiscarding)) { return true; } if ((Object)(object)__instance.selectedIcon == (Object)null || !((Component)__instance.selectedIcon).gameObject.active) { return false; } ArtifactModelBase artifactModel = __instance.selectedIcon.artifactModel; if (artifactModel.baseId == "Token") { return true; } TokenChanges.RewardTokens(artifactModel.ArtifactPower); return true; } } [HarmonyPatch(typeof(DisplayArtifactsPanel), "OpenDelete")] internal static class DisplayArtifactsPanel_OpenDelete { [HarmonyPostfix] internal static void Postfix(DisplayArtifactsPanel __instance) { Enumerator enumerator = __instance.activeArtifactIcons.GetEnumerator(); while (enumerator.MoveNext()) { RogueArtifactDisplayIcon current = enumerator.Current; if (((Il2CppArrayBase)(object)RogueData.ignoreCountArtifacts).Contains(current.artifactModel.ArtifactName)) { ((Component)current).gameObject.SetActive(false); } } } } private const int ArtifactsPerRow = 8; private static readonly string SellArtifact = ModContent.Localize("SellArtifact", "Sell Artifact"); private static readonly string SellArtifactDescription = ModContent.Localize("SellArtifactDescription", "This Artifact will be removed from your inventory, and you will gain its value in Tokens. Are you sure you want to sell it?"); public static int TokenCount(this RogueGameSaveData saveData) { return Il2CppGenerics.Where(saveData.artifactsInventory, (Func)((ArtifactLoot loot) => loot.baseId == "Token")).Count; } private static void AddSpacer(Transform parent, int index) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Spacer", (Type[])(object)new Type[1] { Il2CppType.Of() }); RectTransform component = val.GetComponent(); ((Transform)component).SetParent(parent); component.sizeDelta = ((Component)parent).GetComponent().cellSize; ((Transform)component).SetSiblingIndex(index); } } public static class ArtifactUpgrading { [HarmonyPatch(typeof(RogueLegendsManager), "CheckIfArtifactOwned")] internal static class RogueLegendsManager_CheckIfArtifactOwned { [HarmonyPrefix] internal static void Prefix(ref int tier) { if (ModSettingBool.op_Implicit(RogueRemixMod.ArtifactUpgrading)) { tier++; if (tier > 2) { tier = 2; } } } } [HarmonyPatch(typeof(RogueGameSaveData), "AddArtifactToInventory")] internal static class RogueGameSaveData_AddArtifactToInventory { [HarmonyPrefix] internal static void Prefix(RogueGameSaveData __instance, ArtifactLoot artifact, ref bool allowStacking) { if (!ModSettingBool.op_Implicit(RogueRemixMod.ArtifactUpgrading)) { return; } ArtifactModelBase val = default(ArtifactModelBase); if (Il2CppGenerics.Any(__instance.artifactsInventory, (Func)((ArtifactLoot loot) => loot.artifactName == artifact.artifactName)) && Il2CppSystemObjectExt.Is((from data in Il2CppSystemDictionaryExt.Values(GameData.Instance.artifactsData.artifactDatas) select ((Il2CppObjectBase)data.ArtifactModel()).Cast()).FirstOrDefault((Func)((ArtifactModelBase m) => !m.IsBoost && m.baseId == artifact.baseId && m.tier == artifact.tier + 1)), ref val)) { __instance.RemoveArtifactFromInventory(artifact.artifactName); ArtifactLoot obj = artifact; int tier = obj.tier; obj.tier = tier + 1; artifact.artifactName = ((Model)val).name; } if (artifact.artifactName.Contains("BoostArtifact") || artifact.artifactName.StartsWith("Token")) { allowStacking = true; } else if (!allowStacking) { Enumerator enumerator = Il2CppGenerics.Where(__instance.artifactsInventory, (Func)((ArtifactLoot loot) => loot.baseId == artifact.baseId)).GetEnumerator(); while (enumerator.MoveNext()) { ArtifactLoot current = enumerator.Current; TokenChanges.RewardTokens(current.ArtifactPower()); } } } } [HarmonyPatch(typeof(DisplayArtifactsPanel), "PopulateArtifacts")] internal static class DisplayArtifactsPanel_PopulateArtifacts { [HarmonyPrefix] internal static void Prefix(DisplayArtifactsPanel __instance) { PopulatingOwned = true; } [HarmonyPostfix] internal static void Postfix(DisplayArtifactsPanel __instance) { PopulatingOwned = false; } } [HarmonyPatch(typeof(RogueArtifactDisplayIcon), "Bind")] internal static class RogueArtifactDisplayIcon_Bind { [HarmonyPostfix] internal static void Postfix(RogueArtifactDisplayIcon __instance, ArtifactModelBase artifactModel, ArtifactSelected? onAddCallback, ArtifactSelected? onRemoveCallback) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown if (MerchantChanges.IsPopulatingShop) { HandleUpgradeIcon(__instance, artifactModel.ArtifactName); } RogueMerchantPanel panel = default(RogueMerchantPanel); if (!artifactModel.baseId.StartsWith("Token") || !Il2CppSystemObjectExt.Is(((Component)__instance).GetComponentInParent(), ref panel)) { return; } AudioClipReference sound = GameData.Instance.rogueData.rogueUIAudio.selectSound; if ((Delegate)(object)onAddCallback != (Delegate)null) { Button componentOrAdd = GameObjectExtensions.GetComponentOrAdd