Talos docs

ViewModel

Since 0.6
Plain text

Signature

export class ViewModel {
  readonly config: ViewModelConfig
  readonly screen: string
  offset: Vec2 = [0, 0]
  constructor(config: ViewModelConfig)
  show(ctx: Ctx, ...names: string[]): void
  shown(): string[]
  update(ctx: Ctx, bob: BobState | null): void
  hide(ctx: Ctx): void
  box(name: string, offset: Vec2 = this.offset): [number, number, number, number]
}

Import: import { ViewModel } from "@argus/gameplay"

Members

MemberSignatureDescription
configreadonly config: ViewModelConfig
screenreadonly screen: string
offsetoffset: Vec2 = [0, 0]The bob offset last drawn, in virtual pixels.
constructorconstructor(config: ViewModelConfig)
showshow(ctx: Ctx, ...names: string[]): voidDraw exactly these frames from now on. An unknown name throws, naming the ones there are.
shownshown(): string[]The frames drawn now.
updateupdate(ctx: Ctx, bob: BobState | null): voidOnce a tick, after the camera rig: put the screen up when play is live, and place the frames.
hidehide(ctx: Ctx): voidStop drawing until the next update: the view is not first-person any more.
boxbox(name: string, offset: Vec2 = this.offset): [number, number, number, number]Where a frame's box sits on the canvas, in percent: [left, top, width, height].