Talos docs

RoadProgress

Since 0.7

One entity's progress along a road, from {@link RoadLine.progress}.

Plain text

Signature

export interface RoadProgress {
  /** Distance along the road where the entity is now, as `closest` gives it (0 to `length` on a closed road). */
  readonly s: number
  /** Metres right of the centre line, negative left. */
  readonly offset: number
  /** Laps completed: every checkpoint crossed in order, then the start line. Always 0 on an open road. */
  readonly lap: number
  /**
   * Metres past the start line, laps included, and never past the next checkpoint still owed: what
   * the race order sorts by. Negative behind the line on the grid; `s` on an open road.
   */
  readonly distance: number
  /** The gate to cross next, an index into `gates`; null on a road with no gates. */
  readonly nextGate: number | null
  /** True after going backward along the road for more than 10 m (net of going forward again). */
  readonly wrongWay: boolean
  /** Race position among the entities tracked on this road, 1 for the leader. */
  readonly place: number
}

Import: import type { RoadProgress } from "@argus/api"

Members

MemberSignatureDescription
sreadonly s: numberDistance along the road where the entity is now, as closest gives it (0 to length on a closed road).
offsetreadonly offset: numberMetres right of the centre line, negative left.
lapreadonly lap: numberLaps completed: every checkpoint crossed in order, then the start line. Always 0 on an open road.
distancereadonly distance: numberMetres past the start line, laps included, and never past the next checkpoint still owed: what the race order sorts by. Negative behind the line on the grid; s on an open road.
nextGatereadonly nextGate: number | nullThe gate to cross next, an index into gates; null on a road with no gates.
wrongWayreadonly wrongWay: booleanTrue after going backward along the road for more than 10 m (net of going forward again).
placereadonly place: numberRace position among the entities tracked on this road, 1 for the leader.

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