Skip to main content

StatUpgradeTarget

A class in Root.Township, Alta.StatSystem.

Networked one use item that permanently raises a player's stat (capped at maxValue), and can top up a related stat. Used up on the server and no longer saved.

Constructors​

MemberWhat it is
StatUpgradeTarget()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

10 private and internal fields
MemberWhat it is
private StatDefinition baseStatSecond stat changed on upgrade, used when onUpgradeIncrease isn't none.
private Transform effectOriginWhere the effect and onUpgraded start.
private bool isValidFalse once used.
private float maxValueCap for the target stat's base.
private TransformEvent onUpgradedEvent fired with effectOrigin on upgrade.
private StatUpgradeTarget.StatIncreaseType onUpgradeIncreaseWhat happens to baseStat: nothing, add the same amount, or fill to maximum.
private PooledObjectDefinition statEffectPooled StatUpgradeEffect played on clients.
private MethodSyncStruct<uint> syncPlayerNetwork sync that sends the upgraded player's entity id.
private StatDefinition targetStatThe stat raised.
private float upgradeAmount added to the target stat.

Methods​

MemberWhat it is
override void Initialize()Creates the effect sync.
void UpgradePlayer(IPlayer player)Server: upgrades the player once, then marks the item to not be saved.
void UpgradePlayer(PlayerController player)Server: upgrades the player once, then marks the item to not be saved.
protected void UpgradePlayerInternal(PlayerController player)Adds upgrade to the target stat, raises or fills baseStat, then syncs the effect and fires onUpgraded.
1 private and internal method
MemberWhat it is
private void SyncPlayer(IPlayer player, Stream stream, uint playerEntityIdentifier)Network handler: clients fire onUpgraded and play the upgrade effect from effectOrigin to the player's body.