wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5ffe50ed02
commit
19fcf60599
459 changed files with 17862 additions and 17603 deletions
|
|
@ -1,44 +1,43 @@
|
|||
# mirror.ludic - a guest draws the host's people: no routine and no census here, a slot filled or
|
||||
# emptied as the host says, and each one eased toward where it was last heard to be
|
||||
var np_clock: float = 0.0
|
||||
|
||||
# on: this machine's own walkers leave, and only the host's are drawn until it is turned off
|
||||
export function npc_mirror(on: bool) -> void {
|
||||
np_ensure()
|
||||
if np_mirror == on { return }
|
||||
np_mirror = on
|
||||
for i in 0 .. len(np_walkers) { npc_retire(np_walkers[i]) }
|
||||
if not on { npc_census_now() }
|
||||
export function npc_mirror(npc_st: mut NpcState, on: bool) -> void {
|
||||
np_ensure(npc_st)
|
||||
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]) }
|
||||
if not on { npc_census_now(npc_st) }
|
||||
}
|
||||
|
||||
export function npc_mirroring() -> bool { return np_mirror }
|
||||
export function npc_mirroring(npc_st: NpcState) -> bool { return npc_st.np_mirror }
|
||||
|
||||
# the host's slot: somebody new in it (born), or nobody (gone)
|
||||
export function npc_put(slot: int, id: int, kind: int, look: int, seed: float, name: string, hx: float, hz: float) -> NpcPerson {
|
||||
np_ensure()
|
||||
if slot < 0 or slot >= np_max or kind < 0 or kind >= NPCK_COUNT { return null }
|
||||
while len(np_walkers) <= slot {
|
||||
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)
|
||||
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
|
||||
q.slot = len(np_walkers)
|
||||
push(np_walkers, q)
|
||||
q.slot = len(npc_st.np_walkers)
|
||||
push(npc_st.np_walkers, q)
|
||||
}
|
||||
let p = np_walkers[slot]
|
||||
let p = npc_st.np_walkers[slot]
|
||||
if p.active and p.id == id { return p }
|
||||
if p.active { npc_retire(p) }
|
||||
if p.active { npc_retire(npc_st, p) }
|
||||
np_fresh(p, kind, look)
|
||||
p.id = id
|
||||
p.seed = seed
|
||||
p.name = name
|
||||
npc_set_at(p, hx, hz)
|
||||
p.active = true
|
||||
np_n += 1
|
||||
npc_st.np_n += 1
|
||||
NpcWorld.born(p)
|
||||
return p
|
||||
}
|
||||
|
||||
# where the host says it is now, and what it is doing
|
||||
export function npc_heard(slot: int, x: float, y: float, z: float, yaw: float, speed: float, act: int, stalk: bool) -> void {
|
||||
let p = npc_at(slot)
|
||||
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 {
|
||||
let p = npc_at(npc_st, slot)
|
||||
if p == null or not p.active { return }
|
||||
if not p.heard {
|
||||
p.x = x
|
||||
|
|
@ -47,7 +46,7 @@ export function npc_heard(slot: int, x: float, y: float, z: float, yaw: float, s
|
|||
p.yaw = yaw
|
||||
}
|
||||
p.heard = true
|
||||
p.heard_t = np_clock
|
||||
p.heard_t = npc_st.np_clock
|
||||
p.nx = x
|
||||
p.ny = y
|
||||
p.nz = z
|
||||
|
|
@ -58,15 +57,15 @@ export function npc_heard(slot: int, x: float, y: float, z: float, yaw: float, s
|
|||
}
|
||||
|
||||
# heard from in the last six seconds: drawn; not, and it is not drawn until it is again
|
||||
export function npc_heard_lately(p: NpcPerson) -> bool { return p.heard and np_clock - p.heard_t <= 6.0 }
|
||||
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(dt: float) -> void {
|
||||
np_ensure()
|
||||
np_clock = np_clock + dt
|
||||
export function npc_mirror_tick(npc_st: mut NpcState, dt: float) -> void {
|
||||
np_ensure(npc_st)
|
||||
npc_st.np_clock = npc_st.np_clock + dt
|
||||
let k = Math.min(1.0, dt * 8.0)
|
||||
for i in 0 .. len(np_walkers) {
|
||||
let p = np_walkers[i]
|
||||
if not p.active or not npc_heard_lately(p) { continue }
|
||||
for i in 0 .. len(npc_st.np_walkers) {
|
||||
let p = npc_st.np_walkers[i]
|
||||
if not p.active or not npc_heard_lately(npc_st, p) { continue }
|
||||
let ox = p.x
|
||||
let oz = p.z
|
||||
p.x = p.x + (p.nx - p.x) * k
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue