Skip to content

five-on-it / packages/sim/src/components / createComponents

Function: createComponents() ​

createComponents(): object

Defined in: packages/sim/src/components.ts:24

Creates the component arrays of one world.

Returns ​

Camera ​

Camera: object

A security camera of the level (cameras.ts): its index in the level, on, off or destroyed, its hit points.

Camera.health ​

health: Uint8Array<ArrayBuffer>

Camera.index ​

index: Uint16Array<ArrayBuffer>

Camera.state ​

state: Uint8Array<ArrayBuffer>

Character ​

Character: object

A person: a player's character or a pedestrian.

Character.act ​

act: Uint8Array<ArrayBuffer>

What it last did with its hands, for the renderers (acts.ts): an index into ACTS.

Character.actSeq ​

actSeq: Uint8Array<ArrayBuffer>

A counter of its acts (0 to 7), so the same act twice reads as two.

Character.actTicks ​

actTicks: Uint8Array<ArrayBuffer>

Ticks left showing that act; 0 = it is over.

Character.aim ​

aim: Float32Array<ArrayBuffer>

Where the character aims (rad, 0 faces +z).

Character.boardCar ​

boardCar: Int16Array<ArrayBuffer>

The vehicle it is getting in (meaningful while boarding or entering is above 0; -1 on a client's twin).

Character.boardDoor ​

boardDoor: Uint8Array<ArrayBuffer>

Which door it gets in by (an index into the doors boarding.ts lets it use for the seat).

Character.boarding ​

boarding: Uint8Array<ArrayBuffer>

Ticks left to reach the door of the seat it is getting in (boarding.ts); 0 = not on its way to one.

Character.boardSeat ​

boardSeat: Uint8Array<ArrayBuffer>

The seat it is getting in.

Character.body ​

body: Uint8Array<ArrayBuffer>

Its body (character.ts' BODIES): 0 a person's, 1 a dog's (lower, lighter, quicker); set when it is spawned.

Character.by ​

by: Uint16Array<ArrayBuffer>

The client id of the player who last hit it (a shot, a punch, a dart, a car); 0 for none.

Character.climbing ​

climbing: Uint8Array<ArrayBuffer>

The ladder it climbs (ladders.ts): its index in the level's ladders plus one; 0 when it climbs none.

Character.cooking ​

cooking: Uint8Array<ArrayBuffer>

Ticks a grenade has been held with its pin out (0 = none); it goes off at the fuse.

Character.cooldown ​

cooldown: Uint16Array<ArrayBuffer>

Ticks before another enter, exit or reset is accepted.

Character.cover ​

cover: Uint8Array<ArrayBuffer>

Cover: 0 in the open, 1 hidden behind cover (cannot shoot or be shot), 2 popped up out of it.

Character.coverHeld ​

coverHeld: Uint8Array<ArrayBuffer>

The cover key was held last tick (taking cover needs a fresh press).

Character.coverLow ​

coverLow: Uint8Array<ArrayBuffer>

The cover is low (a car's hood, a low wall): hidden means crouching.

Character.coverYaw ​

coverYaw: Float32Array<ArrayBuffer>

Direction into the cover (rad, 0 faces +z): the character moves across it and peeks past its end.

Character.cower ​

cower: Uint8Array<ArrayBuffer>

Cowering where it hides (a target safe in its refuge): crouched in plain sight, 1 while it does.

Character.dart ​

dart: Uint16Array<ArrayBuffer>

Ticks before a tranquilizer dart puts it to sleep (status.ts); 0 = none in it.

Character.down ​

down: Uint16Array<ArrayBuffer>

Ticks left lying knocked down as a tumbling box; 0 = on its feet.

Character.entering ​

entering: Uint8Array<ArrayBuffer>

Ticks left getting in at the door, facing it, before it is seated; 0 = not getting in.

Character.exiting ​

exiting: Uint8Array<ArrayBuffer>

Ticks left standing at the door it just got out of, facing out; 0 = free to go.

Character.fallSpeed ​

fallSpeed: Float32Array<ArrayBuffer>

The fastest it has fallen since it last stood (m/s, downward): what a landing hurts by (character.ts).

Character.ghost ​

ghost: Uint16Array<ArrayBuffer>

Ticks left as a ghost after respawning (griefing.ts): it passes through cars and people and takes no harm; 0 = solid.

Character.grounded ​

grounded: Uint8Array<ArrayBuffer>

Standing on something.

Character.health ​

health: Uint8Array<ArrayBuffer>

Hit points left; 0 = dead, lying down until it respawns.

Character.hostile ​

hostile: Uint8Array<ArrayBuffer>

An enemy: a chaser the AI runs (drawn in its own colour), not a bystander.

Character.indoors ​

indoors: Uint8Array<ArrayBuffer>

Gone indoors (a schedule's home): out of the world, its body disabled, 1 while there.

Character.inside ​

inside: Int16Array<ArrayBuffer>

Vehicle entity it sits in, or -1.

Character.invincible ​

invincible: Uint8Array<ArrayBuffer>

Shrugs off every hit (a debug switch); so does the car it drives.

Character.jackCar ​

jackCar: Int16Array<ArrayBuffer>

The vehicle it is carjacking (meaningful while jackTicks is above 0; -1 on a client's twin).

Character.jackTicks ​

jackTicks: Uint8Array<ArrayBuffer>

Ticks left of a carjack's beat before it takes the wheel (carjack.ts); 0 = not carjacking.

Character.jumpHeld ​

jumpHeld: Uint8Array<ArrayBuffer>

The jump key was held last tick (a jump needs a fresh press).

Character.maxHealth ​

maxHealth: Uint8Array<ArrayBuffer>

Its full hit points, set by a debug switch (setMaxHealth); 0 for its kind's.

Character.opened ​

opened: Int16Array<ArrayBuffer>

The container (a crate, a locker, a car for its trunk, a body for its pockets) it has open, or -1 (interaction.ts).

Character.party ​

party: Uint8Array<ArrayBuffer>

Its party (0 = none; the server numbers a room's parties): a party member is never carjacked nor put out of the car, and under rivals never hurt.

Character.peek ​

peek: Uint8Array<ArrayBuffer>

Popped up out past the end of tall cover (leaning out of it): 1 while there.

Character.pick ​

pick: Uint16Array<ArrayBuffer>

Ticks it has picked a car's lock for, the interaction key held (interaction.ts); 0 = not picking.

Character.pickCar ​

pickCar: Int16Array<ArrayBuffer>

The car whose lock it picks (meaningful while pick is above 0).

Character.police ​

police: Uint8Array<ArrayBuffer>

A police officer the AI runs (@foi/ai's police): drawn as police, and hurting one is a worse crime.

Character.ragdollTicks ​

ragdollTicks: Uint16Array<ArrayBuffer>

Ticks it tumbles when a car knocks it down without killing it.

Character.role ​

role: Uint8Array<ArrayBuffer>

What it is for (GAME_DESIGN §5.4): 0 nothing in particular, 1 a contact (interactables.ts' ROLE_CONTACT), who says "Talk" to the interaction key.

Character.seat ​

seat: Uint8Array<ArrayBuffer>

Seat index while inside (0 = driver).

Character.sitting ​

sitting: Int16Array<ArrayBuffer>

The seat it sits on (sitting.ts: its index among the level's spots), or −1.

Character.slot ​

slot: Uint8Array<ArrayBuffer>

The selected slot of its inventory: the weapon it holds, what the use and drop keys act on (items.ts).

Character.status ​

status: Uint8Array<ArrayBuffer>

Why it lies down (status.ts): stunned, knocked out or asleep; 0 (awake) for any other fall.

Character.stays ​

stays: Uint8Array<ArrayBuffer>

Dead, it stays where it fell instead of coming back (a level's guard, whose body can be found).

Character.stepping ​

stepping: Uint8Array<ArrayBuffer>

Ticks left held level after stepping up a kerb or a stair (character.ts): its stride carries the capsule over the edge before it settles.

Character.swimming ​

swimming: Uint8Array<ArrayBuffer>

Swimming (water.ts): in water over its chest, afloat; 1 while it swims.

Character.weapon ​

weapon: Uint8Array<ArrayBuffer>

The weapon it holds, an index into the weapon table: the selected slot's item's (weapons.ts' heldWeapon).

Character.weaponCooldown ​

weaponCooldown: Uint8Array<ArrayBuffer>

Ticks before the weapon fires again.

Character.yaw ​

yaw: Float32Array<ArrayBuffer>

Facing (rad, 0 faces +z): the aim.

Container ​

Container: object

A crate or a locker (items.ts): its kind's index, and whether it is locked.

Container.kind ​

kind: Uint8Array<ArrayBuffer>

Container.locked ​

locked: Uint8Array<ArrayBuffer>

Door ​

Door: object

A door of the level (doors.ts): its index in the level, open (0 shut, 1 or 2 swung either way), locked (1 by a key's tag, 2 by a keypad's code); a gate's or a barrier's opening for a car (1 while it stands open by itself, to shut once the way is clear) and the ticks the way has been clear.

Door.auto ​

auto: Uint8Array<ArrayBuffer>

Door.clear ​

clear: Uint16Array<ArrayBuffer>

Door.index ​

index: Uint16Array<ArrayBuffer>

Door.locked ​

locked: Uint8Array<ArrayBuffer>

Door.open ​

open: Uint8Array<ArrayBuffer>

NailStrip ​

NailStrip: object

A nail strip laid across a road (nails.ts): its length now and in full (m), how fast it unrolls (m/s; negative reeled in, 0 still), the end that stays put (ax, az, m) and the way it unrolls from there (a unit vector across the road).

NailStrip.ax ​

ax: Float32Array<ArrayBuffer>

NailStrip.az ​

az: Float32Array<ArrayBuffer>

NailStrip.full ​

full: Float32Array<ArrayBuffer>

NailStrip.length ​

length: Float32Array<ArrayBuffer>

NailStrip.rate ​

rate: Float32Array<ArrayBuffer>

NailStrip.ux ​

ux: Float32Array<ArrayBuffer>

NailStrip.uz ​

uz: Float32Array<ArrayBuffer>

NetOwner ​

NetOwner: object

Which client owns the entity (0 = nobody).

NetOwner.clientId ​

clientId: Uint16Array<ArrayBuffer>

Pedestrian ​

Pedestrian: object

A pedestrian's wandering state (server only).

Pedestrian.ahead ​

ahead: Float32Array<ArrayBuffer>

Where a dog on its lead ranges to, in its walker's frame (m): ahead of the walker, and to its left.

Pedestrian.base ​

base: Uint16Array<ArrayBuffer>

Its own node: a commuter's and a jogger's start, a shopkeeper's door's.

Pedestrian.commute ​

commute: Uint8Array<ArrayBuffer>

A commuter going one way only, in at its goal (1: to work, 2: home); 0 walks back and forth.

Pedestrian.dirX ​

dirX: Float32Array<ArrayBuffer>

Walking direction (zero while standing).

Pedestrian.dirZ ​

dirZ: Float32Array<ArrayBuffer>

Pedestrian.dog ​

dog: Uint8Array<ArrayBuffer>

What a dog is doing, an index into DOG_MODES (dogs.ts).

Pedestrian.face ​

face: Float32Array<ArrayBuffer>

The way it faces at its place (a vendor's, a queuer's: the yaw).

Pedestrian.flee ​

flee: Uint16Array<ArrayBuffer>

Ticks left running away from gunfire (0 = not fleeing).

Pedestrian.follow ​

follow: Int16Array<ArrayBuffer>

The person a stray follows (its entity), or −1.

Pedestrian.from ​

from: Uint16Array<ArrayBuffer>

The pavement node it came from.

Pedestrian.goal ​

goal: Uint16Array<ArrayBuffer>

The pavement node it is headed for (a commuter's destination, a jogger's next corner); a shopkeeper's door (an index into the doors).

Pedestrian.homeX ​

homeX: Float32Array<ArrayBuffer>

Where it was spawned: it respawns there, and a range dummy never leaves it.

Pedestrian.homeY ​

homeY: Float32Array<ArrayBuffer>

Pedestrian.homeZ ​

homeZ: Float32Array<ArrayBuffer>

Pedestrian.idle ​

idle: Uint16Array<ArrayBuffer>

Ticks a dog's walker has stood still: it sits after a while.

Pedestrian.lead ​

lead: Uint8Array<ArrayBuffer>

A dog on its lead (1), or off it.

Pedestrian.loopA ​

loopA: Uint16Array<ArrayBuffer>

A jogger's loop: its two other corners.

Pedestrian.loopB ​

loopB: Uint16Array<ArrayBuffer>

Pedestrian.mode ​

mode: Uint8Array<ArrayBuffer>

What it is doing, an index into PEDESTRIAN_MODES.

Pedestrian.node ​

node: Uint16Array<ArrayBuffer>

The pavement node it walks to, or NO_NODE off the pavements (wandering as it likes).

Pedestrian.owner ​

owner: Int16Array<ArrayBuffer>

A dog's walker (its entity), or −1: kept both ways with the walker's pet (dogs.ts).

Pedestrian.pet ​

pet: Int16Array<ArrayBuffer>

A dog walker's dog (its entity), or −1.

Pedestrian.roam ​

roam: Uint8Array<ArrayBuffer>

Wanders (1) or stands at its post as a range dummy (0).

Pedestrian.role ​

role: Uint8Array<ArrayBuffer>

Its role, an index into PEDESTRIAN_ROLES (pedestrians.ts): its look, its walk, its fright.

Pedestrian.side ​

side: Float32Array<ArrayBuffer>

Pedestrian.spot ​

spot: Int16Array<ArrayBuffer>

A vendor's stand, a queuer's stop, a sitter's seat: an index into the level's spots; −1 none.

Pedestrian.stuck ​

stuck: Uint8Array<ArrayBuffer>

Ticks spent walking without getting anywhere.

Pedestrian.taut ​

taut: Uint8Array<ArrayBuffer>

Ticks a sniffing dog's lead has been taut.

Pedestrian.toX ​

toX: Float32Array<ArrayBuffer>

What a dog makes for (m, in the world): the thing it sniffs at, the way it bolts.

Pedestrian.toZ ​

toZ: Float32Array<ArrayBuffer>

Pedestrian.until ​

until: Uint16Array<ArrayBuffer>

Ticks until the next decision.

Pickup ​

Pickup: object

Items lying on the ground (items.ts): which item of the room's table, how many.

Pickup.count ​

count: Uint16Array<ArrayBuffer>

Pickup.item ​

item: Uint16Array<ArrayBuffer>

Piece ​

Piece: object

A light piece of the level (breakables.ts).

Piece.loose ​

loose: Uint8Array<ArrayBuffer>

Knocked loose (1) or planted (0).

Piece.placement ​

placement: Uint16Array<ArrayBuffer>

Its placement's index in the level.

PlayerInput ​

PlayerInput: object

The input applied on the current tick; persists until overwritten. A player's input lands on their character and is forwarded to the vehicle they drive. The fields are those of VehicleInputLike, its flags stored as 0 or 1.

PlayerInput.action ​

action: Uint8Array<ArrayBuffer>

PlayerInput.aim ​

aim: Float32Array<ArrayBuffer>

PlayerInput.aimDistance ​

aimDistance: Float32Array<ArrayBuffer>

PlayerInput.boost ​

boost: Uint8Array<ArrayBuffer>

PlayerInput.cover ​

cover: Uint8Array<ArrayBuffer>

PlayerInput.drop ​

drop: Uint8Array<ArrayBuffer>

PlayerInput.expose ​

expose: Uint8Array<ArrayBuffer>

PlayerInput.fire ​

fire: Uint8Array<ArrayBuffer>

PlayerInput.handbrake ​

handbrake: Uint8Array<ArrayBuffer>

PlayerInput.interact ​

interact: Uint8Array<ArrayBuffer>

PlayerInput.nextClass ​

nextClass: Uint8Array<ArrayBuffer>

PlayerInput.phone ​

phone: Uint8Array<ArrayBuffer>

PlayerInput.reset ​

reset: Uint8Array<ArrayBuffer>

PlayerInput.resetLevel ​

resetLevel: Uint8Array<ArrayBuffer>

PlayerInput.run ​

run: Uint8Array<ArrayBuffer>

PlayerInput.service ​

service: Uint8Array<ArrayBuffer>

PlayerInput.siren ​

siren: Uint8Array<ArrayBuffer>

PlayerInput.slot ​

slot: Uint8Array<ArrayBuffer>

PlayerInput.steer ​

steer: Float32Array<ArrayBuffer>

PlayerInput.target ​

target: Uint8Array<ArrayBuffer>

PlayerInput.throttle ​

throttle: Float32Array<ArrayBuffer>

PlayerInput.transfer ​

transfer: Int16Array<ArrayBuffer>

PlayerInput.use ​

use: Uint8Array<ArrayBuffer>

Projectile ​

Projectile: object

A rocket in flight or a thrown grenade.

Projectile.dx ​

dx: Float32Array<ArrayBuffer>

Flight direction of a rocket (unit, horizontal).

Projectile.dz ​

dz: Float32Array<ArrayBuffer>

Projectile.kind ​

kind: Uint8Array<ArrayBuffer>

Weapon index that fired it.

Projectile.owner ​

owner: Uint16Array<ArrayBuffer>

Client id of the shooter (for colouring).

Projectile.shooter ​

shooter: Uint16Array<ArrayBuffer>

Entity id of the shooter (its body is never hit by its own rocket).

Projectile.ttl ​

ttl: Uint16Array<ArrayBuffer>

Ticks left before it blows up.

Terminal ​

Terminal: object

A terminal (interactables.ts): its kind's index, and what the interaction key says at it (0 use, 1 hack).

Terminal.kind ​

kind: Uint8Array<ArrayBuffer>

Terminal.verb ​

verb: Uint8Array<ArrayBuffer>

Trailer ​

Trailer: object

A trailer: the vehicle towing it.

Trailer.tractor ​

tractor: Int16Array<ArrayBuffer>

Transform ​

Transform: object

World pose, mirrored from Rapier after each step (or written by the projectile system).

Transform.qw ​

qw: Float32Array<ArrayBuffer>

Transform.qx ​

qx: Float32Array<ArrayBuffer>

Transform.qy ​

qy: Float32Array<ArrayBuffer>

Transform.qz ​

qz: Float32Array<ArrayBuffer>

Transform.x ​

x: Float32Array<ArrayBuffer>

Transform.y ​

y: Float32Array<ArrayBuffer>

Transform.z ​

z: Float32Array<ArrayBuffer>

Twin ​

Twin: object

A client's twin of a server entity: a proxy (1) is placed by the snapshots and never simulated (proxy.ts); 0 on the server, and for what a client predicts.

Twin.proxy ​

proxy: Uint8Array<ArrayBuffer>

Vehicle ​

Vehicle: object

A drivable vehicle: its class, its trailer entity (-1 for none), its paint (0 its class's or driver's colour, 1 and up a respray's, garages.ts), who owns it (an index into OWNER_KINDS, locks.ts: nobody, a player, an NPC, a mission) and which one (a player's client id, an NPC's entity), whether it is locked, and whether it has the pursuit tune (1: an interceptor's engine, vehicle-classes.ts' PURSUIT_TUNE).

Vehicle.cls ​

cls: Uint8Array<ArrayBuffer>

Vehicle.locked ​

locked: Uint8Array<ArrayBuffer>

Vehicle.owner ​

owner: Uint8Array<ArrayBuffer>

Vehicle.ownerId ​

ownerId: Uint16Array<ArrayBuffer>

Vehicle.paint ​

paint: Uint8Array<ArrayBuffer>

Vehicle.pursuit ​

pursuit: Uint8Array<ArrayBuffer>

Vehicle.trailer ​

trailer: Int16Array<ArrayBuffer>

VehicleState ​

VehicleState: object

Per-vehicle driving state (trailers use the contact, tyre and speed fields).

VehicleState.actionCooldown ​

actionCooldown: Uint16Array<ArrayBuffer>

Ticks before another reset or class change is accepted.

VehicleState.boost ​

boost: Float32Array<ArrayBuffer>

Boost meter, 1 = full; drains while boosting, refills otherwise.

VehicleState.boosting ​

boosting: Uint8Array<ArrayBuffer>

Boosting this tick.

VehicleState.boostSpent ​

boostSpent: Uint8Array<ArrayBuffer>

The meter ran dry while the boost was still held; cleared once the key is let go of.

VehicleState.fallSpeed ​

fallSpeed: Float32Array<ArrayBuffer>

Largest downward speed seen since the wheels last left the ground (m/s).

VehicleState.fire ​

fire: Uint8Array<ArrayBuffer>

Its fire (fire.ts): 0 none, 1 burning, 2 blown up and still burning, 3 a burnt-out wreck.

VehicleState.fireBy ​

fireBy: Uint16Array<ArrayBuffer>

The client id of whoever set it alight (0 nobody's doing): its blast is theirs.

VehicleState.fuelled ​

fuelled: Uint16Array<ArrayBuffer>

Ticks left of a fill-up's faster boost (fuel.ts): it recharges twice as fast; 0 none.

VehicleState.fuse ​

fuse: Uint16Array<ArrayBuffer>

Ticks of the fire's fuse left (burning), or of the wreck's blaze (blown up).

VehicleState.gripFront ​

gripFront: Float32Array<ArrayBuffer>

Front axle side grip.

VehicleState.gripRear ​

gripRear: Float32Array<ArrayBuffer>

Rear axle side grip.

VehicleState.handbrake ​

handbrake: Uint8Array<ArrayBuffer>

Handbrake held this tick.

VehicleState.health ​

health: Uint8Array<ArrayBuffer>

Hit points left; 0 = wrecked (the car no longer answers its driver).

VehicleState.landing ​

landing: Float32Array<ArrayBuffer>

Seconds of dulled control left after a hard landing.

VehicleState.parked ​

parked: Uint8Array<ArrayBuffer>

The parking brake: 0 driven, 1 parked (nobody has driven it since it was spawned or left), 2 parked and held where it came to rest (parkX, parkY, parkZ).

VehicleState.parkX ​

parkX: Float32Array<ArrayBuffer>

Where a parked car's locked tyres hold it (m).

VehicleState.parkY ​

parkY: Float32Array<ArrayBuffer>

VehicleState.parkZ ​

parkZ: Float32Array<ArrayBuffer>

VehicleState.pendingNextClass ​

pendingNextClass: Uint8Array<ArrayBuffer>

VehicleState.pendingReset ​

pendingReset: Uint8Array<ArrayBuffer>

A reset or a class change asked for during the cooldown, applied when it ends.

VehicleState.pvx ​

pvx: Float32Array<ArrayBuffer>

Last tick's velocity: a sudden change is an impact that costs hit points.

VehicleState.pvy ​

pvy: Float32Array<ArrayBuffer>

VehicleState.pvz ​

pvz: Float32Array<ArrayBuffer>

VehicleState.siren ​

siren: Uint8Array<ArrayBuffer>

The siren wails (a class with a siren, its driver asking for it).

VehicleState.slip ​

slip: Float32Array<ArrayBuffer>

Rear-axle lateral slip (m/s).

VehicleState.speed ​

speed: Float32Array<ArrayBuffer>

Signed forward speed (m/s).

VehicleState.steer ​

steer: Float32Array<ArrayBuffer>

Smoothed steering, -1..1.

VehicleState.tyres ​

tyres: Uint8Array<ArrayBuffer>

Bitmask of flat tyres, bit i = wheel i.

VehicleState.wheelContact ​

wheelContact: Uint8Array<ArrayBuffer>

Bitmask of wheels in contact with the ground.

VehicleState.wheelspin ​

wheelspin: Float32Array<ArrayBuffer>

How hard the driven tyres spin, 0..1.

Velocity ​

Velocity: object

World velocities, mirrored from Rapier after each step.

Velocity.vx ​

vx: Float32Array<ArrayBuffer>

Velocity.vy ​

vy: Float32Array<ArrayBuffer>

Velocity.vz ​

vz: Float32Array<ArrayBuffer>

Velocity.wx ​

wx: Float32Array<ArrayBuffer>

Velocity.wy ​

wy: Float32Array<ArrayBuffer>

Velocity.wz ​

wz: Float32Array<ArrayBuffer>