Merge branch 'lang/ecs' into lang/uifree
This commit is contained in:
commit
d7b449869e
5 changed files with 36 additions and 27 deletions
|
|
@ -45,6 +45,9 @@ story_marks()
|
||||||
let marks = compass_capture_end()
|
let marks = compass_capture_end()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The list and its marks are the compass's own, reused, and good until the next capture begins: read
|
||||||
|
them then, or copy what must last longer.
|
||||||
|
|
||||||
## The port
|
## The port
|
||||||
|
|
||||||
```ludic
|
```ludic
|
||||||
|
|
|
||||||
26
packages/ludic.compass/capture.ludic
Normal file
26
packages/ludic.compass/capture.ludic
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# capture.ludic - 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(compass_st: mut CompassState) -> void {
|
||||||
|
if compass_st.cmp_caught == null {
|
||||||
|
compass_st.cmp_caught = new []CompassMark
|
||||||
|
compass_st.cmp_cpool = new []CompassMark
|
||||||
|
}
|
||||||
|
List.clear(compass_st.cmp_caught)
|
||||||
|
compass_st.cmp_cused = 0
|
||||||
|
compass_st.cmp_capturing = true
|
||||||
|
}
|
||||||
|
|
||||||
|
# what was caught: the compass's own list and marks, good until the next capture begins
|
||||||
|
export function compass_capture_end(compass_st: mut CompassState) -> []CompassMark {
|
||||||
|
compass_st.cmp_capturing = false
|
||||||
|
if compass_st.cmp_caught == null { compass_st.cmp_caught = new []CompassMark }
|
||||||
|
return compass_st.cmp_caught
|
||||||
|
}
|
||||||
|
|
||||||
|
# the capture pool's next mark, filled (one made only when the pool is short)
|
||||||
|
function cmp_catch(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
|
||||||
|
if compass_st.cmp_cpool == null { compass_st.cmp_cpool = new []CompassMark }
|
||||||
|
if compass_st.cmp_cused >= len(compass_st.cmp_cpool) { push(compass_st.cmp_cpool, new CompassMark) }
|
||||||
|
compass_st.cmp_cused += 1
|
||||||
|
return cmp_fill(compass_st.cmp_cpool[compass_st.cmp_cused - 1], x, z, icon, colour, tier, prio, label)
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ export function compass_begin(compass_st: mut CompassState) -> void {
|
||||||
export function compass_mark(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> void {
|
export function compass_mark(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> void {
|
||||||
if compass_st.cmp_list == null { compass_begin(compass_st) }
|
if compass_st.cmp_list == null { compass_begin(compass_st) }
|
||||||
if compass_st.cmp_capturing {
|
if compass_st.cmp_capturing {
|
||||||
push(compass_st.cmp_caught, cmp_new(x, z, icon, colour, tier, prio, label)) # kept by the listener
|
push(compass_st.cmp_caught, cmp_catch(compass_st, x, z, icon, colour, tier, prio, label))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if CompassWorld.tier() < tier { return }
|
if CompassWorld.tier() < tier { return }
|
||||||
|
|
@ -38,16 +38,8 @@ export function compass_end(compass_st: mut CompassState) -> void {
|
||||||
# the pool's next mark, filled (one made only when the pool is short)
|
# the pool's next mark, filled (one made only when the pool is short)
|
||||||
function cmp_take(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
|
function cmp_take(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
|
||||||
if compass_st.cmp_used >= len(compass_st.cmp_pool) { push(compass_st.cmp_pool, new CompassMark) }
|
if compass_st.cmp_used >= len(compass_st.cmp_pool) { push(compass_st.cmp_pool, new CompassMark) }
|
||||||
let m = compass_st.cmp_pool[compass_st.cmp_used]
|
|
||||||
compass_st.cmp_used += 1
|
compass_st.cmp_used += 1
|
||||||
m.x = x
|
return cmp_fill(compass_st.cmp_pool[compass_st.cmp_used - 1], x, z, icon, colour, tier, prio, label)
|
||||||
m.z = z
|
|
||||||
m.icon = icon
|
|
||||||
m.colour = colour
|
|
||||||
m.tier = tier
|
|
||||||
m.prio = prio
|
|
||||||
m.label = label
|
|
||||||
return m
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cmp_band(p: int) -> int { return Math.clamp(p, COMPASS_PLAIN, COMPASS_TRACKED) }
|
function cmp_band(p: int) -> int { return Math.clamp(p, COMPASS_PLAIN, COMPASS_TRACKED) }
|
||||||
|
|
@ -63,19 +55,4 @@ export function compass_gather(compass_st: mut CompassState) -> void {
|
||||||
compass_end(compass_st)
|
compass_end(compass_st)
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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(compass_st: mut CompassState) -> void {
|
|
||||||
compass_st.cmp_capturing = true
|
|
||||||
compass_st.cmp_caught = new []CompassMark
|
|
||||||
}
|
|
||||||
|
|
||||||
export function compass_capture_end(compass_st: mut CompassState) -> []CompassMark {
|
|
||||||
compass_st.cmp_capturing = false
|
|
||||||
var got = compass_st.cmp_caught
|
|
||||||
compass_st.cmp_caught = new []CompassMark
|
|
||||||
if got == null { got = new []CompassMark }
|
|
||||||
return got
|
|
||||||
}
|
|
||||||
|
|
||||||
export function compass_capturing(compass_st: CompassState) -> bool { return compass_st.cmp_capturing }
|
export function compass_capturing(compass_st: CompassState) -> bool { return compass_st.cmp_capturing }
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,6 @@ import "ludic.base"
|
||||||
import "ports.ludic"
|
import "ports.ludic"
|
||||||
import "marks.ludic"
|
import "marks.ludic"
|
||||||
import "gather.ludic"
|
import "gather.ludic"
|
||||||
|
import "capture.ludic"
|
||||||
import "bearing.ludic"
|
import "bearing.ludic"
|
||||||
import "radar.ludic"
|
import "radar.ludic"
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ export state CompassState {
|
||||||
cmp_used: int = 0
|
cmp_used: int = 0
|
||||||
cmp_capturing: bool = false
|
cmp_capturing: bool = false
|
||||||
cmp_caught: []CompassMark = null # what providers said while someone was listening
|
cmp_caught: []CompassMark = null # what providers said while someone was listening
|
||||||
|
cmp_cpool: []CompassMark = null # the capture's marks, reused from one capture to the next
|
||||||
|
cmp_cused: int = 0
|
||||||
cmp_ranges: []float = null
|
cmp_ranges: []float = null
|
||||||
cmp_radar_from: int = 2 # marks of at least this tier are blips; the tracked one always is
|
cmp_radar_from: int = 2 # marks of at least this tier are blips; the tracked one always is
|
||||||
}
|
}
|
||||||
|
|
@ -40,8 +42,8 @@ export function compass_config(compass_st: mut CompassState, cap: int) -> void {
|
||||||
compass_begin(compass_st)
|
compass_begin(compass_st)
|
||||||
}
|
}
|
||||||
|
|
||||||
function cmp_new(x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
|
# a pooled mark filled in place
|
||||||
let m = new CompassMark
|
function cmp_fill(m: CompassMark, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
|
||||||
m.x = x
|
m.x = x
|
||||||
m.z = z
|
m.z = z
|
||||||
m.icon = icon
|
m.icon = icon
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue