From 316f30db43f863a2e0b35335525f9c01b2fc999c Mon Sep 17 00:00:00 2001 From: GrahamKracker Date: Tue, 10 Dec 2024 08:34:52 -0500 Subject: [PATCH] Initial updates for v46 --- BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs | 6 +++--- .../Api/Commands/OpenProfileFolderCommand.cs | 3 ++- BloonsTD6 Mod Helper/Api/Helpers/TimeHelper.cs | 1 + BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs | 5 +++-- .../Extensions/BehaviorExtensions/ModelBehaviorExt.cs | 8 ++++---- .../Extensions/CollectionExtensions/ArrayExt.cs | 1 + .../Extensions/CollectionExtensions/IEnumerableExt.cs | 1 + .../CollectionExtensions/Il2CppGenericIEnumerableExt.cs | 1 + .../Extensions/CollectionExtensions/Il2CppGenericsExt.cs | 1 + .../CollectionExtensions/Il2CppIEnumeratorExt.cs | 1 + .../CollectionExtensions/Il2CppReferenceArrayExt.cs | 1 + .../Extensions/CollectionExtensions/ListExt.cs | 1 + .../Extensions/CollectionExtensions/LockedListExt.cs | 1 + .../Extensions/LINQExtensions/LockedList.cs | 1 + .../Patches/Sim/TimeManager_FastForwardTimeScale.cs | 1 + BloonsTD6 Mod Helper/Patches/Sim/TimeManager_Update.cs | 1 + BloonsTD6 Mod Helper/Patches/UI/TowerImageLoader_Load.cs | 4 ++-- .../Patches/UI/TowerPurchaseButtonPatches.cs | 6 ++++-- 18 files changed, 30 insertions(+), 14 deletions(-) diff --git a/BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs b/BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs index 894e98518..d75cea4b5 100644 --- a/BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs +++ b/BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs @@ -1,5 +1,5 @@ -using Il2CppAssets.Scripts.Models.Bloons.Behaviors; -using Il2CppAssets.Scripts.Utils; +using Il2CppAssets.Scripts.Models.Bloons; +using Il2CppAssets.Scripts.Models.Bloons.Behaviors; namespace BTD_Mod_Helper.Api.Bloons; /// @@ -19,7 +19,7 @@ public static string ConstructBloonId(string bloonName, bool camo, bool regrow, { var baseName = bloonName.Replace("Camo", "").Replace("Regrow", "").Replace("Fortified", ""); - return BloonTypeUtility.BloonType(baseName, camo, regrow, fortified); + return BloonType.Construct(baseName, camo, regrow, fortified); } /// diff --git a/BloonsTD6 Mod Helper/Api/Commands/OpenProfileFolderCommand.cs b/BloonsTD6 Mod Helper/Api/Commands/OpenProfileFolderCommand.cs index ff655a857..11e46d9ef 100644 --- a/BloonsTD6 Mod Helper/Api/Commands/OpenProfileFolderCommand.cs +++ b/BloonsTD6 Mod Helper/Api/Commands/OpenProfileFolderCommand.cs @@ -11,7 +11,8 @@ internal class OpenProfileFolderCommand : ModCommand public override bool Execute(ref string resultText) { - ProcessHelper.OpenFolder(Path.GetDirectoryName(Game.Player.dataFile.file.path)); + if(Game.Player.dataFile.file.TryGetLocalFilePath(out var path)) + ProcessHelper.OpenFolder(Path.GetDirectoryName(path)); return true; } } \ No newline at end of file diff --git a/BloonsTD6 Mod Helper/Api/Helpers/TimeHelper.cs b/BloonsTD6 Mod Helper/Api/Helpers/TimeHelper.cs index 44be77ed7..ecbd0cc10 100644 --- a/BloonsTD6 Mod Helper/Api/Helpers/TimeHelper.cs +++ b/BloonsTD6 Mod Helper/Api/Helpers/TimeHelper.cs @@ -1,5 +1,6 @@ using System; using Il2CppAssets.Scripts; +using Il2CppAssets.Scripts.Simulation; using Il2CppAssets.Scripts.Utils; namespace BTD_Mod_Helper.Api.Helpers; diff --git a/BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs b/BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs index 85aa4043d..56db970e7 100644 --- a/BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs +++ b/BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs @@ -1,3 +1,4 @@ +using Il2CppAssets.Scripts.Models; using Il2CppAssets.Scripts.Models.Towers.Behaviors.Emissions; using Il2CppAssets.Scripts.Models.Towers.Projectiles; using Il2CppAssets.Scripts.Models.Towers.Weapons; @@ -81,9 +82,9 @@ public EmissionModel Emission /// Default null /// - public WeaponBehaviorModel[] Behaviors + public Model[] Behaviors { - get => Model.behaviors ?? new Il2CppReferenceArray(0); + get => Model.behaviors ?? new Il2CppReferenceArray(0); set { Model.RemoveChildDependants(Model.behaviors); diff --git a/BloonsTD6 Mod Helper/Extensions/BehaviorExtensions/ModelBehaviorExt.cs b/BloonsTD6 Mod Helper/Extensions/BehaviorExtensions/ModelBehaviorExt.cs index 6f86cf514..459abd01b 100644 --- a/BloonsTD6 Mod Helper/Extensions/BehaviorExtensions/ModelBehaviorExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/BehaviorExtensions/ModelBehaviorExt.cs @@ -42,9 +42,9 @@ public static IEnumerable GetBehaviors(this Model model) return attackModel.behaviors ?? Enumerable.Empty(); if (model.IsType(out PropModel propModel)) return propModel.behaviors ?? Enumerable.Empty(); - if (model.IsType(out WeaponModel weaponModel)) - return weaponModel.behaviors.CastAll() ?? Enumerable.Empty(); + return weaponModel.behaviors ?? Enumerable.Empty(); + if (model.IsType(out PowerModel powerModel)) return powerModel.behaviors.CastAll() ?? Enumerable.Empty(); if (model.IsType(out EmissionModel emissionModel)) @@ -101,9 +101,9 @@ public static void SetBehaviors(this Model model, IEnumerable behaviors, attackModel.behaviors = il2CppReferenceArray; else if (model.IsType(out PropModel propModel)) propModel.behaviors = il2CppReferenceArray; - else if (model.IsType(out WeaponModel weaponModel)) - weaponModel.behaviors = il2CppReferenceArray.DuplicateAs(); + weaponModel.behaviors = il2CppReferenceArray; + else if (model.IsType(out PowerModel powerModel)) powerModel.behaviors = il2CppReferenceArray.DuplicateAs(); else if (model.IsType(out EmissionModel emissionModel)) diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ArrayExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ArrayExt.cs index ac87db7a2..c5595e328 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ArrayExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ArrayExt.cs @@ -2,6 +2,7 @@ using System.Linq; using Il2CppAssets.Scripts.Utils; using Il2CppInterop.Runtime; +using Il2CppNinjaKiwi.Common; using Il2CppSystem.Collections.Generic; using Object = Il2CppSystem.Object; namespace BTD_Mod_Helper.Extensions; diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/IEnumerableExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/IEnumerableExt.cs index 50893338e..2787481fa 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/IEnumerableExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/IEnumerableExt.cs @@ -2,6 +2,7 @@ using System.Linq; using Il2CppAssets.Scripts.Utils; using Il2CppInterop.Runtime; +using Il2CppNinjaKiwi.Common; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using ArgumentException = System.ArgumentException; diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericIEnumerableExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericIEnumerableExt.cs index b1b1b19df..9a5ed234a 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericIEnumerableExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericIEnumerableExt.cs @@ -1,4 +1,5 @@ using Il2CppAssets.Scripts.Utils; +using Il2CppNinjaKiwi.Common; using Il2CppSystem; using Il2CppSystem.Collections; using Il2CppSystem.Collections.Generic; diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericsExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericsExt.cs index 466130e7b..65b85e9ef 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericsExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppGenericsExt.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Il2CppAssets.Scripts.Utils; +using Il2CppNinjaKiwi.Common; using Il2CppSystem; using Array = System.Array; namespace BTD_Mod_Helper.Extensions; diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppIEnumeratorExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppIEnumeratorExt.cs index 24558a8fc..22a7a86d6 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppIEnumeratorExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppIEnumeratorExt.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Il2CppAssets.Scripts.Simulation.Objects; using Il2CppAssets.Scripts.Utils; +using Il2CppNinjaKiwi.Common; using Il2CppSystem; using Il2CppSystem.Collections; namespace BTD_Mod_Helper.Extensions; diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppReferenceArrayExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppReferenceArrayExt.cs index bbe2757e8..c05471b54 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppReferenceArrayExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/Il2CppReferenceArrayExt.cs @@ -2,6 +2,7 @@ using System.Linq; using Il2CppAssets.Scripts.Models; using Il2CppAssets.Scripts.Utils; +using Il2CppNinjaKiwi.Common; using Il2CppSystem; using Array = System.Array; namespace BTD_Mod_Helper.Extensions; diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ListExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ListExt.cs index 5d18f06b9..91252b741 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ListExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/ListExt.cs @@ -1,6 +1,7 @@ using System.IO; using Il2CppAssets.Scripts.Simulation.Objects; using Il2CppAssets.Scripts.Utils; +using Il2CppNinjaKiwi.Common; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Newtonsoft.Json; diff --git a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/LockedListExt.cs b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/LockedListExt.cs index b59d4ff60..b7552bfb8 100644 --- a/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/LockedListExt.cs +++ b/BloonsTD6 Mod Helper/Extensions/CollectionExtensions/LockedListExt.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Il2CppAssets.Scripts.Utils; +using Il2CppNinjaKiwi.Common; using Il2CppSystem; using Array = System.Array; using Exception = System.Exception; diff --git a/BloonsTD6 Mod Helper/Extensions/LINQExtensions/LockedList.cs b/BloonsTD6 Mod Helper/Extensions/LINQExtensions/LockedList.cs index 6bd383bf3..d7bdcf999 100644 --- a/BloonsTD6 Mod Helper/Extensions/LINQExtensions/LockedList.cs +++ b/BloonsTD6 Mod Helper/Extensions/LINQExtensions/LockedList.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Il2CppAssets.Scripts.Utils; +using Il2CppNinjaKiwi.Common; using Object = Il2CppSystem.Object; namespace BTD_Mod_Helper.Extensions; diff --git a/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_FastForwardTimeScale.cs b/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_FastForwardTimeScale.cs index 1d8e71dad..748571adf 100644 --- a/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_FastForwardTimeScale.cs +++ b/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_FastForwardTimeScale.cs @@ -1,6 +1,7 @@ using System; using BTD_Mod_Helper.Api.Helpers; using Il2CppAssets.Scripts; +using Il2CppAssets.Scripts.Simulation; using Il2CppAssets.Scripts.Utils; namespace BTD_Mod_Helper.Patches.Sim; diff --git a/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_Update.cs b/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_Update.cs index 46aa07aad..cf33f602a 100644 --- a/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_Update.cs +++ b/BloonsTD6 Mod Helper/Patches/Sim/TimeManager_Update.cs @@ -1,4 +1,5 @@ using BTD_Mod_Helper.Api.Helpers; +using Il2CppAssets.Scripts.Simulation; using Il2CppAssets.Scripts.Unity.UI_New.InGame; using Il2CppAssets.Scripts.Utils; using UnityEngine; diff --git a/BloonsTD6 Mod Helper/Patches/UI/TowerImageLoader_Load.cs b/BloonsTD6 Mod Helper/Patches/UI/TowerImageLoader_Load.cs index d4c29e71f..251edd010 100644 --- a/BloonsTD6 Mod Helper/Patches/UI/TowerImageLoader_Load.cs +++ b/BloonsTD6 Mod Helper/Patches/UI/TowerImageLoader_Load.cs @@ -5,7 +5,7 @@ namespace BTD_Mod_Helper.Patches.UI; [HarmonyPatch(typeof(TowerImageLoader), nameof(TowerImageLoader.Load))] internal static class TowerImageLoader_Load { - [HarmonyPostfix] + /*[HarmonyPostfix] private static void Postfix(TowerImageLoader __instance, string towerID, bool useRoundBg) { if (ModTowerHelper.ModTowerCache.TryGetValue(towerID, out var modTower) && @@ -15,5 +15,5 @@ modTower.ModTowerSet is var modTowerSet && ResourceLoader.LoadSpriteFromSpriteReferenceAsync( useRoundBg ? modTowerSet.SeatReference : modTowerSet.ContainerReference, __instance.bg); } - } + }*/ } \ No newline at end of file diff --git a/BloonsTD6 Mod Helper/Patches/UI/TowerPurchaseButtonPatches.cs b/BloonsTD6 Mod Helper/Patches/UI/TowerPurchaseButtonPatches.cs index 188a710c8..8dea43bb2 100644 --- a/BloonsTD6 Mod Helper/Patches/UI/TowerPurchaseButtonPatches.cs +++ b/BloonsTD6 Mod Helper/Patches/UI/TowerPurchaseButtonPatches.cs @@ -4,7 +4,8 @@ using UnityEngine.UI; namespace BTD_Mod_Helper.Patches.UI; -[HarmonyPatch(typeof(TowerPurchaseButton2D), nameof(TowerPurchaseButton2D.DetermineBackgroundSprite))] +//todo: test whether custom towerset backgrounds still work +/*[HarmonyPatch(typeof(TowerPurchaseButton2D), nameof(TowerPurchaseButton2D.UpdateDisplay))] internal class TowerPurchaseButton2D_DetermineBackgroundSprite { [HarmonyPrefix] @@ -13,12 +14,13 @@ internal static bool Prefix(TowerPurchaseButton2D __instance, ref SpriteReferenc if (__instance.towerModel.GetModTower()?.ModTowerSet is ModTowerSet modTowerSet) { __result = modTowerSet.ContainerReference; + ModHelper.Log($"TowerPurchaseButton2D_DetermineBackgroundSprite: {modTowerSet.ContainerReference}"); return false; } return true; } -} +}*/ [HarmonyPatch(typeof(TowerPurchaseButton2D), nameof(TowerPurchaseButton2D.UpdateDisplay))] internal class TowerPurchaseButton2D_UpdateTowerDisplay