Skip to main content

FireBug

A class in Root.Township, Alta.Intelligence.

The firebug creature: a catchable bug that glows and trails when shaken and throws sparks when killed. Its AI switches between emerge, regain-control and lose-control action sets.

Constructors​

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

Fields​

24 private and internal fields
MemberWhat it is
private ParticleSystem androidEffectsParticle system for Android set in the inspector. Not used in this build.
private GameObject dragTrackingObjectObject turned on while drag tracking is enabled.
private ParticleSystem effectsParticles that play while the bug is shaken hard enough.
private static ActionSet<FireBug> emergeActionStatic action set the bug starts in, built from the first bug's emergeActionSet.
private ActionComponentSet emergeActionSetAction set asset for emerging, used for every bug via the static emergeAction.
private float flailingAngularDragAngular drag set by IncreaseDrag. Default 1.
private float flailingDragDrag set by IncreaseDrag. Default 1.
private static ActionSet<FireBug> loseControlActionStatic action set used after a collision knocks the bug about.
private ActionComponentSet loseControlActionSetAction set asset for losing control.
private float minimumShakeToActivateEffectsShake strength above which the particles and trail turn on. Default 0.7.
private PickupAgent pickupAgentThe PickupAgent that lets the bug be caught and released.
private static ActionSet<FireBug> regainControlActionStatic action set used after the bug is released.
private ActionComponentSet regainControlActionSetAction set asset for regaining control.
private ShakeDetectorHelper shakeDetectorHelper measuring how hard the bug's rigidbody is shaken. Not created on a headless server.
private ShakeDetectorFactory shakeDetectorSettingsFactory settings for the shake detector.
private PlatformLight shakeLightLight whose intensity and range follow the shake strength.
private AnimationCurve shakeStrenghtToLightIntensityCurve from shake strength to light intensity.
private AnimationCurve shakeStrenghtToLightRangeCurve from shake strength to light range.
private IUnityUpdateMethod shakeUpdateThe registered UpdateShake or FadeLight update.
private PooledObjectDefinition sparkEffectSpark effect played where the bug dies.
private float sparkRadiusRadius of the fire-lighting sparks the server makes on death. Default 0.5.
private MethodSyncStruct<bool> syncDragNetwork sync for the drag tracking flag.
private TrailRenderer trailTrail turned on while the bug is shaken hard enough.
private static UpdateModule updateModuleShared "Firebug shake" fixed update module.

Methods​

MemberWhat it is
void DecreaseDrag()Sets the rigidbody to zero drag and low angular drag.
void EnableDragTracking(bool hasDrag)Turns the drag tracking object on or off. The server syncs it to clients.
void EndShakeUpdate()Stops the shake or light-fade update.
void IncreaseDrag()Sets the rigidbody to the flailing drag values.
override void Initialize()Sets up the drag sync message.
protected override void Awake()Stops effects and hooks the PickupAgent caught and released events. Sets up the shake detector when not headless.
protected override void InitializeAi()Starts on the emerge action set and makes the pickup not save.
protected override void InitializeStatic()Builds the shared emerge, regain and lose control action sets.
protected override void Killed(HealthObject healthobject)Plays the death spark. On the server, simulates fire sparks within sparkRadius and sets the animator's IsAlive to false.
protected override void OnDestroy()Stops the shake update.
protected override void OnValidate()Editor: rebuilds the shake detector.
6 private and internal methods
MemberWhat it is
private void Caught()When the bug is grabbed, off headless, starts the shake update that drives its light and effects.
private void FadeLight()Update after release: keeps updating the shake effects until the shake strength reaches 0, then stops.
private void Alta.Intelligence.IReceiveImpulseFromCollision.ReceivedImpulse(float strength)When hit by a collision while enabled, the server switches to the lose control set and decides again; a client makes the rigidbody non-kinematic.
private void Released(Interactor interactor)On release, the server switches to the regain control set; the releasing client turns drag tracking on. Off headless, starts FadeLight.
private void SyncDrag(IPlayer player, Stream stream, bool hasDrag)Network handler (SyncA) that sends the drag tracking flag and applies it on clients.
private void UpdateShake()Measures the shake, sets the light's intensity and range from it, and turns particles and trail on or off around minimumShakeToActivateEffects.