ludic.things: a Thing's dawn (the last day a restock reached it, saved); things_restock takes the day; things_catch_up restocks a chunk's Things that missed a dawn once a morning would reach them, as that morning would have

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 21:14:42 +03:00
parent 0634116d59
commit b053bf625c
7 changed files with 57 additions and 8 deletions

View file

@ -64,14 +64,18 @@ export function things_tick(things_st: mut ThingsState, hours: float) -> void {
}
}
# a restock: every Thing the world grew is back, and loses its `used` unless its kind keeps it;
# what was put down is left as it is
export function things_restock(things_st: ThingsState) -> void {
# a restock on `day`: every Thing the world grew where a morning reaches is back, and loses its
# `used` unless its kind keeps it; what was put down is left as it is
export function things_restock(things_st: ThingsState, day: int) -> void {
let all = things_all(things_st)
for i in 0 .. len(all) {
let t = all[i]
if thing_is_put_down(t) or not ThingsWorld.restocks(t.x, t.z) { continue }
if not ThingKinds[t.kind].keeps { t.used = 0 }
if not t.active { thing_show(t) }
th_restock_one(t, day)
}
}
function th_restock_one(t: Thing, day: int) -> void {
if not ThingKinds[t.kind].keeps { t.used = 0 }
if not t.active { thing_show(t) }
t.dawn = day
}