Skip to main content

TreeDecay

A class in Root.Township, Alta.Woodcutting.

Server decay for a WoodcutTree: once the tree has no chunking parent its decay timer runs, scaled by tree size, and it won't decay within two minutes of being hit.

Constructors​

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

Fields​

2 private and internal fields
MemberWhat it is
private TimeSpan lastDamageTimeline time of the last hit.
private WoodcutTree treeThe tree this decays.

Properties​

MemberWhat it is
protected override float TimerMultiplier { get; }The tree's total size, so bigger trees probably take longer to decay.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Gets the WoodcutTree before the base setup.
protected override void DecayFailed()Restarts the timer when decay was refused because of recent damage.
protected override void FinishInitialize()Hooks the tree's cut and damage events and checks its state a frame later.
protected override bool IsDecayValid(bool isStarting)Allowed when the base allows it, the rigidbody isn't kinematic, and it's starting or 120 seconds have passed since the last hit.
2 private and internal methods
MemberWhat it is
private void CheckCut(WoodcutTree tree)On a cut, starts or shortens the timer if the tree has no chunking parent, otherwise cancels it.
private void PartTookDamage(WoodcutTree tree, float damage)Records the time of the last hit.