turretsKit.package
README.md
turretsKit.brain
A turret's mind, built on Watchful Minds' state machine (aiKit.fsm) and shaped like
aiKit's own turret preset: it sweeps its arc, locks on to what it can engage, keeps
aiming at the last spot for a moment when the target is lost, then sweeps again.
The machine runs only on the peer in charge of the turret. The turretsKit.Turret
component creates it with new and supplies the verbs it calls on the runtime r:
r:scan(dt), r:aimAt(c, dt), r:engage(c, dt), r:sweep(dt), r:stopFiring() and
r:passiveTick(dt).
States
| State | Machine | What it does |
|---|---|---|
sweep | active | Nothing to engage: swings back and forth across the arc. Goes to track on a target. |
track | active | Turns onto the target (its lead point) and fires when lined up. Goes to hold when it is lost. |
hold | active | Stops firing and keeps aiming where the target was for HOLD_TIME (or r.holdTime); back to track if re-acquired, else sweep. |
idle | passive | Support beacons and walls: no aiming, runs r:passiveTick(dt). |
Fields
SWEEP,SWEEP_SPEED: sweep width (degrees) and speed, read from aiKit'sturretpreset (sweep/sweepSpeed), falling back to 80 and 35.HOLD_TIME:1.0second.ACTIVE: theturretsKit.turretmachine definition (sweep / track / hold).PASSIVE: theturretsKit.passivemachine definition (idle).
Functions
new(r: any, passive: boolean): any: creates a machine for runtimer(passive for support and wall roles), stores it inr.machineand returns it.