Skip to content

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

packages/sim/src/doors ​

The level's doors (GAME_DESIGN §5.5): one entity per door of the level (LevelData.doors), created with the world in the level's order, so the server's and every client's are the same and a snapshot names a door by its index. A door is a panel on a fixed body: shut, it stands across its doorway and blocks it; open, it is swung a quarter turn about its hinge, the doorway's −x end in its own frame, to one side or the other, and its collider with it, so the doorway is clear. Locked, it stays shut unless the interaction key comes with its key (interaction.ts); locked by a keypad (DOOR_KEYPAD), the key asks for its code, which the server's missions check; missions lock and unlock it (the server's word reaches the clients in the snapshots).

Two more kinds work the same way (DoorDef.kind): a gate slides aside along its width, toward its hinge end, instead of swinging; a barrier is a car park's arm, a bar as thick as the door is deep at the height the door's height says, lifted upright about its hinge to open. Both also open by themselves (gateSystem, the server's: the clients see the snapshots) for a car that comes up to them, either side, when its driver carries what opens them (anything when they are not locked; a key, a keycard, a ticket for a barrier locked by one; never a keypad's code), and shut again once the way has been clear for a moment. On foot the interaction key opens them like a door.

Variables ​

Functions ​