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
| Member | What it is |
|---|
SparkImpactDetector() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
3 private and internal fields
| Member | What it is |
|---|
private float maximumFireChance | Fire chance for a fully effective hit. Default 0.5. |
private float minimumFireChance | Fire chance for a hit with no effectiveness. Default 0.1. |
private float radius | Radius around the hit point that sparks reach. Default 0.1. |
Methods
| Member | What it is |
|---|
protected override void Awake() | Waits for the entity to finish initializing, then calls AddSpark. |
4 private and internal methods
| Member | What 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. |