ludic.things: things_spare_warm - spare records made up front, so play takes them from the first placement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 12:09:52 +03:00
parent 32050879a1
commit 93e6954fb1
2 changed files with 11 additions and 0 deletions

View file

@ -62,3 +62,9 @@ export function thing_slot(t: Thing) -> int {
if t == null or t.ent < 0 { return -1 }
return t.ent & ECS_SLOT
}
# spare records made now, up to `n` waiting: a world that will place Things in play takes them
# from the first placement instead of making new ones until enough have been removed
export function things_spare_warm(things_st: mut ThingsState, n: int) -> void {
while things_spare_count(things_st) < n { push(things_st.th_spare, new Thing) }
}

View file

@ -240,5 +240,10 @@ program ThingsTest {
expect(things_spare_count(things_st) <= 33)
things_reserve(things_st, 5000)
expect_eq(things_verify(things_st), 0)
things_spare_warm(things_st, 96)
expect_eq(things_spare_count(things_st), 96)
let warm = thing_put(things_st, TH_SIGN, "sign", 9.0, 9.0, 0.0, 0.0, 2.0, 2)
expect_eq(things_spare_count(things_st), 95)
expect_eq(thing_nearest(things_st, TH_SIGN, 9.0, 9.0).uid, warm.uid)
}
}