-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80924e4
commit 9aa6923
Showing
4 changed files
with
226 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
using Il2CppAssets.Scripts.Models; | ||
using Il2CppAssets.Scripts.Models.Towers.Behaviors.Abilities; | ||
using Il2CppAssets.Scripts.Utils; | ||
namespace BTD_Mod_Helper.Api.Helpers; | ||
|
||
/// <summary> | ||
/// A wrapper around AbilityModels for making them easier to create | ||
/// </summary> | ||
public class AbilityHelper : ModelHelper<AbilityModel> | ||
{ | ||
/// Default name | ||
/// <seealso cref="AbilityModel.displayName"/> | ||
public string DisplayName | ||
{ | ||
get => Model.displayName; | ||
set => Model.displayName = value; | ||
} | ||
|
||
/// Default name | ||
/// <seealso cref="AbilityModel.description"/> | ||
public string Description | ||
{ | ||
get => Model.description; | ||
set => Model.description = value; | ||
} | ||
|
||
/// Default -1 | ||
/// <seealso cref="AbilityModel.animation"/> | ||
public int Animation | ||
{ | ||
get => Model.animation; | ||
set => Model.animation = value; | ||
} | ||
|
||
/// Default 0 | ||
/// <seealso cref="AbilityModel.AnimationOffset"/> | ||
public float AnimationOffset | ||
{ | ||
get => Model.AnimationOffset; | ||
set => Model.AnimationOffset = value; | ||
} | ||
|
||
/// Default "" | ||
/// <seealso cref="AbilityModel.icon"/> | ||
public string Icon | ||
{ | ||
get => Model.icon.guidRef; | ||
set => Model.icon.guidRef = value; | ||
} | ||
|
||
/// Default { guidRef = "" } | ||
/// <seealso cref="AbilityModel.icon"/> | ||
public SpriteReference IconReference | ||
{ | ||
get => Model.icon; | ||
set => Model.icon = value; | ||
} | ||
|
||
/// Default 0 | ||
/// <seealso cref="AbilityModel.Cooldown"/> | ||
public float Cooldown | ||
{ | ||
get => Model.Cooldown; | ||
set => Model.Cooldown = value; | ||
} | ||
|
||
/// Default null | ||
/// <seealso cref="AbilityModel.behaviors"/> | ||
public Model[] Behaviors | ||
{ | ||
get => Model.behaviors ?? new Il2CppReferenceArray<Model>(0); | ||
set | ||
{ | ||
Model.RemoveChildDependants(Model.behaviors); | ||
Model.behaviors = value; | ||
Model.AddChildDependants(Model.behaviors); | ||
} | ||
} | ||
|
||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.activateOnPreLeak"/> | ||
public bool ActivateOnPreLeak | ||
{ | ||
get => Model.activateOnPreLeak; | ||
set => Model.activateOnPreLeak = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.activateOnLeak"/> | ||
public bool ActivateOnLeak | ||
{ | ||
get => Model.activateOnLeak; | ||
set => Model.activateOnLeak = value; | ||
} | ||
|
||
/// Default "" | ||
/// <seealso cref="AbilityModel.addedViaUpgrade"/> | ||
public string AddedViaUpgrade | ||
{ | ||
get => Model.addedViaUpgrade; | ||
set => Model.addedViaUpgrade = value; | ||
} | ||
|
||
/// Default 0 | ||
/// <seealso cref="AbilityModel.CooldownSpeedScale" /> | ||
public float CooldownSpeedScale | ||
{ | ||
get => Model.CooldownSpeedScale; | ||
set => Model.CooldownSpeedScale = value; | ||
} | ||
|
||
/// Default 0 | ||
/// <seealso cref="AbilityModel.livesCost" /> | ||
public int LivesCost | ||
{ | ||
get => Model.livesCost; | ||
set => Model.livesCost = value; | ||
} | ||
|
||
/// Default -1 | ||
/// <seealso cref="AbilityModel.maxActivationsPerRound" /> | ||
public int MaxActivationsPerRound | ||
{ | ||
get => Model.maxActivationsPerRound; | ||
set => Model.maxActivationsPerRound = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.resetCooldownOnTierUpgrade" /> | ||
public bool ResetCooldownOnTierUpgrade | ||
{ | ||
get => Model.resetCooldownOnTierUpgrade; | ||
set => Model.resetCooldownOnTierUpgrade = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.activateOnLivesLost" /> | ||
public bool ActivateOnLivesLost | ||
{ | ||
get => Model.activateOnLivesLost; | ||
set => Model.activateOnLivesLost = value; | ||
} | ||
|
||
/// Default true | ||
/// <seealso cref="AbilityModel.enabled" /> | ||
public bool Enabled | ||
{ | ||
get => Model.enabled; | ||
set => Model.enabled = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.canActivateBetweenRounds" /> | ||
public bool CanActivateBetweenRounds | ||
{ | ||
get => Model.canActivateBetweenRounds; | ||
set => Model.canActivateBetweenRounds = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.sharedCooldown" /> | ||
public bool SharedCooldown | ||
{ | ||
get => Model.sharedCooldown; | ||
set => Model.sharedCooldown = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.dontShowStacked" /> | ||
public bool DontShowStacked | ||
{ | ||
get => Model.dontShowStacked; | ||
set => Model.dontShowStacked = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.animateOnMainAttackDisplay" /> | ||
public bool AnimateOnMainAttackDisplay | ||
{ | ||
get => Model.animateOnMainAttackDisplay; | ||
set => Model.animateOnMainAttackDisplay = value; | ||
} | ||
|
||
/// Default false | ||
/// <seealso cref="AbilityModel.restrictAbilityAfterMaxRoundTimer" /> | ||
public bool RestrictAbilityAfterMaxRoundTimer | ||
{ | ||
get => Model.restrictAbilityAfterMaxRoundTimer; | ||
set => Model.restrictAbilityAfterMaxRoundTimer = value; | ||
} | ||
|
||
private AbilityHelper(AbilityModel model) : base(model) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Begins construction of a new AttackModel with sensible default values | ||
/// <param name="name">The model name (don't need the AbilityModel_ part)</param> | ||
/// </summary> | ||
public AbilityHelper | ||
(string name = "") : base(new AbilityModel(name, name, name, -1, 0, new SpriteReference {guidRef = ""}, 0, null, | ||
false, false, "", 0, 0, -1, false, false)) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Unwraps the model | ||
/// </summary> | ||
public static implicit operator AbilityModel(AbilityHelper helper) => helper.Model; | ||
|
||
/// <summary> | ||
/// Wraps a model | ||
/// </summary> | ||
public static implicit operator AbilityHelper(AbilityModel model) => new(model); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
- Now natively works on Epic Games version, and prompts user to download the compatability plugin to make other mods work if they don't have it | ||
- Added ModHelperData `bool Plugin` field for mods that are MelonPlugins | ||
- Fixed SteamWebView usage on the Epic Games version | ||
- Fixed a crash that could happen on Linux (thanks @GrahamKracker) | ||
- Fixed more crashes from TowerInventory / subtower interactions (thanks @Onixiya) | ||
- Added `AttackHelper`, `WeaponHelper` and `ProjectileHelper` that can be used to less painfully create those models | ||
from scratch | ||
- The classes will implicitly convert themselves to their respective models | ||
- Make use of the object initialization syntax; don't need to specific every single field, will use sensible defaults | ||
- Added `AbilityHelper` class | ||
- Reverted a previous change that was leading to a selling / rebuying 5th tiers issue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9aa6923
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah