Skip to content

Commit

Permalink
Initial updates for v46
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker committed Dec 10, 2024
1 parent 5dcd0b8 commit 316f30d
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 14 deletions.
6 changes: 3 additions & 3 deletions BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
Expand All @@ -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);

Check failure on line 22 in BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs

View workflow job for this annotation

GitHub Actions / build

The name 'BloonType' does not exist in the current context

Check failure on line 22 in BloonsTD6 Mod Helper/Api/Bloons/BloonModelUtils.cs

View workflow job for this annotation

GitHub Actions / build

The name 'BloonType' does not exist in the current context
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ internal class OpenProfileFolderCommand : ModCommand<OpenFolderCommand>

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))

Check failure on line 14 in BloonsTD6 Mod Helper/Api/Commands/OpenProfileFolderCommand.cs

View workflow job for this annotation

GitHub Actions / build

'File<ProfileModel>' does not contain a definition for 'TryGetLocalFilePath' and no accessible extension method 'TryGetLocalFilePath' accepting a first argument of type 'File<ProfileModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 14 in BloonsTD6 Mod Helper/Api/Commands/OpenProfileFolderCommand.cs

View workflow job for this annotation

GitHub Actions / build

'File<ProfileModel>' does not contain a definition for 'TryGetLocalFilePath' and no accessible extension method 'TryGetLocalFilePath' accepting a first argument of type 'File<ProfileModel>' could be found (are you missing a using directive or an assembly reference?)
ProcessHelper.OpenFolder(Path.GetDirectoryName(path));
return true;
}
}
1 change: 1 addition & 0 deletions BloonsTD6 Mod Helper/Api/Helpers/TimeHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Il2CppAssets.Scripts;
using Il2CppAssets.Scripts.Simulation;
using Il2CppAssets.Scripts.Utils;
namespace BTD_Mod_Helper.Api.Helpers;

Expand Down
5 changes: 3 additions & 2 deletions BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -81,9 +82,9 @@ public EmissionModel Emission

/// Default null
/// <seealso cref="WeaponModel.behaviors"/>
public WeaponBehaviorModel[] Behaviors
public Model[] Behaviors
{
get => Model.behaviors ?? new Il2CppReferenceArray<WeaponBehaviorModel>(0);
get => Model.behaviors ?? new Il2CppReferenceArray<Model>(0);

Check failure on line 87 in BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs

View workflow job for this annotation

GitHub Actions / build

Operator '??' cannot be applied to operands of type 'Il2CppReferenceArray<WeaponBehaviorModel>' and 'Il2CppReferenceArray<Model>'

Check failure on line 87 in BloonsTD6 Mod Helper/Api/Helpers/WeaponHelper.cs

View workflow job for this annotation

GitHub Actions / build

Operator '??' cannot be applied to operands of type 'Il2CppReferenceArray<WeaponBehaviorModel>' and 'Il2CppReferenceArray<Model>'
set
{
Model.RemoveChildDependants(Model.behaviors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public static IEnumerable<Model> GetBehaviors(this Model model)
return attackModel.behaviors ?? Enumerable.Empty<Model>();
if (model.IsType(out PropModel propModel))
return propModel.behaviors ?? Enumerable.Empty<Model>();

if (model.IsType(out WeaponModel weaponModel))
return weaponModel.behaviors.CastAll<WeaponBehaviorModel, Model>() ?? Enumerable.Empty<Model>();
return weaponModel.behaviors ?? Enumerable.Empty<Model>();

if (model.IsType(out PowerModel powerModel))
return powerModel.behaviors.CastAll<PowerBehaviorModel, Model>() ?? Enumerable.Empty<Model>();
if (model.IsType(out EmissionModel emissionModel))
Expand Down Expand Up @@ -101,9 +101,9 @@ public static void SetBehaviors(this Model model, IEnumerable<Model> 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<Model, WeaponBehaviorModel>();
weaponModel.behaviors = il2CppReferenceArray;

Check failure on line 105 in BloonsTD6 Mod Helper/Extensions/BehaviorExtensions/ModelBehaviorExt.cs

View workflow job for this annotation

GitHub Actions / build

Cannot implicitly convert type 'Il2CppInterop.Runtime.InteropTypes.Arrays.Il2CppReferenceArray<Il2CppAssets.Scripts.Models.Model>' to 'Il2CppInterop.Runtime.InteropTypes.Arrays.Il2CppReferenceArray<Il2CppAssets.Scripts.Models.Towers.Weapons.WeaponBehaviorModel>'

else if (model.IsType(out PowerModel powerModel))
powerModel.behaviors = il2CppReferenceArray.DuplicateAs<Model, PowerBehaviorModel>();
else if (model.IsType(out EmissionModel emissionModel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Il2CppAssets.Scripts.Utils;
using Il2CppNinjaKiwi.Common;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 1 addition & 0 deletions BloonsTD6 Mod Helper/Patches/Sim/TimeManager_Update.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions BloonsTD6 Mod Helper/Patches/UI/TowerImageLoader_Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand All @@ -15,5 +15,5 @@ modTower.ModTowerSet is var modTowerSet &&
ResourceLoader.LoadSpriteFromSpriteReferenceAsync(
useRoundBg ? modTowerSet.SeatReference : modTowerSet.ContainerReference, __instance.bg);
}
}
}*/
}
6 changes: 4 additions & 2 deletions BloonsTD6 Mod Helper/Patches/UI/TowerPurchaseButtonPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit 316f30d

Please sign in to comment.