Skip to content

five-on-it / packages/sim/src/locks

packages/sim/src/locks ​

Vehicles' owners and locks (GAME_DESIGN §6.3). Every vehicle has an owner: nobody, a player (by client id), an NPC (by entity) or a mission; and a lock, shut or open, whose key is an item answering to the car's key tag (SimWorld.locks, usually key:vehicle:<id>: the shape the phone's RentaCar app hands over). Who owns what:

  • a vehicle is spawned nobody's and open, in its own colour (spawnVehicle); whoever spawns it says otherwise: a player's car at their spawn is theirs (they take its wheel first), ambient traffic is its NPC driver's, a mission's car is the mission's, a level's parked car (spawners.ts) nobody's or an NPC's, locked unless it says not;
  • taking the wheel of a car nobody owns makes it the driver's; a player who takes the wheel of an NPC's car makes it theirs (stolen); another player's car and a mission's stay whose they were;
  • a car a player carjacks or picks the lock of is theirs from then on, whoever's it was.

A locked car opens to its owner, and to whoever carries its key: the interaction key says Unlock, which unlocks it for good and gets in. Anyone else finds it Locked, and holding the key for PICK's seconds picks the lock (interaction.ts), which the police count as a crime when somebody sees it. A carjack is by force: the lock does not stop it. Missions and spawners lock and unlock cars; the snapshots carry the owner and the lock to every client, for the prompt and the HUD.

Interfaces ​

Type Aliases ​

Variables ​

Functions ​