Skip to main content

PlayerUnlock

A class in Root.Township, the global namespace.

Asset for something a player can unlock. It can raise the maximum of a stat on the player, list prerequisite unlocks and describe orb visuals on the body.

Constructors​

MemberWhat it is
PlayerUnlock()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

3 private and internal fields
MemberWhat it is
private PlayerUnlock.OrbProperties[] orbsBacking field for Orbs: orb prefabs, bones, positions and scales for this unlock.
private List<PlayerUnlock> prerequisitesBacking field for Prerequisites.
private PlayerUnlock.UnlockingPermissionsSetup unlockingPermissionsBacking field for UnlockingPermissions: teleport and climb layer overrides and the max stat bonus.

Properties​

MemberWhat it is
PlayerUnlock.OrbProperties[] Orbs { get; }Orb visuals for this unlock: prefab, weight, bone, position and scale.
IEnumerable<PlayerUnlock> Prerequisites { get; }Unlocks needed before this one.
PlayerUnlock.UnlockingPermissionsSetup UnlockingPermissions { get; }What the unlock changes: optional teleport and climb layer overrides, and the max stat change.

Methods​

MemberWhat it is
void ApplyTo(Player player)Adds the configured amount to the stat's maximum and base value, and again whenever the player gets a new controller.
void RemoveFrom(Player player)Takes back the stat change and stops reapplying it on new controllers.
3 private and internal methods
MemberWhat it is
private bool CanUpdateMaxStat(Player player)True when the player controller has health with a stat manager.
private bool CanUpdateMaxStat(PlayerController playerController)True when the player controller has health with a stat manager.
private void UpdatePlayerController(Player player, PlayerController playerController)Raises the unlock's max stat (range and base) on a new player controller. Runs on ApplyTo and each controller change.

Used in​

Members of other types that take, return or hold a PlayerUnlock: