Skip to content

Commit

Permalink
Fix initial v45 compiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Oct 9, 2024
1 parent 8f8f0c6 commit aa8b7a3
Show file tree
Hide file tree
Showing 36 changed files with 216 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
fileName: MelonLoader.x64.zip
tarBall: false
zipBall: false
tag: v0.6.1
latest: true
- name: Extract MelonLoader
if: env.MELONLOADER_BRANCH == ''
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class OpenProfileFolderCommand : ModCommand<OpenFolderCommand>

public override bool Execute(ref string resultText)
{
ProcessHelper.OpenFolder(Path.GetDirectoryName(Game.Player.DataFile.File.Path));
ProcessHelper.OpenFolder(Path.GetDirectoryName(Game.Player.dataFile.file.path));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class OpenUserDataFolderCommand : ModCommand<OpenFolderCommand>

public override bool Execute(ref string resultText)
{
ProcessHelper.OpenFolder(Game.instance.playerService.Configuration.PlayerDataRootPath);
ProcessHelper.OpenFolder(Game.instance.playerService.configuration.playerDataRootPath);
return true;
}
}
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/Api/Display/ModBloonDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected static string GetBloonDisplay(string bloonId, int damagedAmount = 0)
}

var damageStateModels = bloonModel.damageDisplayStates;
return damageStateModels[damagedAmount - 1].displayPath.GUID;
return damageStateModels[damagedAmount - 1].displayPath.AssetGUID;
}
}

Expand Down
4 changes: 2 additions & 2 deletions BloonsTD6 Mod Helper/Api/Display/ModDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ protected void Set2DTexture(UnityDisplayNode node, string textureName)
/// <param name="bot">Path 3 tier</param>
/// <returns>The display GUID</returns>
protected string GetDisplay(string tower, int top = 0, int mid = 0, int bot = 0) =>
Game.instance.model.GetTower(tower, top, mid, bot).display.GUID;
Game.instance.model.GetTower(tower, top, mid, bot).display.AssetGUID;

/// <summary>
/// Gets the Display for a given bloon
/// </summary>
/// <param name="bloon"> The bloon base id</param>
/// <returns>The display GUID</returns>
protected string GetBloonDisplay(string bloon) =>
Game.instance.model.GetBloon(bloon).display.GUID;
Game.instance.model.GetBloon(bloon).display.AssetGUID;

/// <summary>
/// Gets a UnityDisplayNode for a different guid
Expand Down
118 changes: 114 additions & 4 deletions BloonsTD6 Mod Helper/Api/Enums/VanillaSprites.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions BloonsTD6 Mod Helper/Api/Helpers/GameModelExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ internal static void ExportAll()
["description"] = data.description,
["baseTowerName"] = data.baseTowerName,
["mmCost"] = data.mmCost,
["icon"] = data.icon.GUID,
["iconSquare"] = data.iconSquare.GUID,
["icon"] = data.icon.AssetGUID,
["iconSquare"] = data.iconSquare.AssetGUID,
["isDefaultTowerSkin"] = data.isDefaultTowerSkin,
["textMaterialId"] = data.textMaterialId,
["StorePortraitsContainer"] = new JArray(
data.StorePortraitsContainer?.items?.ToList()?.Select(portrait =>
new JObject
{
["asset"] = portrait.asset?.GUID,
["asset"] = portrait.asset?.AssetGUID,
["levelText"] = portrait.levelTxt
}) ??
Array.Empty<JObject>()
Expand Down
6 changes: 3 additions & 3 deletions BloonsTD6 Mod Helper/Api/Helpers/Lists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public Lists(IntPtr pointer) : base(pointer)
/// <summary>
/// All towers currently placed in the game, or null if not in a game
/// </summary>
public static Tower[] AllTowers => Instances.TowerManager?.GetTowers().ToIl2CppList().ToArray();
public static Tower[] AllTowers => Instances.TowerManager?.GetTowers().ToIl2CppList().ToArray() ?? Array.Empty<Tower>();

/// <summary>
/// All TowerToSimulation objects currently placed in the game, or null if not in a game
/// </summary>
public static TowerToSimulation[] AllTTS => Instances.Bridge?.ttss.ToArray();
public static TowerToSimulation[] AllTTS => Instances.Bridge?.ttss.ToArray()?? Array.Empty<TowerToSimulation>();

/// <summary>
/// All Entities in the current game, or null if not in a game
/// </summary>
public static Entity[] AllEntities => Instances.FactoryFactory?.GetUncast<Entity>().ToArray();
public static Entity[] AllEntities => Instances.FactoryFactory?.GetUncast<Entity>().ToArray()?? Array.Empty<Entity>();
}
4 changes: 3 additions & 1 deletion BloonsTD6 Mod Helper/Api/Internal/VanillaSpriteGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ public static void PopulateFromAddressables()

foreach (var atlasName in spriteAtlases)
{
if (atlasName == "AssetLibraryAtlas") continue;

var atlas = ResourceLoader.LoadAtlas(atlasName).WaitForCompletion();

var dummyArray = new Il2CppReferenceArray<Sprite>(atlas.spriteCount);
atlas.GetSprites(dummyArray);

Expand Down
4 changes: 2 additions & 2 deletions BloonsTD6 Mod Helper/Api/Towers/ModHero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ public virtual SkinData CreateDefaultSkin(Dictionary<string, SkinData> skinsByNa
skinData.iconSquare = SquareReference;
skinData.isDefaultTowerSkin = true;

skinData.unlockedEventSound = new AudioSourceReference
skinData.unlockedEventSound = new AudioClipReference
{
guidRef = SelectSound
};
skinData.unlockedVoiceSound = new AudioSourceReference
skinData.unlockedVoiceSound = new AudioClipReference
{
guidRef = ""
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class BloonBehaviorExt
/// <param name="bloon"></param>
/// <returns></returns>
public static bool HasBloonBehavior<T>(this Bloon bloon) where T : BloonBehavior =>
bloon.bloonBehaviors.HasItemsOfType<BloonBehavior, T>();
bloon.bloonBehaviors.HasItemsOfType<IBloonBehavior, T>();

/// <summary>
/// Check if this has a specific Behavior
Expand All @@ -37,7 +37,7 @@ public static bool HasBloonBehavior<T>(this Bloon bloon, out T item) where T : B
/// <param name="bloon"></param>
/// <returns></returns>
public static T GetBloonBehavior<T>(this Bloon bloon) where T : BloonBehavior =>
bloon.bloonBehaviors.GetItemOfType<BloonBehavior, T>();
bloon.bloonBehaviors.GetItemOfType<IBloonBehavior, T>();

/// <summary>
/// Return all Behaviors of type T
Expand All @@ -46,7 +46,7 @@ public static T GetBloonBehavior<T>(this Bloon bloon) where T : BloonBehavior =>
/// <param name="bloon"></param>
/// <returns></returns>
public static List<T> GetBloonBehaviors<T>(this Bloon bloon) where T : BloonBehavior =>
bloon.bloonBehaviors.GetItemsOfType<BloonBehavior, T>();
bloon.bloonBehaviors.GetItemsOfType<IBloonBehavior, T>();

/// <summary>
/// Add a Behavior to this
Expand All @@ -56,7 +56,7 @@ public static List<T> GetBloonBehaviors<T>(this Bloon bloon) where T : BloonBeha
/// <param name="behavior"></param>
public static void AddBloonBehavior<T>(this Bloon bloon, T behavior) where T : BloonBehavior
{
bloon.bloonBehaviors.Add(behavior);
bloon.bloonBehaviors.Add(behavior.Cast<IBloonBehavior>());
}

/// <summary>
Expand All @@ -66,7 +66,7 @@ public static void AddBloonBehavior<T>(this Bloon bloon, T behavior) where T : B
/// <param name="bloon"></param>
public static void RemoveBloonBehavior<T>(this Bloon bloon) where T : BloonBehavior
{
bloon.bloonBehaviors = bloon.bloonBehaviors.RemoveItemOfType<BloonBehavior, T>();
bloon.bloonBehaviors = bloon.bloonBehaviors.RemoveItemOfType<IBloonBehavior, T>();
}

/// <summary>
Expand All @@ -77,7 +77,7 @@ public static void RemoveBloonBehavior<T>(this Bloon bloon) where T : BloonBehav
/// <param name="behavior"></param>
public static void RemoveBloonBehavior<T>(this Bloon bloon, T behavior) where T : BloonBehavior
{
bloon.bloonBehaviors = bloon.bloonBehaviors.RemoveItem(behavior);
bloon.bloonBehaviors = bloon.bloonBehaviors.RemoveItem(behavior.Cast<IBloonBehavior>());
}

/// <summary>
Expand All @@ -87,6 +87,6 @@ public static void RemoveBloonBehavior<T>(this Bloon bloon, T behavior) where T
/// <param name="bloon"></param>
public static void RemoveBloonBehaviors<T>(this Bloon bloon) where T : BloonBehavior
{
bloon.bloonBehaviors = bloon.bloonBehaviors.RemoveItemsOfType<BloonBehavior, T>();
bloon.bloonBehaviors = bloon.bloonBehaviors.RemoveItemsOfType<IBloonBehavior, T>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using Il2CppAssets.Scripts.Models;
using Il2CppAssets.Scripts.Models.Bloons;
using Il2CppAssets.Scripts.Models.MapEditorBehaviors;
using Il2CppAssets.Scripts.Models.Powers;
using Il2CppAssets.Scripts.Models.Towers;
using Il2CppAssets.Scripts.Models.Towers.Behaviors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class ProjectileBehaviorExt
/// Check if this has a specific Behavior
/// </summary>
public static bool HasProjectileBehavior<T>(this Projectile projectile) where T : ProjectileBehavior =>
projectile.projectileBehaviors.HasItemsOfType<ProjectileBehavior, T>();
projectile.projectileBehaviors.HasItemsOfType<IProjectileBehavior, T>();

/// <summary>
/// Check if this has a specific Behavior
Expand All @@ -26,28 +26,28 @@ public static bool HasProjectileBehavior<T>(this Projectile projectile, out T it
/// Return the first Behavior of type T
/// </summary>
public static T GetProjectileBehavior<T>(this Projectile projectile) where T : ProjectileBehavior =>
projectile.projectileBehaviors.GetItemOfType<ProjectileBehavior, T>();
projectile.projectileBehaviors.GetItemOfType<IProjectileBehavior, T>();

/// <summary>
/// Return all Behaviors of type T
/// </summary>
public static List<T> GetProjectileBehaviors<T>(this Projectile projectile) where T : ProjectileBehavior =>
projectile.projectileBehaviors.GetItemsOfType<ProjectileBehavior, T>();
projectile.projectileBehaviors.GetItemsOfType<IProjectileBehavior, T>();

/// <summary>
/// Add a Behavior to this
/// </summary>
public static void AddProjectileBehavior<T>(this Projectile projectile, T behavior) where T : ProjectileBehavior
{
projectile.projectileBehaviors.Add(behavior);
projectile.projectileBehaviors.Add(behavior.Cast<IProjectileBehavior>());
}

/// <summary>
/// Remove the first Behavior of Type T
/// </summary>
public static void RemoveProjectileBehavior<T>(this Projectile projectile) where T : ProjectileBehavior
{
projectile.projectileBehaviors = projectile.projectileBehaviors.RemoveItemOfType<ProjectileBehavior, T>();
projectile.projectileBehaviors = projectile.projectileBehaviors.RemoveItemOfType<IProjectileBehavior, T>();
}

/// <summary>
Expand All @@ -63,6 +63,6 @@ public static void RemoveProjectileBehavior<T>(this Projectile projectile, T beh
/// </summary>
public static void RemoveProjectileBehaviors<T>(this Projectile projectile) where T : ProjectileBehavior
{
projectile.projectileBehaviors = projectile.projectileBehaviors.RemoveItemsOfType<ProjectileBehavior, T>();
projectile.projectileBehaviors = projectile.projectileBehaviors.RemoveItemsOfType<IProjectileBehavior, T>();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Il2CppAssets.Scripts.Simulation.Objects;
using Il2CppAssets.Scripts.Simulation.Towers;
namespace BTD_Mod_Helper.Extensions;

Expand All @@ -11,40 +12,40 @@ public static class TowerBehaviorExt
/// Check if this has a specific Behavior
/// </summary>
public static bool HasTowerBehavior<T>(this Tower tower) where T : TowerBehavior =>
tower.towerBehaviors.HasItemsOfType<TowerBehavior, T>();
tower.towerBehaviors.HasItemsOfType<ITowerBehavior, T>();

/// <summary>
/// Check if this has a specific Behavior
/// </summary>
public static bool HasTowerBehavior<T>(this Tower tower, out T item) where T : TowerBehavior =>
tower.towerBehaviors.HasItemsOfType<TowerBehavior, T>(out item);
tower.towerBehaviors.HasItemsOfType<ITowerBehavior, T>(out item);

/// <summary>
/// Return the first Behavior of type T
/// </summary>
public static T GetTowerBehavior<T>(this Tower tower) where T : TowerBehavior =>
tower.towerBehaviors.GetItemOfType<TowerBehavior, T>();
tower.towerBehaviors.GetItemOfType<ITowerBehavior, T>();

/// <summary>
/// Return all Behaviors of type T
/// </summary>
public static List<T> GetTowerBehaviors<T>(this Tower tower) where T : TowerBehavior =>
tower.towerBehaviors.GetItemsOfType<TowerBehavior, T>();
tower.towerBehaviors.GetItemsOfType<ITowerBehavior, T>();

/// <summary>
/// Add a Behavior to this
/// </summary>
public static void AddTowerBehavior<T>(this Tower tower, T behavior) where T : TowerBehavior
{
tower.towerBehaviors.Add(behavior);
tower.towerBehaviors.Add(behavior.Cast<ITowerBehavior>());
}

/// <summary>
/// Remove the first Behavior of Type T
/// </summary>
public static void RemoveTowerBehavior<T>(this Tower tower) where T : TowerBehavior
{
tower.towerBehaviors = tower.towerBehaviors.RemoveItemOfType<TowerBehavior, T>();
tower.towerBehaviors = tower.towerBehaviors.RemoveItemOfType<ITowerBehavior, T>();
}

/// <summary>
Expand All @@ -60,6 +61,6 @@ public static void RemoveTowerBehavior<T>(this Tower tower, T behavior) where T
/// </summary>
public static void RemoveTowerBehaviors<T>(this Tower tower) where T : TowerBehavior
{
tower.towerBehaviors = tower.towerBehaviors.RemoveItemsOfType<TowerBehavior, T>();
tower.towerBehaviors = tower.towerBehaviors.RemoveItemsOfType<ITowerBehavior, T>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void Clear<T>(this Il2CppReferenceArray<T> referenceArray) where T
{
for (var i = 0; i < referenceArray.Length; i++)
{
referenceArray[i] = default;
referenceArray[i] = default!;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static LockList<T> ToLockList<T>(this System.Collections.Generic.List<T>
/// Return as LockList
/// </summary>
public static RootObjectLockList<T> ToRootObjectLockList<T>(this System.Collections.Generic.List<T> list)
where T : RootObject
where T : Il2CppObjectBase
{
var lockList = new RootObjectLockList<T>();
foreach (var item in list)
Expand Down
Loading

0 comments on commit aa8b7a3

Please sign in to comment.