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 Il2Cpp; using Il2CppAssets.Scripts.Models; using Il2CppAssets.Scripts.Models.Entities; using Il2CppAssets.Scripts.Models.GenericBehaviors; using Il2CppAssets.Scripts.Models.Towers; using Il2CppAssets.Scripts.Models.Towers.Behaviors.Attack; using Il2CppAssets.Scripts.Models.Towers.Filters; using Il2CppAssets.Scripts.Models.Towers.Projectiles; using Il2CppAssets.Scripts.Models.Towers.Projectiles.Behaviors; using Il2CppAssets.Scripts.Models.Towers.Weapons; using Il2CppAssets.Scripts.Unity; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppNinjaKiwi.Common.ResourceUtils; using Il2CppNinjaKiwi.Localization; using Il2CppSystem.Linq; using MelonLoader; using Microsoft.CodeAnalysis; using PathsPlusPlus; using TornadoWizards; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(TornadoWizardsMod), "Tornado Wizards", "1.0.4", "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("TornadoWizards")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f042f8400c35ae267db03175fe16482359eb92f1")] [assembly: AssemblyProduct("TornadoWizards")] [assembly: AssemblyTitle("TornadoWizards")] [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 TornadoWizards { public static class ModHelperData { public const string WorksOnVersion = "54.0"; public const string Version = "1.0.4"; public const string Name = "Tornado Wizards"; public const string Description = "A mod making use of PathsPlusPlus to add an additional upgrade path for Wizards.\nThe 5 new upgrades give them back lightning and tornado themed abilities they had in previous games that were instead shifted to Druids in BTD6."; public const string RepoOwner = "doombubbles"; public const string PrevRepoName = "tornado-wizards"; public const string RepoName = "TornadoWizards"; public const string Dependencies = "doombubbles/PathsPlusPlus"; } public class MysticDisruption : UpgradePlusPlus { public override int Cost => 400; public override int Tier => 1; public override string Icon => "f8ecd04260b47014493bc025eae0dbf1"; public override string Portrait => "Wizard1"; public override string Description => "Attacks slightly faster, and magic can now pop purple Bloons."; public override void ApplyUpgrade(TowerModel towerModel, int tier) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) foreach (WeaponModel item in Enumerable.ToArray(((Model)towerModel).GetDescendants())) { item.Rate /= 1.1f; } foreach (DamageModel item2 in Enumerable.ToArray(((Model)towerModel).GetDescendants())) { item2.immuneBloonProperties = (BloonProperties)(item2.immuneBloonProperties & -9); } if (((UpgradePlusPlus)this).IsHighestUpgrade(towerModel, false)) { PrefabReference display = (TowerModelBehaviorExt.GetBehavior(towerModel).display = ((EntityModel)Game.instance.model.GetTower(TowerType.WizardMonkey, 0, 0, 1)).display); ((EntityModel)towerModel).display = display; } } } public class LightningBolt : UpgradePlusPlus { public override int Cost => 1020; public override int Tier => 2; public override string Portrait => "Wizard2"; public override string Description => "Unleashes the power of lightning to zap many Bloons at once in a chain."; public override void ApplyUpgrade(TowerModel towerModel, int tier) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0270: Unknown result type (might be due to invalid IL or missing references) TowerModel tower = Game.instance.model.GetTower(TowerType.Druid, Math.Min(tier, 5), 0, 0); WeaponModel val = ModelExt.Duplicate(ModelExt.FindDescendant((Model)(object)tower, "Lightning")); val.animation = 1; DamageModel damageModel = ProjectileModelExt.GetDamageModel(val.projectile); damageModel.immuneBloonProperties = (BloonProperties)(damageModel.immuneBloonProperties & -9); if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Monkey Sense")) { Il2CppGenericIEnumerable.ForEach(((Model)val).GetDescendants(), (Action)delegate(FilterInvisibleModel model) { model.isActive = false; }); } if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Arcane Mastery")) { float damage = damageModel.damage; damageModel.damage = damage + 1f; if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Arcane Spike")) { DamageModifierForTagModel val2 = CreateDamageModifierForTagModelExt.Create(new Args { damageAddative = 6f, tag = "Moabs" }); ProjectileModelBehaviorExt.AddBehavior(val.projectile, val2); val.projectile.hasDamageModifiers = true; if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Archmage")) { damageModel.damage += 7f; val2.damageAddative = 24f; ProjectileModel projectile = val.projectile; damage = projectile.pierce; projectile.pierce = damage + 1f; ProjectileModel projectile2 = val.projectile; damage = projectile2.maxPierce; projectile2.maxPierce = damage + 1f; val.Rate /= 2f; } } } if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Dragon's Breath")) { val.Rate /= 3f; if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Summon Phoenix")) { damageModel.damage *= 2f; if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Wizard Lord Phoenix")) { damageModel.damage *= 3f; } TowerModel[] array = ModelExt.FindDescendants((Model)(object)towerModel, "Phoenix"); foreach (TowerModel val3 in array) { AttackModel attackModel = TowerModelExt.GetAttackModel(val3); WeaponModel val4 = ((IEnumerable)attackModel.weapons).First(); WeaponModel val5 = ModelExt.Duplicate(val); val5.animation = 1; WeaponModelExt.SetEject(val5, WeaponModelExt.GetEject(val4), false, false, false); val5.Rate *= val4.Rate / 0.2f; AttackModelExt.AddWeapon(attackModel, val5); } } } AttackModelExt.AddWeapon(TowerModelExt.GetAttackModel(towerModel), val); if (((UpgradePlusPlus)this).IsHighestUpgrade(towerModel, false)) { PrefabReference display = (TowerModelBehaviorExt.GetBehavior(towerModel).display = ((EntityModel)Game.instance.model.GetTower(TowerType.WizardMonkey, 0, 0, 1)).display); ((EntityModel)towerModel).display = display; } } } public class SummonWhirlwind : UpgradePlusPlus { public override int Cost => 1700; public override int Tier => 3; public override string Icon => "87bf090e91425a94eb2050f4d9256133"; public override string Portrait => "Wizard3"; public override string Description => "Whirlwind blows bloons off the path away from the exit. However, removes ice and glue from the bloons."; public override void ApplyUpgrade(TowerModel towerModel, int tier) { TowerModel tower = Game.instance.model.GetTower(TowerType.Druid, Math.Min(tier, 5), 0, 0); AttackModel val = ModelExt.Duplicate(TowerModelExt.GetAttackModels(tower).First((AttackModel model) => ((Model)model).name.Contains("Tornado"))); ((Il2CppArrayBase)(object)val.weapons)[0].animation = 1; if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Monkey Sense")) { Il2CppGenericIEnumerable.ForEach(((Model)val).GetDescendants(), (Action)delegate(FilterInvisibleModel model) { model.isActive = false; }); } val.range = towerModel.range; TowerModelBehaviorExt.AddBehavior(towerModel, val); } } public class ElectricOverload : UpgradePlusPlus { public override int Tier => 4; public override string Portrait => "Wizard4"; public override int Cost => ModSettingBool.op_Implicit(TornadoWizardsMod.BallLightning) ? Game.instance.model.GetUpgrade("Ball Lightning").cost : 7000; public override string DisplayName => ModSettingBool.op_Implicit(TornadoWizardsMod.BallLightning) ? "[Ball Lightning]" : ((NamedModContent)this).DisplayName; public override string Description => ModSettingBool.op_Implicit(TornadoWizardsMod.BallLightning) ? "[Ball Lightning Description]" : "Supercharges the Lightning attack, increasing damage, speed, and splitting."; public override string Icon => ModSettingBool.op_Implicit(TornadoWizardsMod.BallLightning) ? "2839dd76ceecd024291cf9c489473e30" : ((UpgradePlusPlus)this).Icon; public override void ApplyUpgrade(TowerModel towerModel, int tier) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (ModSettingBool.op_Implicit(TornadoWizardsMod.BallLightning)) { TowerModel tower = Game.instance.model.GetTower(TowerType.Druid, Math.Min(tier, 5), 0, 0); WeaponModel val = ModelExt.Duplicate(((IEnumerable)TowerModelExt.GetAttackModel(tower).weapons).First((WeaponModel w) => ((Model)w).name == "WeaponModel_BallLightning")); val.animation = 1; DamageModel damageModel = ProjectileModelExt.GetDamageModel(val.projectile); damageModel.immuneBloonProperties = (BloonProperties)(damageModel.immuneBloonProperties & -9); if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Monkey Sense")) { Il2CppGenericIEnumerable.ForEach(((Model)val).GetDescendants(), (Action)delegate(FilterInvisibleModel model) { model.isActive = false; }); } AttackModelExt.AddWeapon(TowerModelExt.GetAttackModel(towerModel), val); } else { WeaponModel val2 = ((IEnumerable)TowerModelExt.GetAttackModel(towerModel).weapons).First((WeaponModel w) => ((Model)w).name == "WeaponModel_Lightning"); val2.Rate /= 2f; ProjectileModel projectile = val2.projectile; DamageModel damageModel2 = ProjectileModelExt.GetDamageModel(projectile); damageModel2.damage += 4f; LightningModel behavior = ProjectileModelBehaviorExt.GetBehavior(projectile); int splits = behavior.splits; behavior.splits = splits + 1; } if (((UpgradePlusPlus)this).IsHighestUpgrade(towerModel, false)) { PrefabReference display = (TowerModelBehaviorExt.GetBehavior(towerModel).display = ((EntityModel)Game.instance.model.GetTower(TowerType.Druid, 4, 0, 0)).display); ((EntityModel)towerModel).display = display; } } } public class TempestTornado : UpgradePlusPlus { public override int Tier => 5; public override string Icon => "3a2676eac98a3b24194bf9963296f12e"; public override string Portrait => "Wizard5"; public override int Cost => ModSettingBool.op_Implicit(TornadoWizardsMod.BallLightning) ? Game.instance.model.GetUpgrade("Superstorm").cost : 50000; public override string Description => "The tempest blows more Bloons faster, further, and more often."; public override void ApplyUpgrade(TowerModel towerModel) { TowerModel tower = Game.instance.model.GetTower(TowerType.Druid, 5, 0, 0); WeaponModel val = ModelExt.Duplicate(((IEnumerable)TowerModelExt.GetAttackModel(tower).weapons).First((WeaponModel w) => ((Model)w).name.Contains("Superstorm"))); val.animation = 1; if (!ModSettingBool.op_Implicit(TornadoWizardsMod.BallLightning)) { ProjectileModelBehaviorExt.RemoveBehavior(val.projectile); } Il2CppGenericIEnumerable.ForEach(((Model)val).GetDescendants(), (Action)delegate(DamageModel model) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) model.immuneBloonProperties = (BloonProperties)(model.immuneBloonProperties & -9); }); if (((Il2CppArrayBase)(object)towerModel.appliedUpgrades).Contains("Monkey Sense")) { Il2CppGenericIEnumerable.ForEach(((Model)val).GetDescendants(), (Action)delegate(FilterInvisibleModel model) { model.isActive = false; }); } AttackModelExt.AddWeapon(TowerModelExt.GetAttackModel(towerModel), val); if (((UpgradePlusPlus)this).IsHighestUpgrade(towerModel, false)) { PrefabReference display = (TowerModelBehaviorExt.GetBehavior(towerModel).display = ((EntityModel)Game.instance.model.GetTower(TowerType.Druid, 5, 0, 0)).display); ((EntityModel)towerModel).display = display; } } } public class TornadoWizardsMod : BloonsTD6Mod { public static readonly ModSettingBool BallLightning; static TornadoWizardsMod() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0037: Expected O, but got Unknown ModSettingBool val = new ModSettingBool(false) { description = "Uses Ball Lightning as the Tier 4 Upgrade instead of the custom Lightning Overload upgrade. \r\nAlso reincorporates the Ball Lightning projectiles into the Tier 5 Upgrade.", icon = "2839dd76ceecd024291cf9c489473e30" }; ((ModSetting)val).onSave = delegate { ((NamedModContent)ModContent.GetInstance()).RegisterText(LocalizationManager.Instance.defaultTable); }; BallLightning = val; } } public class TornadoWizardPath : PathPlusPlus { public override string Tower => TowerType.WizardMonkey; } }