Skip to main content

SparkImpactDetector

A class in Root.Township, Alta.Impact.

A CraftableImpactDetector that throws sparks when hit, with a chance to light nearby flammables that grows with hit effectiveness. Server only for the sparks.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private float maximumFireChanceFire chance for a fully effective hit. Default 0.5.
private float minimumFireChanceFire chance for a hit with no effectiveness. Default 0.1.
private float radiusRadius around the hit point that sparks reach. Default 0.1.

Methods​

MemberWhat it is
protected override void Awake()Waits for the entity to finish initializing, then calls AddSpark.
4 private and internal methods
MemberWhat it is
private void AddSpark(NetworkEntity entity)Server: once the entity is initialized, subscribes Spark to the detector's Hit event.
private void OnDrawGizmosSelected()Editor: draws the spark radius.
private void OnValidate()Editor: fills in the entity from the parents.
private void Spark(ImpactHit hit)Calls Fire.SimulateSparks at the hit point with a chance lerped from min to max by hit effectiveness.