Table of Contents
Class for adding a custom Tower to the game. Use alongside ModUpgrade to define its upgrades,
and optionally ModTowerDisplay to define custom displays for it.
public abstract class ModTower : BTD_Mod_Helper.Api.NamedModContent
Inheritance System.Object ModContent NamedModContent ModTower
Derived
↳ ModHero
↳ ModSubTower
↳ ModTower<T>
↳ ModVanillaParagon
The string to use for the Magic tower set
protected const string MAGIC = "Magic";
The string to use for the Military tower set
protected const string MILITARY = "Military";
The string to use for the Primary tower set
protected const string PRIMARY = "Primary";
The string to use for the Support tower set
protected const string SUPPORT = "Support";
Whether to always make this tower be included in challenges / Bosses / Odysseys etc
public virtual bool AlwaysIncludeInChallenge { get; }
The id of the default BTD Tower that your Tower is going to be copied from by default.
public abstract string BaseTower { get; }
The number of upgrades the tower has in it's 3rd / bottom path
public virtual int BottomPathUpgrades { get; }
The in game cost of this tower (on Medium difficulty)
public abstract int Cost { get; }
Makes this Tower not actually add itself to the shop, useful for making subtowers
public virtual bool DontAddToShop { get; }
Hotkey to use for placing this tower from the shop
public virtual BTD_Mod_Helper.Api.ModOptions.ModSettingHotkey Hotkey { get; }
The Icon for the Tower's purchase button, by default "[Name]-Icon"
(Name of .png or .jpg, not including file extension)
public virtual string Icon { get; }
If you're not going to use a custom .png for your Icon, use this to directly control its SpriteReference
public virtual SpriteReference IconReference { get; }
Il2CppNinjaKiwi.Common.ResourceUtils.SpriteReference
Whether this tower should be allowed to be included in Monkey Teams
public virtual bool IncludeInMonkeyTeams { get; }
The number of upgrades the tower has in it's 2nd / middle path
public virtual int MiddlePathUpgrades { get; }
Defines whether / how this ModTower has a Paragon
public virtual BTD_Mod_Helper.Api.Towers.ParagonMode ParagonMode { get; }
For 2D towers, the ratio between pixels and display units. Higher number -> smaller tower.
public virtual float PixelsPerUnit { get; }
The Portrait for the 0-0-0 tower, by default "[Name]-Portrait"
(Name of .png or .jpg, not including file extension)
public virtual string Portrait { get; }
If you're not going to use a custom .png for your Portrait, use this to directly control its SpriteReference
public virtual SpriteReference PortraitReference { get; }
Il2CppNinjaKiwi.Common.ResourceUtils.SpriteReference
How many of this tower you can buy at once during a game. By default -1 for no limit.
public virtual int ShopTowerCount { get; }
The number of upgrades the tower has in it's 1st / top path
public virtual int TopPathUpgrades { get; }
The family of Monkeys that your Tower should be put in.
For now, just use one of the default constants provided of PRIMARY, MILITARY, MAGIC, or SUPPORT.
public abstract TowerSet TowerSet { get; }
Il2CppAssets.Scripts.Models.TowerSets.TowerSet
Whether this Tower should display 2-dimensionally, and search for png images
public virtual bool Use2DModel { get; }
Gets the scale to use for a 2d tower at the given tiers
public virtual float Get2DScale(params int[] tiers);
tiers
System.Int32[]
If this is a 2D tower, gets the name of the .png to use for a given set of tiers
Default Behavior Example: For CardMonkey with tiers 2-3-0, it would try (in order):
CardMonkey-230, CardMonkey-X3X, CardMonkey-2XX, CardMonkey
public virtual string Get2DTexture(params int[] tiers);
tiers
System.Int32[]
Allows you to change the base TowerModel your tower will use at different tiers. Note that you'd need to be
careful if you entirely changed the base tower you're working with at different tiers, as it will still attempt
to apply all the appropriate upgrades. If you would like a ModUpgrade to only have an effect at a given tier,
you could do something like:
public override void ApplyUpgrade(TowerModel towerModel) {
if (towerModel.tiers[Path] != Tier) return;
...
}
public virtual TowerModel GetBaseTowerModel(params int[] tiers);
tiers
System.Int32[]
Length 3 array of Top/Mid/Bot tiers
Il2CppAssets.Scripts.Models.Towers.TowerModel
The base TowerModel to use
Gets the portrait reference this tower should use for the given tiers
Looks for the highest tier ModUpgrade this tower has that defined a
PortraitReference,
falling back to the tower's own base PortraitReference by default.
public SpriteReference GetPortraitReferenceForTiers(params int[] tiers);
tiers
System.Int32[]
Il2CppNinjaKiwi.Common.ResourceUtils.SpriteReference
When adding this tower to the shop, gets the index at which to add the tower relative to the existing ones.
By default, the tower will be put at the end of the TowerSet category that it's in.
public virtual int GetTowerIndex(System.Collections.Generic.List<TowerDetailsModel> towerSet);
towerSet
System.Collections.Generic.List<Il2CppAssets.Scripts.Models.TowerSets.TowerDetailsModel>
Creates an UpgradePathModel for a particular upgrade and new tiers
public virtual UpgradePathModel GetUpgradePathModel(BTD_Mod_Helper.Api.Towers.ModUpgrade modUpgrade, int[] newTiers);
modUpgrade
ModUpgrade
The upgrade
newTiers
System.Int32[]
The new desired tiers of the tower
Il2CppAssets.Scripts.Models.Towers.Upgrades.UpgradePathModel
Allows you to override whether an UpgradePath should be closed or not for a tower
public virtual System.Nullable<bool> IsUpgradePathClosed(TowerToSimulation tower, int path, bool defaultClosed);
tower
Il2CppAssets.Scripts.Unity.Bridge.TowerToSimulation
The TowerToSimulation
path
System.Int32
What path this is for
defaultClosed
System.Boolean
Whether it'd be naturally closed or not
System.Nullable<System.Boolean>
Whether the upgrade path should be closed, or null for no change
Another way to modify the allowable crosspaths for your tower. By default, checks that the highest tier is at
most 5, the next highest is at most 2, and the last one is 0
Used in the default implementation of TowerTiers()
public virtual bool IsValidCrosspath(params int[] tiers);
tiers
System.Int32[]
Allows you to override how many possible Upgrade pips it should show as being possible for a tower to get
public virtual System.Nullable<int> MaxUpgradePips(TowerToSimulation tower, int path, int defaultMax);
tower
Il2CppAssets.Scripts.Unity.Bridge.TowerToSimulation
The TowerToSimulation
path
System.Int32
What path this is for
defaultMax
System.Int32
The default maximum
System.Nullable<System.Int32>
The new maximum amount of upgrade pips, or null for no change
Implemented by a ModTower to modify the base tower model before applying any/all ModUpgrades
Things like the TowerModel's name, cost, tier, and upgrades are already taken care of before this point
public abstract void ModifyBaseTowerModel(TowerModel towerModel);
towerModel
Il2CppAssets.Scripts.Models.Towers.TowerModel
The Base Tower Model
Further modifies this tower when you go into a new match.
Useful for making conditional effects happen based on settings.
The normal ApplyUpgrade effects for all upgrades will have already been applied on game start,
so this will simply modify all the TowerModels for this ModTower.
public virtual void ModifyTowerModelForMatch(TowerModel towerModel, GameModel gameModel);
towerModel
Il2CppAssets.Scripts.Models.Towers.TowerModel
gameModel
Il2CppAssets.Scripts.Models.GameModel
Further modifies this tower when you go into a new match.
Useful for making conditional effects happen based on settings.
The normal ApplyUpgrade effects for all upgrades will have already been applied on game start,
so this will simply modify all the TowerModels for this ModTower.
public virtual void ModifyTowerModelForMatch(TowerModel towerModel, System.Collections.Generic.IReadOnlyList<ModModel> gameModes);
towerModel
Il2CppAssets.Scripts.Models.Towers.TowerModel
gameModes
System.Collections.Generic.IReadOnlyList<Il2CppAssets.Scripts.Models.ModModel>
Returns all the valid tiers for the TowerModels of this Tower
public virtual System.Collections.Generic.IEnumerable<int[]> TowerTiers();