Skip to main content

SparkSecondaryDetector

A class in Root.Township, Alta.Impact.

Makes sparks when certain colliders are struck on spark channels, which can light nearby flammables. The wielding client reports its hit and the server runs the sparks.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private ImpactDetector baseDetectorThe impact detector whose hits are checked.
private Collider[] collidersColliders that make sparks when struck.
private ImpactDetectorSettings hitSettingsSettings used to play the hit effects.
private float maximumFireChanceChance to light at full effectiveness.
private float minimumFireChanceChance to light at zero effectiveness.
private float radiusRadius of the spark check.
private ImpactChannel[] sparkChannelsImpact channels that can make sparks.
private MethodSyncStruct<SparkSecondaryDetector.SparkArgument> syncSparkSynced method that sends sparks from client to server.

Methods​

MemberWhat it is
override void Initialize()Hooks the base detector's hits on the server or client side and sets up the spark message.
5 private and internal methods
MemberWhat it is
private void ClientSpark(ImpactHit hit)Client: on a valid hit by the local player's tool, sends the spark to the server and plays effects.
private void OnDrawGizmosSelected()Draws the spark radius in the editor.
private void ServerSpark(ImpactHit hit)Server: on a valid hit, runs Fire.SimulateSparks at the hit point.
private void SyncSpark(IPlayer player, Stream stream, SparkSecondaryDetector.SparkArgument arguments)Sends the hit point (relative, within 10 m) and effectiveness; the server runs Fire.SimulateSparks on receipt.
private bool ValidateHit(ImpactHit hit)True if the hit is on a spark channel and struck one of colliders.