Skip to main content

DestroyableStaticObject

A class in Root.Township, Alta.Networking.

A modifiable static world object (such as a breakable wall) that takes hit damage while modified and reverts to unmodified when its health runs out. Server only.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private float currentHealthHealth left before the object reverts.
private ImpactDetector[] detectorsImpact detectors that pass hits to Hit.
private Dictionary<ImpactType, float> impactTypeMultipliersDamage multiplier per impact type, built from multipliers.
private float modifiedHealthHealth the object gets each time it becomes modified.
private AttackTypeMultiplier[] multipliersDamage multipliers per attack type.

Methods​

MemberWhat it is
protected override void OnValidate()Editor: fills detectors from child impact detectors if empty.
protected override void Start()Waits for ModifiableStaticManager to finish initializing before running Initialize.
3 private and internal methods
MemberWhat it is
private void Hit(ImpactHit impact)Server: applies impact damage, scaled by attack type and armour multipliers, and unmodifies the object at 0 health.
private void Initialize(NetworkEntity entity = null)Server: hooks the impact detectors and modified event and loads the attack type multipliers, once the static manager is ready.
private void Modified(ModifiableStaticObject self)Resets health to modifiedHealth when the object becomes modified.