Skip to content

Commit

Permalink
Fix for 45
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Oct 9, 2024
1 parent 722f286 commit ecf3614
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
3 changes: 1 addition & 2 deletions LATEST.md
Original file line number Diff line number Diff line change
@@ -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
- Fixed for BTD6 v45
4 changes: 2 additions & 2 deletions ModHelperData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down
19 changes: 9 additions & 10 deletions Patches/UiPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,16 @@ internal static class TowerManager_GetTowerUpgradeCost
{
private static void Prefix(Tower tower, int path, int tier, ref Il2CppReferenceArray<UpgradePathModel>? __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]
Expand Down
2 changes: 1 addition & 1 deletion PathPlusPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
16 changes: 8 additions & 8 deletions UpgradeScreenPlusPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ internal class UpgradeScreenPlusPlus : MonoBehaviour
public UpgradeScreenPlusPlus(IntPtr ptr) : base(ptr)
{
createdUpgradePaths = new List<GameObject>();
extraUpgradeDetails = new List<UpgradeDetails>[]
{
new(),
new(),
new(),
};
extraUpgradeDetails =
[
new List<UpgradeDetails>(),
new List<UpgradeDetails>(),
new List<UpgradeDetails>()
];
}

public void UpdateUi(string towerId)
Expand All @@ -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<PathPlusPlus>();
: [];

var extendedPaths = PathsPlusPlusMod.ExtendedPathsByTower.TryGetValue(towerId, out var morePaths)
? morePaths.Where(path => path is {ShowInMenu: true}).ToList()!
: new System.Collections.Generic.List<PathPlusPlus>();
: [];

var allPaths = extraPaths.Concat(extendedPaths).ToArray();

Expand Down

0 comments on commit ecf3614

Please sign in to comment.