Talos docs

VehicleWater

Since 0.7

{@link Vehicle.water}: a watercraft's or an amphibious vehicle's water handling, as of the last tick.

Plain text

ts // Spray from the bow at speed, and a thump when the hull slams back down. update(ctx) { const w = ctx.vehicle?.water if (!w) return if (w.bowWet && w.speed > 6) ctx.hud.set("spray", Math.round(w.speed)) if (w.slam > 0) ctx.log("slam", w.slam) }

Signature

export interface VehicleWater {
  /** Forward speed relative to the water under the hull, m/s; negative going astern. */
  readonly speed: number
  /** How far onto the plane the hull is, 0..1. */
  readonly planing: number
  /** The hull's submerged share, 0..1. */
  readonly immersion: number
  /** How much of the handling is the water's, 0..1: 1 afloat, 0 on its wheels. */
  readonly blend: number
  /** True while it is upside down or on its side (tilted past about 100°), until it is back within 60° of upright. */
  readonly capsized: boolean
  /** The bow, world space. */
  readonly bow: Vec3
  /** Whether the bow is under the surface. */
  readonly bowWet: boolean
  /** Whether any thruster is in the water. */
  readonly sternWet: boolean
  /** Total thrust applied, newtons, negative in reverse. */
  readonly thrust: number
  /** The downward speed, m/s, of the hull hitting the water on this tick; 0 on every other tick. */
  readonly slam: number
  /** Slams since the vehicle was built. */
  readonly slams: number
}

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

Members

MemberSignatureDescription
speedreadonly speed: numberForward speed relative to the water under the hull, m/s; negative going astern.
planingreadonly planing: numberHow far onto the plane the hull is, 0..1.
immersionreadonly immersion: numberThe hull's submerged share, 0..1.
blendreadonly blend: numberHow much of the handling is the water's, 0..1: 1 afloat, 0 on its wheels.
capsizedreadonly capsized: booleanTrue while it is upside down or on its side (tilted past about 100°), until it is back within 60° of upright.
bowreadonly bow: Vec3The bow, world space.
bowWetreadonly bowWet: booleanWhether the bow is under the surface.
sternWetreadonly sternWet: booleanWhether any thruster is in the water.
thrustreadonly thrust: numberTotal thrust applied, newtons, negative in reverse.
slamreadonly slam: numberThe downward speed, m/s, of the hull hitting the water on this tick; 0 on every other tick.
slamsreadonly slams: numberSlams since the vehicle was built.

Example

The tested fixture fixtures/app/nudge.ts.

import type { Behavior } from "@argus/api"

// The behavior the allocation and scale benchmarks run: one primitive call per tick and
// nothing else. `translate` is a Rust call, so what this measures on the Rust side is the
// bridge, not the script — which is the point of SPEC's "orchestration, not compute" rule.
export default {
  init(ctx) {
    ctx.state.ticks = 0
  },
  update(ctx, dt) {
    ctx.state.ticks = (ctx.state.ticks as number) + 1
    ctx.entity.translate([0, 0, (ctx.props.speed as number) * dt])
  },
} satisfies Behavior