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.
- Listed in Creatures and AI
- Inherits or implements
Agent<FireBug>,IReceiveImpulseFromCollision - Derived types
FireBug - Documented in Other creatures, Creature data, Creatures and AI
Constructors
| Member | What it is |
|---|---|
FireBug() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
24 private and internal fields
| Member | What it is |
|---|---|
private ParticleSystem androidEffects | Particle system for Android set in the inspector. Not used in this build. |
private GameObject dragTrackingObject | Object turned on while drag tracking is enabled. |
private ParticleSystem effects | Particles that play while the bug is shaken hard enough. |
private static ActionSet<FireBug> emergeAction | Static action set the bug starts in, built from the first bug's emergeActionSet. |
private ActionComponentSet emergeActionSet | Action set asset for emerging, used for every bug via the static emergeAction. |
private float flailingAngularDrag | Angular drag set by IncreaseDrag. Default 1. |
private float flailingDrag | Drag set by IncreaseDrag. Default 1. |
private static ActionSet<FireBug> loseControlAction | Static action set used after a collision knocks the bug about. |
private ActionComponentSet loseControlActionSet | Action set asset for losing control. |
private float minimumShakeToActivateEffects | Shake strength above which the particles and trail turn on. Default 0.7. |
private PickupAgent pickupAgent | The PickupAgent that lets the bug be caught and released. |
private static ActionSet<FireBug> regainControlAction | Static action set used after the bug is released. |
private ActionComponentSet regainControlActionSet | Action set asset for regaining control. |
private ShakeDetectorHelper shakeDetector | Helper measuring how hard the bug's rigidbody is shaken. Not created on a headless server. |
private ShakeDetectorFactory shakeDetectorSettings | Factory settings for the shake detector. |
private PlatformLight shakeLight | Light whose intensity and range follow the shake strength. |
private AnimationCurve shakeStrenghtToLightIntensity | Curve from shake strength to light intensity. |
private AnimationCurve shakeStrenghtToLightRange | Curve from shake strength to light range. |
private IUnityUpdateMethod shakeUpdate | The registered UpdateShake or FadeLight update. |
private PooledObjectDefinition sparkEffect | Spark effect played where the bug dies. |
private float sparkRadius | Radius of the fire-lighting sparks the server makes on death. Default 0.5. |
private MethodSyncStruct<bool> syncDrag | Network sync for the drag tracking flag. |
private TrailRenderer trail | Trail turned on while the bug is shaken hard enough. |
private static UpdateModule updateModule | Shared "Firebug shake" fixed update module. |
Methods
| Member | What 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
| Member | What 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. |