ludic/packages/ludic.vehicles/kinds.ludic
Orkuncakilkaya 045bf22e10 feat(ecs): ludic.vehicles on a Table<Vehicle>
The vehicles are rows of a ludic.base Table with kind and owner as columns, every player's own by
an owner index and a nid map: vehicle_of walks only that player's rows, vehicle_by_nid is a map
lookup, and a player who leaves has their rows removed instead of the whole list rebuilt. ve_add
takes the owner, so the owner is filed once and never assigned around the table. Positions stay
on the record: a boat moves every frame and there are at most two a player. vehicles_test holds
the table (9 tests); the game builds against it and lab/unit passes (88 tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 21:50:23 +03:00

42 lines
1.6 KiB
Text

# kinds.ludic - what can be ridden, a vehicle, and what happened to one
export const VEHICLE_HORSE: int = 1 # land only: stamina for a gallop, hay to go at all
export const VEHICLE_BOAT: int = 3 # water only (2 was a machine the wilderness has no place for)
export const VEHICLE_PLACES: int = 4 # berths on the pier head, bays at the rail
export property Vehicle {
kind: int = 0
nid: int = 0 # its id across machines
x: float = 0.0
y: float = 0.0
z: float = 0.0
yaw: float = 0.0
speed: float = 0.0
fuel: float = 0.0 # a horse's stamina, 0..100
food: float = 0.0 # a horse's hay, 0..100
seat_h: float = 0.0 # the rider sits this far above it
owned: bool = false # hired or rented for the trip
owner: int = 0 # the player it belongs to (0: this machine's)
rider: int = -1 # the player on it, -1 nobody
home_x: float = 0.0 # a horse is tied where its home is
home_z: float = 0.0
ent: int = -1 # its handle in the table
tab: Table<Vehicle> = null
}
export const VEHICLE_MOUNTED: int = 0
export const VEHICLE_DISMOUNTED: int = 1
export const VEHICLE_NO_LANDING: int = 2 # no shore near enough to step onto
export const VEHICLE_MOVED: int = 3 # v: metres covered this frame by the rider
export const VEHICLE_SWELL: int = 4 # the edge's swell is taking the stroke; every 14 s
export const VEHICLE_HUNGRY: int = 5 # a horse without hay will not go
export const VEHICLE_FED: int = 6
export property VehicleFact {
what: int = 0
nid: int = 0
kind: int = 0
owner: int = 0
x: float = 0.0
z: float = 0.0
v: float = 0.0
}