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>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 21:50:23 +03:00
parent 52270ab5d1
commit 045bf22e10
8 changed files with 87 additions and 18 deletions

View file

@ -2,13 +2,14 @@
# and the horse's hay); where they lie is not saved - they are called again. The boats' hulls are
# read back and pushed by the wind in vehicles_tick, which the game calls where the world is run
export function vehicles_reset(vehicles_st: mut VehiclesState) -> void {
if vehicles_st.ve_list != null {
for i in 0 .. len(vehicles_st.ve_list) {
let v = vehicles_st.ve_list[i]
if v.kind == VEHICLE_BOAT { VehicleHull.gone(v.nid) } else { VehicleLegs.gone(v.nid) }
}
let l = ve_all(vehicles_st)
for i in 0 .. len(l) {
let v = l[i]
if v.kind == VEHICLE_BOAT { VehicleHull.gone(v.nid) } else { VehicleLegs.gone(v.nid) }
v.ent = -1
}
vehicles_st.ve_list = new []Vehicle
tb_clear(vehicles_st.ve.tab)
imap_clear(vehicles_st.ve.nids)
vehicles_st.ve_cur = null
vehicles_st.ve_have_dock = false
vehicles_st.ve_swell_said = 0.0