BusVehicleRecovered
Since 0.7
Payload of the engine-published "vehicle-recovered" event: a vehicle with a recovery block was flipped, stuck, fell out of the world, drowned or broke the physics, and the engine put it back where it can go on (its last good spot, the nearest road, or upright where it was).
Raised at the top of the tick after the move; by is null. What a game turns into a fade, a sound or a penalty. ts ctx.events.on("vehicle-recovered", (ev) => { if (ev.data.entity === ctx.entity.id) ctx.audio.play("respawn") })
Signature
export interface BusVehicleRecovered {
/** Id of the vehicle. */
entity: string
/** What set it off: flipped, stuck, fell, in water, or a physics fault. */
why: VehicleRecoveryWhy
/** Where it was, `[x, y, z]`. */
from: Vec3
/** Where it was put. */
position: Vec3
}
Import: import type { BusVehicleRecovered } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
entity | entity: string | Id of the vehicle. |
why | why: VehicleRecoveryWhy | What set it off: flipped, stuck, fell, in water, or a physics fault. |
from | from: Vec3 | Where it was, [x, y, z]. |
position | position: Vec3 | Where it was put. |
Example
The tested fixture fixtures/app/agent.ts.
import type { Behavior } from "@argus/api"
// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
init(ctx) {
ctx.state.arrived = false
ctx.nav?.goTo(ctx.props.target as [number, number, number])
},
update(ctx) {
if (ctx.nav?.arrived) ctx.state.arrived = true
},
} satisfies Behavior