-
Notifications
You must be signed in to change notification settings - Fork 7
Example Mods
Goorakh edited this page Oct 24, 2021
·
5 revisions
Adds an upgrade that enables mag boots for the character that has the upgrade:
[MainModClass]
public class Main : Mod
{
protected override void OnModEnabled()
{
addUpgrade();
}
protected override void OnModRefreshed()
{
addUpgrade();
}
// Can be essentially any number, but must be different from every other upgrade type
const UpgradeType UPGRADE_TYPE = (UpgradeType)82765014;
void addUpgrade()
{
// If the upgrade type is already registered, don't add it again
if (UpgradeManager.Instance.IsUpgradeTypeAndLevelUsed(UPGRADE_TYPE))
return;
UpgradeDescription myCoolUpgrade = new GameObject("MyCoolUpgrade").AddComponent<UpgradeDescription>();
myCoolUpgrade.UpgradeName = "A cool upgrade"; // The name of the upgrade
myCoolUpgrade.Description = "It's cool!"; // The description of the upgrade
myCoolUpgrade.SkillPointCostDefault = 3; // The cost of the upgrade (default 1)
myCoolUpgrade.UpgradeType = UPGRADE_TYPE; // The UpgradeType of the upgrade
myCoolUpgrade.Level = 1; // The level of the upgrade
myCoolUpgrade.Requirement = UpgradeManager.Instance.GetUpgrade(UpgradeType.EnergyCapacity, 2); // The first requirement of the upgrade (optional)
myCoolUpgrade.Requirement2 = UpgradeManager.Instance.GetUpgrade(UpgradeType.AimTime, 2); // The second requirement of the upgrade (optional)
myCoolUpgrade.Icon = UpgradeManager.Instance.GetUpgrade(UpgradeType.SummonAlly).Icon; // The icon of the upgrade
UpgradeManager.Instance.AddUpgrade(myCoolUpgrade, this);
}
// Called when a FirstPersonMover refreshes their upgrades
protected override void OnUpgradesRefreshed(FirstPersonMover owner, UpgradeCollection upgrades)
{
// NOTE: This is executed for every FirstPersonMover, so if something should only apply to the player, check owner.IsMainPlayer() first.
// This is also executed whenever any upgrade is applied, so it will be run multiple times
if (upgrades.HasUpgrade(UPGRADE_TYPE))
{
owner.SetIsUsingMagBoots(true);
}
}
}
