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:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -1,43 +1,43 @@
|
|||
# system.ludic - gear as a system: the burn each tick, and the levels and charges saved by key (the
|
||||
# hand is not saved: a trip opens with empty hands)
|
||||
export function gear_reset(base_st: mut BaseState, gear_st: mut GearState) -> void {
|
||||
gear__ensure(gear_st)
|
||||
for k in 0 .. GEAR_COUNT { gear_st.gear__lv[k] = GearKinds[k].start }
|
||||
export function gear_reset() -> void {
|
||||
gear__ensure()
|
||||
for k in 0 .. GEAR_COUNT { gear__lv[k] = GearKinds[k].start }
|
||||
for c in 0 .. CHARGE_COUNT {
|
||||
gear_st.gear__left[c] = GearCharges[c].full
|
||||
gear_st.gear__on[c] = false
|
||||
gear__left[c] = GearCharges[c].full
|
||||
gear__on[c] = false
|
||||
}
|
||||
gear_st.gear__hand = -1
|
||||
q_clear(base_st, gear_facts(base_st, gear_st))
|
||||
gear__hand = -1
|
||||
q_clear(gear_facts())
|
||||
}
|
||||
|
||||
export function gear_save(gear_st: mut GearState) -> Val {
|
||||
gear__ensure(gear_st)
|
||||
export function gear_save() -> Val {
|
||||
gear__ensure()
|
||||
let v = Value.object()
|
||||
let lv = Value.object()
|
||||
for k in 0 .. GEAR_COUNT { sv_put_int(lv, GearKinds[k].key, gear_st.gear__lv[k]) }
|
||||
for k in 0 .. GEAR_COUNT { sv_put_int(lv, GearKinds[k].key, gear__lv[k]) }
|
||||
Value.put(v, "levels", lv)
|
||||
let ch = Value.object()
|
||||
for c in 0 .. CHARGE_COUNT { sv_put_float(ch, GearCharges[c].key, gear_st.gear__left[c]) }
|
||||
for c in 0 .. CHARGE_COUNT { sv_put_float(ch, GearCharges[c].key, gear__left[c]) }
|
||||
Value.put(v, "charges", ch)
|
||||
return v
|
||||
}
|
||||
|
||||
# a kind the file does not name starts where a new trip does; then what the pack carries counts
|
||||
export function gear_load(base_st: mut BaseState, gear_st: mut GearState, v: Val, version: int) -> void {
|
||||
gear_reset(base_st, gear_st)
|
||||
export function gear_load(v: Val, version: int) -> void {
|
||||
gear_reset()
|
||||
if Value.has(v, "levels") != 0 {
|
||||
let lv = Value.get(v, "levels")
|
||||
for k in 0 .. GEAR_COUNT { gear_st.gear__lv[k] = sv_int(lv, GearKinds[k].key, GearKinds[k].start) }
|
||||
for k in 0 .. GEAR_COUNT { gear__lv[k] = sv_int(lv, GearKinds[k].key, GearKinds[k].start) }
|
||||
}
|
||||
if Value.has(v, "charges") != 0 {
|
||||
let ch = Value.get(v, "charges")
|
||||
for c in 0 .. CHARGE_COUNT { gear_charge_set(gear_st, c, sv_float(ch, GearCharges[c].key, GearCharges[c].full)) }
|
||||
for c in 0 .. CHARGE_COUNT { gear_charge_set(c, sv_float(ch, GearCharges[c].key, GearCharges[c].full)) }
|
||||
}
|
||||
gear_sync(gear_st)
|
||||
gear_sync()
|
||||
}
|
||||
|
||||
function gear__tick(base_st: mut BaseState, gear_st: mut GearState, t: Tick) -> void { gear__burn(base_st, gear_st, t.hours) }
|
||||
function gear__tick(t: Tick) -> void { gear__burn(t.hours) }
|
||||
|
||||
export function gear_system() -> System {
|
||||
let s = system_new("gear", PH_SIMULATE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue