feat(ludic.tracks): prints, their age and reading them as a mechanic package

A ring of prints per kind; a port for the trip's time, the reader's tier, a
bearing in words and a hook the game draws each print through. A read is a
TrackRead fact on tracks_reads() every time and a count the first time; other
sign is told with tracks_note. The count and last bearing are its save section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 04:54:43 +03:00
parent 093ca0d260
commit bf73f7edaf
10 changed files with 487 additions and 0 deletions

View file

@ -0,0 +1,47 @@
# queries.ludic - what the world asks the ground. A slot is kind * cap + ring index.
export function tracks_kinds() -> int { return tk_kinds }
export function tracks_cap() -> int { return tk_cap }
export function tracks_count(kind: int) -> int {
if not tk_ok(kind) { return 0 }
return tk_count[kind]
}
export function tracks_slot(kind: int, i: int) -> int { return kind * tk_cap + i }
export function tracks_x(slot: int) -> float { return tk_ring[slot].x }
export function tracks_z(slot: int) -> float { return tk_ring[slot].z }
export function tracks_yaw(slot: int) -> float { return tk_ring[slot].yaw }
export function tracks_sp(slot: int) -> int { return tk_ring[slot].sp }
export function tracks_legend(slot: int) -> bool { return tk_ring[slot].legend }
export function tracks_made(slot: int) -> float { return tk_ring[slot].made }
export function tracks_was_read(slot: int) -> bool { return tk_ring[slot].read }
# game hours since it was made; never below 0
export function tracks_age(slot: int) -> float { return Math.max(0.0, tk_now() - tk_ring[slot].made) }
# the nearest print within `r` of (x, z), as a slot; -1 when there is none
export function tracks_nearest(x: float, z: float, r: float) -> int {
var best = r * r
var at = -1
for k in 0 .. tk_kinds {
for i in 0 .. tk_count[k] {
let t = tk_ring[k * tk_cap + i]
let dx = t.x - x
let dz = t.z - z
let d2 = dx * dx + dz * dz
if d2 < best {
best = d2
at = k * tk_cap + i
}
}
}
return at
}
# signs read for the first time, of every source
export function tracks_read_count() -> int { return tk_read_n }
# the heading of the last sign read, and whether there has been one
export function tracks_last_yaw() -> float { return tk_yaw }
export function tracks_has_bearing() -> bool { return tk_has_yaw }