wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 3eda72e8c2
commit 5ffe50ed02
463 changed files with 72045 additions and 67421 deletions

View file

@ -3,8 +3,8 @@
function th_of(t: Thing, kind: int) -> bool { return kind < 0 or t.kind == kind }
# the first active one of a kind (and of that id, unless id < 0), in the order placed
export function thing_find(things_st: mut ThingsState, kind: int, id: int) -> Thing {
let all = things_all(things_st)
export function thing_find(kind: int, id: int) -> Thing {
let all = things_all()
for i in 0 .. len(all) {
let t = all[i]
if t.active and th_of(t, kind) and (id < 0 or t.id == id) { return t }
@ -12,17 +12,17 @@ export function thing_find(things_st: mut ThingsState, kind: int, id: int) -> Th
return null
}
export function thing_by_uid(things_st: mut ThingsState, uid: int) -> Thing {
let all = things_all(things_st)
export function thing_by_uid(uid: int) -> Thing {
let all = things_all()
for i in 0 .. len(all) { if all[i].uid == uid { return all[i] } }
return null
}
# the nearest active one of a kind to (x, z), or null
export function thing_nearest(things_st: mut ThingsState, kind: int, x: float, z: float) -> Thing {
export function thing_nearest(kind: int, x: float, z: float) -> Thing {
var best: Thing = null
var bd = 0.0
let all = things_all(things_st)
let all = things_all()
for i in 0 .. len(all) {
let t = all[i]
if not t.active or not th_of(t, kind) { continue }
@ -43,9 +43,9 @@ export function thing_dist2(t: Thing, x: float, z: float) -> float {
}
# every active one within r of (x, z), nearest first
export function things_within(things_st: mut ThingsState, x: float, z: float, r: float) -> []Thing {
export function things_within(x: float, z: float, r: float) -> []Thing {
let out = new []Thing
let all = things_all(things_st)
let all = things_all()
for i in 0 .. len(all) {
let t = all[i]
if t.active and thing_dist2(t, x, z) <= r * r { th_insert(out, t, x, z) }
@ -64,17 +64,17 @@ function th_insert(out: []Thing, t: Thing, x: float, z: float) -> void {
}
# every active one of a kind, in the order placed
export function things_each(things_st: mut ThingsState, kind: int) -> []Thing {
export function things_each(kind: int) -> []Thing {
let out = new []Thing
let all = things_all(things_st)
let all = things_all()
for i in 0 .. len(all) { if all[i].active and th_of(all[i], kind) { push(out, all[i]) } }
return out
}
# every one of a kind, active or not
export function things_each_all(things_st: mut ThingsState, kind: int) -> []Thing {
export function things_each_all(kind: int) -> []Thing {
let out = new []Thing
let all = things_all(things_st)
let all = things_all()
for i in 0 .. len(all) { if th_of(all[i], kind) { push(out, all[i]) } }
return out
}