feat(packages): ludic.compass - bearing marks on a strip: marks gathered once a frame from an open registry of providers (CompassProviders), gated by the viewer's tier, sorted tracked / note / plain and culled to a cap; bearings and distances off the viewer's facing, the tracked mark, a capture that lets a guide hear the providers whatever the tier, the eight points, and the radar's range per tier with blips on a unit disc; the viewer through a port
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dc71fc986c
commit
1005a677f2
10 changed files with 453 additions and 0 deletions
56
packages/ludic.compass/gather.ludic
Normal file
56
packages/ludic.compass/gather.ludic
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# gather.ludic - a frame's marks: begin, every provider marks, end sorts and culls. While a
|
||||
# capture is open the marks go to whoever is listening instead, whatever the tier.
|
||||
export function compass_begin() -> void { cmp_list = new []CompassMark }
|
||||
|
||||
# a provider's verb: a thing at (x, z), shown from compass `tier` up
|
||||
export function compass_mark(x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> void {
|
||||
if cmp_list == null { compass_begin() }
|
||||
let m = cmp_new(x, z, icon, colour, tier, prio, label)
|
||||
if cmp_capturing {
|
||||
push(cmp_caught, m)
|
||||
return
|
||||
}
|
||||
if CompassWorld.tier() < tier { return }
|
||||
push(cmp_list, m)
|
||||
}
|
||||
|
||||
# highest priority first, the providers' order kept within one; then the cap
|
||||
export function compass_end() -> void {
|
||||
if cmp_list == null { compass_begin() }
|
||||
let out = new []CompassMark
|
||||
for p in 0 .. 3 {
|
||||
let want = COMPASS_TRACKED - p
|
||||
for i in 0 .. len(cmp_list) { if cmp_band(cmp_list[i].prio) == want and len(out) < cmp_cap { push(out, cmp_list[i]) } }
|
||||
}
|
||||
cmp_list = out
|
||||
}
|
||||
|
||||
function cmp_band(p: int) -> int { return Math.clamp(p, COMPASS_PLAIN, COMPASS_TRACKED) }
|
||||
|
||||
# once a frame: ask every registered provider, in the registry's order
|
||||
export function compass_gather() -> void {
|
||||
compass_begin()
|
||||
if CompassWorld.tier() <= 0 { return }
|
||||
for i in 0 .. COMPASS_FROM_COUNT {
|
||||
let f = CompassProviders[i].gather
|
||||
if f != null { f() }
|
||||
}
|
||||
compass_end()
|
||||
}
|
||||
|
||||
# someone else wants to know where the providers point (a guide's arrow): until the end every
|
||||
# mark is theirs, whatever the tier, and the frame's list is left alone
|
||||
export function compass_capture_begin() -> void {
|
||||
cmp_capturing = true
|
||||
cmp_caught = new []CompassMark
|
||||
}
|
||||
|
||||
export function compass_capture_end() -> []CompassMark {
|
||||
cmp_capturing = false
|
||||
var got = cmp_caught
|
||||
cmp_caught = new []CompassMark
|
||||
if got == null { got = new []CompassMark }
|
||||
return got
|
||||
}
|
||||
|
||||
export function compass_capturing() -> bool { return cmp_capturing }
|
||||
Loading…
Add table
Add a link
Reference in a new issue