From ecf3614b44b8122f8b7de39ff8c808782b2a8852 Mon Sep 17 00:00:00 2001 From: doombubbles Date: Tue, 8 Oct 2024 22:46:43 -0700 Subject: [PATCH] Fix for 45 --- LATEST.md | 3 +-- ModHelperData.cs | 4 ++-- Patches/UiPatches.cs | 19 +++++++++---------- PathPlusPlus.cs | 2 +- Properties/launchSettings.json | 5 +++-- UpgradeScreenPlusPlus.cs | 16 ++++++++-------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/LATEST.md b/LATEST.md index d758a1f..a0d9c14 100644 --- a/LATEST.md +++ b/LATEST.md @@ -1,2 +1 @@ -- For modders, added `MultiPathPlusPlus` and `MultiUpdatePlusPlus` classes for making paths that apply to multiple towers - - Apart from overriding `Towers` instead of `Tower`, usage will be the same \ No newline at end of file +- Fixed for BTD6 v45 \ No newline at end of file diff --git a/ModHelperData.cs b/ModHelperData.cs index 8c51360..6f5e16a 100644 --- a/ModHelperData.cs +++ b/ModHelperData.cs @@ -2,8 +2,8 @@ namespace PathsPlusPlus; internal static class ModHelperData { - public const string WorksOnVersion = "44.0"; - public const string Version = "1.1.6"; + public const string WorksOnVersion = "45.0"; + public const string Version = "1.1.7"; public const string Name = "Paths++"; public const string Description = "A helper mod allowing additional upgrade paths and tiers to be made for towers.\n\n" + diff --git a/Patches/UiPatches.cs b/Patches/UiPatches.cs index e9ef17b..c0b63cd 100644 --- a/Patches/UiPatches.cs +++ b/Patches/UiPatches.cs @@ -296,17 +296,16 @@ internal static class TowerManager_GetTowerUpgradeCost { private static void Prefix(Tower tower, int path, int tier, ref Il2CppReferenceArray? __state) { - var towerModel = tower.towerModel; - if ((tier > 5 || path >= 3) && - path >= 0 && - PathPlusPlus.TryGetPath(towerModel.baseId, path, out var pathPlusPlus)) + if (tower.towerModel?.Is(out var towerModel) != true || + (tier <= 5 && path < 3) || + path < 0 || + !PathPlusPlus.TryGetPath(towerModel.baseId, path, out var pathPlusPlus)) return; + + __state = towerModel.upgrades; + towerModel.upgrades = new[] { - __state = towerModel.upgrades; - towerModel.upgrades = new[] - { - new UpgradePathModel(pathPlusPlus.Upgrades[tier - 1]!.Id, towerModel.name) - }; - } + new UpgradePathModel(pathPlusPlus.Upgrades[tier - 1]!.Id, towerModel.name) + }; } [HarmonyPostfix] diff --git a/PathPlusPlus.cs b/PathPlusPlus.cs index c430d11..abd8815 100644 --- a/PathPlusPlus.cs +++ b/PathPlusPlus.cs @@ -168,7 +168,7 @@ public void Apply(TowerModel tower, int tier) tower.tier = Math.Max(tower.tier, Math.Min(5, tier)); for (var i = 0; i < tier; i++) { - if (!Upgrades.TryGetValue(i, out var upgrade)) continue; + if (!Upgrades.TryGetValue(i, out var upgrade) || tower.appliedUpgrades.Contains(upgrade.Id)) continue; upgrade.ApplyUpgrade(tower); upgrade.ApplyUpgrade(tower, tier); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 7d5bb85..25cc67b 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -3,13 +3,14 @@ "BloonsTD6": { "commandName": "Executable", "executablePath": "$(BloonsTD6)/BloonsTD6.exe", - "workingDirectory": "$(BloonsTD6)" + "workingDirectory": "$(BloonsTD6)", + "commandLineArgs": "moddingDev" }, "BloonsTD6 (ML Debug)": { "commandName": "Executable", "executablePath": "$(BloonsTD6)/BloonsTD6.exe", "workingDirectory": "$(BloonsTD6)", - "commandLineArgs": "--melonloader.debug" + "commandLineArgs": "moddingDev --melonloader.debug" } } } \ No newline at end of file diff --git a/UpgradeScreenPlusPlus.cs b/UpgradeScreenPlusPlus.cs index b65b313..e5d9bfb 100644 --- a/UpgradeScreenPlusPlus.cs +++ b/UpgradeScreenPlusPlus.cs @@ -44,12 +44,12 @@ internal class UpgradeScreenPlusPlus : MonoBehaviour public UpgradeScreenPlusPlus(IntPtr ptr) : base(ptr) { createdUpgradePaths = new List(); - extraUpgradeDetails = new List[] - { - new(), - new(), - new(), - }; + extraUpgradeDetails = + [ + new List(), + new List(), + new List() + ]; } public void UpdateUi(string towerId) @@ -68,11 +68,11 @@ public void UpdateUi(string towerId) var extraPaths = PathsPlusPlusMod.PathsByTower.TryGetValue(towerId, out var somePaths) ? somePaths.Where(path => path is {ShowInMenu: true}).ToList() - : new System.Collections.Generic.List(); + : []; var extendedPaths = PathsPlusPlusMod.ExtendedPathsByTower.TryGetValue(towerId, out var morePaths) ? morePaths.Where(path => path is {ShowInMenu: true}).ToList()! - : new System.Collections.Generic.List(); + : []; var allPaths = extraPaths.Concat(extendedPaths).ToArray();