refactor(packages): 0.R5 - a question no longer starts its state - 64 lazy starts ('if st.x == null { st.x = ... }' inside a getter) are the state's defaults, gear__ensure is gone, and ludic migrate state --tighten took mut off 208 package parameters: things_all, thing_find, gear_charge, gear_level, jobs_state and the rest read

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 00:51:03 +03:00
parent 54f5efb23f
commit 9862ec82e3
102 changed files with 320 additions and 351 deletions

View file

@ -3,7 +3,7 @@
# on: this machine's own walkers leave, and only the host's are drawn until it is turned off
export function npc_mirror(npc_st: mut NpcState, on: bool) -> void {
np_ensure(npc_st)
np_ensure()
if npc_st.np_mirror == on { return }
npc_st.np_mirror = on
for i in 0 .. len(npc_st.np_walkers) { npc_retire(npc_st, npc_st.np_walkers[i]) }
@ -14,7 +14,7 @@ export function npc_mirroring(npc_st: NpcState) -> bool { return npc_st.np_mirro
# the host's slot: somebody new in it (born), or nobody (gone)
export function npc_put(npc_st: mut NpcState, slot: int, id: int, kind: int, look: int, seed: float, name: string, hx: float, hz: float) -> NpcPerson {
np_ensure(npc_st)
np_ensure()
if slot < 0 or slot >= npc_st.np_max or kind < 0 or kind >= NPCK_COUNT { return null }
while len(npc_st.np_walkers) <= slot {
let q = new NpcPerson
@ -36,7 +36,7 @@ export function npc_put(npc_st: mut NpcState, slot: int, id: int, kind: int, loo
}
# where the host says it is now, and what it is doing
export function npc_heard(npc_st: mut NpcState, slot: int, x: float, y: float, z: float, yaw: float, speed: float, act: int, stalk: bool) -> void {
export function npc_heard(npc_st: NpcState, slot: int, x: float, y: float, z: float, yaw: float, speed: float, act: int, stalk: bool) -> void {
let p = npc_at(npc_st, slot)
if p == null or not p.active { return }
if not p.heard {
@ -60,7 +60,7 @@ export function npc_heard(npc_st: mut NpcState, slot: int, x: float, y: float, z
export function npc_heard_lately(npc_st: NpcState, p: NpcPerson) -> bool { return p.heard and npc_st.np_clock - p.heard_t <= 6.0 }
export function npc_mirror_tick(npc_st: mut NpcState, dt: float) -> void {
np_ensure(npc_st)
np_ensure()
npc_st.np_clock = npc_st.np_clock + dt
let k = Math.min(1.0, dt * 8.0)
for i in 0 .. len(npc_st.np_walkers) {