using System; 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.ModOptions; using BTD_Mod_Helper.Extensions; using BTD_Mod_Helper.UI.Menus; using HeroXpScale; using Il2CppAssets.Scripts.Models; using Il2CppAssets.Scripts.Models.TowerSets; using Il2CppAssets.Scripts.Models.Towers; using Il2CppAssets.Scripts.Models.Towers.Upgrades; using Il2CppAssets.Scripts.Unity; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using MelonLoader; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(HeroXpScaleMod), "Hero XP Scale", "1.0.3", "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("HeroXpScale")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9229b6bd15568870e14fc49df0c97c355dc45361")] [assembly: AssemblyProduct("HeroXpScale")] [assembly: AssemblyTitle("HeroXpScale")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] 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 HeroXpScale { public class HeroXpScaleMod : BloonsTD6Mod { private const int RoundNumberXpLevel = 4; public const float DefaultMin = 1f; public const float DefaultMax = 1.71f; public const float StepSize = 0.005f; private static readonly string BaseHero = TowerType.Quincy; public static readonly Dictionary HeroXpScales = new Dictionary(); internal static readonly Dictionary LoadedXpScales = new Dictionary(); public static readonly ModSettingBool BalancedMode; public override void OnNewGameModel(GameModel gameModel) { int[] array = (from upgrade in ((IEnumerable)Il2CppGenericIEnumerable.AsIEnumerable(Game.instance.model.GetTowersWithBaseId(BaseHero, false)).MaxBy((TowerModel model) => model.tier).appliedUpgrades).Select((Func)Game.instance.model.GetUpgrade) select upgrade.xpCost).ToArray(); foreach (KeyValuePair heroXpScale in HeroXpScales) { heroXpScale.Deconstruct(out var key, out var value); string text = key; ModSettingFloat val = value; Il2CppStringArray appliedUpgrades = Il2CppGenericIEnumerable.AsIEnumerable(gameModel.GetTowersWithBaseId(text, false)).MaxBy((TowerModel model) => model.tier).appliedUpgrades; for (int num = 0; num < ((Il2CppArrayBase)(object)appliedUpgrades).Length; num++) { gameModel.GetUpgrade(((Il2CppArrayBase)(object)appliedUpgrades)[num]).xpCost = Math.Max((int)Math.Round((float)array[num] * ModSettingDouble.op_Implicit((ModSettingDouble)(object)val)), 1); } } } public override void OnLoadSettings(JObject settings) { foreach (var (text2, val2) in settings) { if (!text2.EndsWith("XpScale")) { continue; } double? num = ((val2 != null) ? new double?(Extensions.Value((IEnumerable)val2)) : ((double?)null)); if (num.HasValue) { double valueOrDefault = num.GetValueOrDefault(); if (true) { LoadedXpScales[text2] = valueOrDefault; } } } } public static float GetXpScale(string heroId) { int xpCost = TowerModelExt.GetAppliedUpgrades(Game.instance.model.GetHeroWithNameAndLevel(BaseHero, 4, false)).Last().xpCost; int xpCost2 = TowerModelExt.GetAppliedUpgrades(Game.instance.model.GetHeroWithNameAndLevel(heroId, 4, false)).Last().xpCost; return (float)xpCost2 / (float)xpCost; } static HeroXpScaleMod() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00af: Expected O, but got Unknown //IL_00b4: Expected O, but got Unknown ModSettingBool val = new ModSettingBool(true) { description = $"Keeps the sliders locked to the vanilla low and high of {1f}x and {1.71f}x", button = true, enabledText = "ON", disabledText = "OFF" }; ((ModSetting)val).onValueChanged = delegate { foreach (ModSettingFloat value in HeroXpScales.Values) { ((ModSettingNumber)(object)value).min = (ModSettingBool.op_Implicit(BalancedMode) ? 1f : 0.005f); ((ModSettingNumber)(object)value).max = (ModSettingBool.op_Implicit(BalancedMode) ? 1.71f : 2f); if ((double)((ModSetting)value).GetValue() < ((ModSettingNumber)(object)value).min) { ((ModSetting)value).SetValue((object)((ModSettingNumber)(object)value).min); } if ((double)((ModSetting)value).GetValue() > ((ModSettingNumber)(object)value).max) { ((ModSetting)value).SetValue((object)((ModSettingNumber)(object)value).max); } } ((ModGameMenu)ModContent.GetInstance()).OnMenuOpened((Object)null); }; BalancedMode = val; } } public class HeroXpScaleSettings : ModContent { protected override float RegistrationPriority => 42f; public override void Register() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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) //IL_0105: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown string value = ((ModContent)this).Localize("XP Scale"); string value2 = ((ModContent)this).Localize("Default"); foreach (TowerDetailsModel item in (Il2CppArrayBase)(object)Game.instance.model.heroSet) { TowerModel towerWithName = Game.instance.model.GetTowerWithName(item.towerId); float xpScale = HeroXpScaleMod.GetXpScale(item.towerId); ModSettingFloat val = new ModSettingFloat(xpScale) { displayName = $"[{item.towerId}] [{value}]", description = $"[{value2}] {xpScale}" }; ((ModSettingNumber)val).slider = true; ((ModSettingNumber)val).min = (ModSettingBool.op_Implicit(HeroXpScaleMod.BalancedMode) ? 1f : 0.005f); ((ModSettingNumber)val).max = (ModSettingBool.op_Implicit(HeroXpScaleMod.BalancedMode) ? 1.71f : 2f); ((ModSettingDouble)val).stepSize = 0.005f; ((ModSetting)val).icon = towerWithName.icon.AssetGUID; ModSettingFloat val2 = val; if (HeroXpScaleMod.LoadedXpScales.TryGetValue(item.towerId + "XpScale", out var value3)) { ((ModSetting)val2).SetValue((object)value3); } base.mod.ModSettings[item.towerId + "XpScale"] = (ModSetting)(object)val2; HeroXpScaleMod.HeroXpScales[item.towerId] = val2; } } } public static class ModHelperData { public const string WorksOnVersion = "55.0"; public const string Version = "1.0.3"; public const string Name = "Hero XP Scale"; public const string Description = "Lets you configure the XP Scales for BTD6 Heroes"; public const string RepoOwner = "doombubbles"; public const string PrevRepoName = "hero-xp-scale"; public const string RepoName = "HeroXpScale"; } }