ludic/packages/ludic.compass/marks.ludic
Orkuncakilkaya 19fcf60599 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>
2026-09-25 15:31:34 +03:00

50 lines
1.8 KiB
Text

# marks.ludic - a mark, the providers the game registers, and the frame's list
export const COMPASS_PLAIN: int = 0 # priorities: an ordinary mark
export const COMPASS_NOTE: int = 1 # one the player asked for (a mark of their own)
export const COMPASS_TRACKED: int = 2 # the objective: its distance is shown, at the edge too
export property CompassMark {
x: float = 0.0
z: float = 0.0
icon: int = 0 # the game's key for its picture
colour: int = 0 # the game's key for its colour
tier: int = 1 # the least compass that shows it
prio: int = 0
label: string = ""
}
# a provider says where its things are by calling compass_mark; the game fills the registry
# (`def CompassProviders story { gather: fn story_marks }`) and they are asked in its order
export property CompassProvider {
key: string = ""
gather: fn() -> void = null
}
export open registry CompassProviders of CompassProvider as COMPASS_FROM
export state CompassState {
cmp_cap: int = 64
cmp_list: []CompassMark = null # this frame's, sorted and culled
cmp_capturing: bool = false
cmp_caught: []CompassMark = null # what providers said while someone was listening
cmp_ranges: []float = null
cmp_radar_from: int = 2 # marks of at least this tier are blips; the tracked one always is
}
# how many marks a frame keeps (the lowest priorities go first past it)
export function compass_config(compass_st: mut CompassState, cap: int) -> void {
compass_st.cmp_cap = Math.max(cap, 1)
compass_begin(compass_st)
}
function cmp_new(x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
let m = new CompassMark
m.x = x
m.z = z
m.icon = icon
m.colour = colour
m.tier = tier
m.prio = prio
m.label = label
return m
}