five-on-it / packages/sim/src/nails
packages/sim/src/nails
Nail strips laid on the road (GAME_DESIGN §12: the police's at three stars), beside the level's own (LevelData.nailStrips): an entity each, with a pose (its centre on the road, turned to the heading of the road it crosses) and a length, no body and no collider, so nothing but a tyre ever meets one. A tyre that rolls over one goes flat as on the level's (vehicle.ts), within a metre and a half of its height, so a strip on a bridge leaves the street under it alone. The server lays them and picks them up (@foi/ai's police): one is thrown from a kerb and unrolls across the road, its end at the kerb staying put, in a second or so, and is reeled in the same way (nailSystem, every tick before the cars, so a tyre meets it as long as it is then); the snapshots carry them as they are, and every client's world has a twin of each, kept to the snapshot's length (setNailStrip), so its prediction pops the tyres the server will.