wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -2,32 +2,32 @@
|
|||
function ef_live(e: Effect) -> bool { return e.delay < 0.01 }
|
||||
|
||||
# what the rules should add for a kind right now (a delayed one counts only once it begins)
|
||||
export function effects_sum(effects_st: mut EffectsState, kind: int) -> float {
|
||||
let all = ef_all(effects_st)
|
||||
export function effects_sum(kind: int) -> float {
|
||||
let all = ef_all()
|
||||
var t = 0.0
|
||||
for i in 0 .. len(all) { if all[i].kind == kind and ef_live(all[i]) { t = t + all[i].mag } }
|
||||
return t
|
||||
}
|
||||
|
||||
export function effects_has(effects_st: mut EffectsState, kind: int) -> bool {
|
||||
let all = ef_all(effects_st)
|
||||
export function effects_has(kind: int) -> bool {
|
||||
let all = ef_all()
|
||||
for i in 0 .. len(all) { if all[i].kind == kind and ef_live(all[i]) { return true } }
|
||||
return false
|
||||
}
|
||||
|
||||
export function effects_bonus_count(effects_st: mut EffectsState) -> int {
|
||||
let all = ef_all(effects_st)
|
||||
export function effects_bonus_count() -> int {
|
||||
let all = ef_all()
|
||||
var n = 0
|
||||
for i in 0 .. len(all) { if all[i].bonus { n += 1 } }
|
||||
return n
|
||||
}
|
||||
|
||||
# everything held, delayed or not, in the order added
|
||||
export function effects_count(effects_st: mut EffectsState) -> int { return len(ef_all(effects_st)) }
|
||||
export function effects_count() -> int { return len(ef_all()) }
|
||||
|
||||
# a copy, so a reader cannot change the ring
|
||||
export function effects_at(effects_st: mut EffectsState, i: int) -> Effect {
|
||||
let src = ef_all(effects_st)[i]
|
||||
export function effects_at(i: int) -> Effect {
|
||||
let src = ef_all()[i]
|
||||
let e = new Effect
|
||||
e.kind = src.kind
|
||||
e.mag = src.mag
|
||||
|
|
@ -39,9 +39,9 @@ export function effects_at(effects_st: mut EffectsState, i: int) -> Effect {
|
|||
}
|
||||
|
||||
# the indices of the ones that have begun, for a read-out
|
||||
export function effects_live(effects_st: mut EffectsState) -> []int {
|
||||
export function effects_live() -> []int {
|
||||
let out = new []int
|
||||
let all = ef_all(effects_st)
|
||||
let all = ef_all()
|
||||
for i in 0 .. len(all) { if ef_live(all[i]) { push(out, i) } }
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,29 +20,27 @@ export property EffectEnded {
|
|||
bonus: bool = false
|
||||
}
|
||||
|
||||
export state EffectsState {
|
||||
ef_list: []Effect = null
|
||||
ef_max: int = 8
|
||||
ef_bonus_max: int = 3
|
||||
ef_ended: Queue<EffectEnded> = null
|
||||
}
|
||||
var ef_list: []Effect = null
|
||||
var ef_max: int = 8
|
||||
var ef_bonus_max: int = 3
|
||||
var ef_ended: Queue<EffectEnded> = null
|
||||
|
||||
function ef_all(effects_st: mut EffectsState) -> []Effect {
|
||||
if effects_st.ef_list == null { effects_st.ef_list = new []Effect }
|
||||
return effects_st.ef_list
|
||||
function ef_all() -> []Effect {
|
||||
if ef_list == null { ef_list = new []Effect }
|
||||
return ef_list
|
||||
}
|
||||
|
||||
# the facts: what ended and why, oldest first; the game drains it
|
||||
export function effects_ended(base_st: mut BaseState, effects_st: mut EffectsState) -> Queue<EffectEnded> {
|
||||
if effects_st.ef_ended == null { effects_st.ef_ended = queue_new(base_st, "effects.ended") }
|
||||
return effects_st.ef_ended
|
||||
export function effects_ended() -> Queue<EffectEnded> {
|
||||
if ef_ended == null { ef_ended = queue_new("effects.ended") }
|
||||
return ef_ended
|
||||
}
|
||||
|
||||
# how many may run at once, and how many of those may be bonuses
|
||||
export function effects_config(effects_st: mut EffectsState, max: int, bonus_max: int) -> void {
|
||||
effects_st.ef_max = max
|
||||
effects_st.ef_bonus_max = bonus_max
|
||||
export function effects_config(max: int, bonus_max: int) -> void {
|
||||
ef_max = max
|
||||
ef_bonus_max = bonus_max
|
||||
}
|
||||
|
||||
export function effects_capacity(effects_st: EffectsState) -> int { return effects_st.ef_max }
|
||||
export function effects_bonus_capacity(effects_st: EffectsState) -> int { return effects_st.ef_bonus_max }
|
||||
export function effects_capacity() -> int { return ef_max }
|
||||
export function effects_bonus_capacity() -> int { return ef_bonus_max }
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
# system.ludic - the effects as a system: reset, a tick in game hours, and its own save section
|
||||
export function effects_reset(base_st: mut BaseState, effects_st: mut EffectsState) -> void {
|
||||
effects_clear(effects_st)
|
||||
q_clear(base_st, effects_ended(base_st, effects_st))
|
||||
export function effects_reset() -> void {
|
||||
effects_clear()
|
||||
q_clear(effects_ended())
|
||||
}
|
||||
|
||||
function effects_tick(base_st: mut BaseState, effects_st: mut EffectsState, t: Tick) -> void { effects_run(base_st, effects_st, t.hours * 60.0) }
|
||||
function effects_tick(t: Tick) -> void { effects_run(t.hours * 60.0) }
|
||||
|
||||
export function effects_save(effects_st: mut EffectsState) -> Val {
|
||||
export function effects_save() -> Val {
|
||||
let l = Value.list()
|
||||
let all = ef_all(effects_st)
|
||||
let all = ef_all()
|
||||
for i in 0 .. len(all) {
|
||||
let o = Value.object()
|
||||
sv_put_int(o, "k", all[i].kind)
|
||||
|
|
@ -24,12 +24,12 @@ export function effects_save(effects_st: mut EffectsState) -> Val {
|
|||
return v
|
||||
}
|
||||
|
||||
export function effects_load(effects_st: mut EffectsState, v: Val, version: int) -> void {
|
||||
effects_clear(effects_st)
|
||||
export function effects_load(v: Val, version: int) -> void {
|
||||
effects_clear()
|
||||
if Value.has(v, "list") == 0 { return }
|
||||
let l = Value.get(v, "list")
|
||||
for i in 0 .. Value.count(l) {
|
||||
if len(ef_all(effects_st)) >= effects_st.ef_max { break }
|
||||
if len(ef_all()) >= ef_max { break }
|
||||
let o = Value.at(l, i)
|
||||
let e = new Effect
|
||||
e.kind = sv_int(o, "k", 0)
|
||||
|
|
@ -38,7 +38,7 @@ export function effects_load(effects_st: mut EffectsState, v: Val, version: int)
|
|||
e.delay = sv_float(o, "d", 0.0)
|
||||
e.bonus = sv_bool(o, "b", false)
|
||||
e.label = sv_str(o, "l", "")
|
||||
push(ef_all(effects_st), e)
|
||||
push(ef_all(), e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,120 +8,120 @@ program EffectsTest {
|
|||
const WARMTH: int = 1
|
||||
const CARRY: int = 2
|
||||
|
||||
function fresh(base_st: mut BaseState, effects_st: mut EffectsState) -> void {
|
||||
effects_config(effects_st, 8, 3)
|
||||
effects_reset(base_st, effects_st)
|
||||
function fresh() -> void {
|
||||
effects_config(8, 3)
|
||||
effects_reset()
|
||||
}
|
||||
|
||||
function ended(base_st: mut BaseState, effects_st: mut EffectsState) -> []EffectEnded { return q_drain(base_st, effects_ended(base_st, effects_st)) }
|
||||
function waiting(base_st: mut BaseState, effects_st: mut EffectsState) -> int { return q_len(effects_ended(base_st, effects_st)) }
|
||||
function ended() -> []EffectEnded { return q_drain(effects_ended()) }
|
||||
function waiting() -> int { return q_len(effects_ended()) }
|
||||
|
||||
function tick_minutes(m: float) -> void {
|
||||
let s = effects_system()
|
||||
s.tick(tick_new(0.016, 0, m / 60.0))
|
||||
}
|
||||
|
||||
test "the sum is per kind, and a kind with nothing running is zero" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, LEGS, 8.0, 20.0, false, "Fizz")
|
||||
effects_add(base_st, effects_st, LEGS, 6.0, 45.0, false, "Trail mix")
|
||||
effects_add(base_st, effects_st, WARMTH, 12.0, 50.0, false, "Stew")
|
||||
expect(effects_sum(effects_st, LEGS) == 14.0)
|
||||
expect(effects_sum(effects_st, WARMTH) == 12.0)
|
||||
expect(effects_sum(effects_st, CARRY) == 0.0)
|
||||
expect(effects_has(effects_st, WARMTH))
|
||||
expect(not effects_has(effects_st, CARRY))
|
||||
test "the sum is per kind, and a kind with nothing running is zero" {
|
||||
fresh()
|
||||
effects_add(LEGS, 8.0, 20.0, false, "Fizz")
|
||||
effects_add(LEGS, 6.0, 45.0, false, "Trail mix")
|
||||
effects_add(WARMTH, 12.0, 50.0, false, "Stew")
|
||||
expect(effects_sum(LEGS) == 14.0)
|
||||
expect(effects_sum(WARMTH) == 12.0)
|
||||
expect(effects_sum(CARRY) == 0.0)
|
||||
expect(effects_has(WARMTH))
|
||||
expect(not effects_has(CARRY))
|
||||
}
|
||||
|
||||
test "the same kind from the same label replaces itself rather than stacking" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, LEGS, 8.0, 20.0, false, "Fizz")
|
||||
effects_add(base_st, effects_st, LEGS, 8.0, 20.0, false, "Fizz")
|
||||
expect_eq(effects_count(effects_st), 1)
|
||||
expect(effects_sum(effects_st, LEGS) == 8.0)
|
||||
test "the same kind from the same label replaces itself rather than stacking" {
|
||||
fresh()
|
||||
effects_add(LEGS, 8.0, 20.0, false, "Fizz")
|
||||
effects_add(LEGS, 8.0, 20.0, false, "Fizz")
|
||||
expect_eq(effects_count(), 1)
|
||||
expect(effects_sum(LEGS) == 8.0)
|
||||
}
|
||||
|
||||
test "a fourth bonus pushes the oldest out and says so" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, LEGS, 1.0, 10.0, true, "a")
|
||||
effects_add(base_st, effects_st, LEGS, 1.0, 30.0, true, "b")
|
||||
effects_add(base_st, effects_st, WARMTH, 1.0, 40.0, true, "c")
|
||||
effects_add(base_st, effects_st, CARRY, 1.0, 50.0, true, "d")
|
||||
expect_eq(effects_bonus_count(effects_st), 3)
|
||||
let gone = ended(base_st, effects_st)
|
||||
test "a fourth bonus pushes the oldest out and says so" {
|
||||
fresh()
|
||||
effects_add(LEGS, 1.0, 10.0, true, "a")
|
||||
effects_add(LEGS, 1.0, 30.0, true, "b")
|
||||
effects_add(WARMTH, 1.0, 40.0, true, "c")
|
||||
effects_add(CARRY, 1.0, 50.0, true, "d")
|
||||
expect_eq(effects_bonus_count(), 3)
|
||||
let gone = ended()
|
||||
expect_eq(len(gone), 1)
|
||||
expect(gone[0].label == "a")
|
||||
expect_eq(gone[0].why, EFFECT_PUSHED_OUT)
|
||||
}
|
||||
|
||||
test "a full ring drops the one nearest its end" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_config(effects_st, 2, 3)
|
||||
effects_add(base_st, effects_st, LEGS, 1.0, 10.0, false, "short")
|
||||
effects_add(base_st, effects_st, WARMTH, 1.0, 90.0, false, "long")
|
||||
effects_add(base_st, effects_st, CARRY, 1.0, 50.0, false, "new")
|
||||
expect_eq(effects_count(effects_st), 2)
|
||||
expect(not effects_has(effects_st, LEGS))
|
||||
expect_eq(ended(base_st, effects_st)[0].why, EFFECT_CROWDED_OUT)
|
||||
test "a full ring drops the one nearest its end" {
|
||||
fresh()
|
||||
effects_config(2, 3)
|
||||
effects_add(LEGS, 1.0, 10.0, false, "short")
|
||||
effects_add(WARMTH, 1.0, 90.0, false, "long")
|
||||
effects_add(CARRY, 1.0, 50.0, false, "new")
|
||||
expect_eq(effects_count(), 2)
|
||||
expect(not effects_has(LEGS))
|
||||
expect_eq(ended()[0].why, EFFECT_CROWDED_OUT)
|
||||
}
|
||||
|
||||
test "a delayed one counts only once it has begun" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, LEGS, 8.0, 20.0, false, "Fizz")
|
||||
effects_add_after(base_st, effects_st, 20.0, LEGS, -5.0, 15.0, false, "Sugar crash")
|
||||
expect(effects_sum(effects_st, LEGS) == 8.0)
|
||||
expect_eq(len(effects_live(effects_st)), 1)
|
||||
test "a delayed one counts only once it has begun" {
|
||||
fresh()
|
||||
effects_add(LEGS, 8.0, 20.0, false, "Fizz")
|
||||
effects_add_after(20.0, LEGS, -5.0, 15.0, false, "Sugar crash")
|
||||
expect(effects_sum(LEGS) == 8.0)
|
||||
expect_eq(len(effects_live()), 1)
|
||||
tick_minutes(25.0)
|
||||
expect(effects_sum(effects_st, LEGS) == -5.0)
|
||||
expect(effects_sum(LEGS) == -5.0)
|
||||
tick_minutes(20.0)
|
||||
expect_eq(effects_count(effects_st), 0)
|
||||
expect_eq(effects_count(), 0)
|
||||
}
|
||||
|
||||
test "running down in game hours reports each ending" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, WARMTH, -10.0, 10.0, false, "Wet through")
|
||||
test "running down in game hours reports each ending" {
|
||||
fresh()
|
||||
effects_add(WARMTH, -10.0, 10.0, false, "Wet through")
|
||||
tick_minutes(5.0)
|
||||
expect_eq(waiting(base_st, effects_st), 0)
|
||||
expect_eq(waiting(), 0)
|
||||
tick_minutes(6.0)
|
||||
expect_eq(effects_count(effects_st), 0)
|
||||
let gone = ended(base_st, effects_st)
|
||||
expect_eq(effects_count(), 0)
|
||||
let gone = ended()
|
||||
expect_eq(gone[0].why, EFFECT_RAN_OUT)
|
||||
expect(gone[0].label == "Wet through")
|
||||
}
|
||||
|
||||
test "clear stops everything and says nothing" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, LEGS, 1.0, 10.0, false, "a")
|
||||
effects_clear(effects_st)
|
||||
expect_eq(effects_count(effects_st), 0)
|
||||
expect_eq(waiting(base_st, effects_st), 0)
|
||||
test "clear stops everything and says nothing" {
|
||||
fresh()
|
||||
effects_add(LEGS, 1.0, 10.0, false, "a")
|
||||
effects_clear()
|
||||
expect_eq(effects_count(), 0)
|
||||
expect_eq(waiting(), 0)
|
||||
}
|
||||
|
||||
test "a save section reads back the same ring" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, LEGS, 8.5, 20.0, true, "Fizz")
|
||||
effects_add_after(base_st, effects_st, 20.0, LEGS, -5.0, 15.0, false, "Sugar crash")
|
||||
test "a save section reads back the same ring" {
|
||||
fresh()
|
||||
effects_add(LEGS, 8.5, 20.0, true, "Fizz")
|
||||
effects_add_after(20.0, LEGS, -5.0, 15.0, false, "Sugar crash")
|
||||
let root = save_tree()
|
||||
save_section(root, "effects", 1, effects_save(effects_st))
|
||||
save_section(root, "effects", 1, effects_save())
|
||||
let text = save_encode(root)
|
||||
effects_clear(effects_st)
|
||||
effects_clear()
|
||||
let n = load_section(save_decode(text), "effects")
|
||||
expect(n.found)
|
||||
effects_load(effects_st, n.data, n.version)
|
||||
expect_eq(effects_count(effects_st), 2)
|
||||
let a = effects_at(effects_st, 0)
|
||||
effects_load(n.data, n.version)
|
||||
expect_eq(effects_count(), 2)
|
||||
let a = effects_at(0)
|
||||
expect(a.mag == 8.5)
|
||||
expect(a.bonus)
|
||||
let b = effects_at(effects_st, 1)
|
||||
let b = effects_at(1)
|
||||
expect(b.delay == 20.0)
|
||||
expect(b.label == "Sugar crash")
|
||||
}
|
||||
|
||||
test "the copy a reader gets does not change the ring" (base_st: mut BaseState, effects_st: mut EffectsState) {
|
||||
fresh(base_st, effects_st)
|
||||
effects_add(base_st, effects_st, LEGS, 3.0, 10.0, false, "a")
|
||||
let e = effects_at(effects_st, 0)
|
||||
test "the copy a reader gets does not change the ring" {
|
||||
fresh()
|
||||
effects_add(LEGS, 3.0, 10.0, false, "a")
|
||||
let e = effects_at(0)
|
||||
e.mag = 100.0
|
||||
expect(effects_sum(effects_st, LEGS) == 3.0)
|
||||
expect(effects_sum(LEGS) == 3.0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
# verbs.ludic - the only way the ring changes. The same kind from the same label replaces
|
||||
# itself; a bonus past the cap pushes out the oldest bonus; a full ring drops the nearest end.
|
||||
function ef_end(base_st: mut BaseState, effects_st: mut EffectsState, i: int, why: int) -> void {
|
||||
let all = ef_all(effects_st)
|
||||
function ef_end(i: int, why: int) -> void {
|
||||
let all = ef_all()
|
||||
let e = new EffectEnded
|
||||
e.kind = all[i].kind
|
||||
e.label = all[i].label
|
||||
e.why = why
|
||||
e.bonus = all[i].bonus
|
||||
q_push(base_st, effects_ended(base_st, effects_st), e)
|
||||
ef_drop(effects_st, i)
|
||||
q_push(effects_ended(), e)
|
||||
ef_drop(i)
|
||||
}
|
||||
|
||||
function ef_drop(effects_st: mut EffectsState, i: int) -> void {
|
||||
let all = ef_all(effects_st)
|
||||
function ef_drop(i: int) -> void {
|
||||
let all = ef_all()
|
||||
let rest = new []Effect
|
||||
for k in 0 .. len(all) { if k != i { push(rest, all[k]) } }
|
||||
effects_st.ef_list = rest
|
||||
ef_list = rest
|
||||
}
|
||||
|
||||
# the one with the least time left (of the bonuses only, when asked); -1 when there is none
|
||||
function ef_nearest_end(effects_st: mut EffectsState, bonus_only: bool) -> int {
|
||||
let all = ef_all(effects_st)
|
||||
function ef_nearest_end(bonus_only: bool) -> int {
|
||||
let all = ef_all()
|
||||
var at = -1
|
||||
for i in 0 .. len(all) {
|
||||
if bonus_only and not all[i].bonus { continue }
|
||||
|
|
@ -29,16 +29,16 @@ function ef_nearest_end(effects_st: mut EffectsState, bonus_only: bool) -> int {
|
|||
return at
|
||||
}
|
||||
|
||||
function ef_make_room(base_st: mut BaseState, effects_st: mut EffectsState, bonus: bool) -> void {
|
||||
function ef_make_room(bonus: bool) -> void {
|
||||
if bonus {
|
||||
while effects_bonus_count(effects_st) >= effects_st.ef_bonus_max and ef_nearest_end(effects_st, true) >= 0 { ef_end(base_st, effects_st, ef_nearest_end(effects_st, true), EFFECT_PUSHED_OUT) }
|
||||
while effects_bonus_count() >= ef_bonus_max and ef_nearest_end(true) >= 0 { ef_end(ef_nearest_end(true), EFFECT_PUSHED_OUT) }
|
||||
}
|
||||
if len(ef_all(effects_st)) >= effects_st.ef_max and ef_nearest_end(effects_st, false) >= 0 { ef_end(base_st, effects_st, ef_nearest_end(effects_st, false), EFFECT_CROWDED_OUT) }
|
||||
if len(ef_all()) >= ef_max and ef_nearest_end(false) >= 0 { ef_end(ef_nearest_end(false), EFFECT_CROWDED_OUT) }
|
||||
}
|
||||
|
||||
# begin one `after` game minutes from now, lasting `minutes` once it has begun
|
||||
export function effects_add_after(base_st: mut BaseState, effects_st: mut EffectsState, after: float, kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
let all = ef_all(effects_st)
|
||||
export function effects_add_after(after: float, kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
let all = ef_all()
|
||||
for i in 0 .. len(all) {
|
||||
if all[i].kind == kind and all[i].label == label {
|
||||
all[i].mag = mag
|
||||
|
|
@ -46,7 +46,7 @@ export function effects_add_after(base_st: mut BaseState, effects_st: mut Effect
|
|||
return
|
||||
}
|
||||
}
|
||||
ef_make_room(base_st, effects_st, bonus)
|
||||
ef_make_room(bonus)
|
||||
let e = new Effect
|
||||
e.kind = kind
|
||||
e.mag = mag
|
||||
|
|
@ -54,27 +54,27 @@ export function effects_add_after(base_st: mut BaseState, effects_st: mut Effect
|
|||
e.delay = after
|
||||
e.bonus = bonus
|
||||
e.label = label
|
||||
push(ef_all(effects_st), e)
|
||||
push(ef_all(), e)
|
||||
}
|
||||
|
||||
export function effects_add(base_st: mut BaseState, effects_st: mut EffectsState, kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
effects_add_after(base_st, effects_st, 0.0, kind, mag, minutes, bonus, label)
|
||||
export function effects_add(kind: int, mag: float, minutes: float, bonus: bool, label: string) -> void {
|
||||
effects_add_after(0.0, kind, mag, minutes, bonus, label)
|
||||
}
|
||||
|
||||
# everything stops at once, and says nothing: a new trip or a night's sleep
|
||||
export function effects_clear(effects_st: mut EffectsState) -> void { effects_st.ef_list = new []Effect }
|
||||
export function effects_clear() -> void { ef_list = new []Effect }
|
||||
|
||||
# run them down by `minutes` of game time; a delayed one waits first
|
||||
export function effects_run(base_st: mut BaseState, effects_st: mut EffectsState, minutes: float) -> void {
|
||||
export function effects_run(minutes: float) -> void {
|
||||
var i = 0
|
||||
while i < len(ef_all(effects_st)) {
|
||||
let e = ef_all(effects_st)[i]
|
||||
while i < len(ef_all()) {
|
||||
let e = ef_all()[i]
|
||||
if e.delay > 0.0 {
|
||||
e.delay = e.delay - minutes
|
||||
i += 1
|
||||
continue
|
||||
}
|
||||
e.left = e.left - minutes
|
||||
if e.left < 0.0 { ef_end(base_st, effects_st, i, EFFECT_RAN_OUT) } else { i += 1 }
|
||||
if e.left < 0.0 { ef_end(i, EFFECT_RAN_OUT) } else { i += 1 }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue