feat(base): 0.R4 - a queue keeps its own count, so every package verb takes only its own state; ludic migrate state --prune
ludic.base's Queue<T> carries a QueueTag (its name and pending count): queue_new(name), q_push(q, v), q_drain(q), q_clear(q) take no BaseState, and core_undrained(tags) names the given queues still holding facts. A reducer on a package's state can now call that package's verbs (wallet_earn(wallet_st, n)). ludic migrate state --prune (ludicc --migrate-prune) takes out each state parameter a function no longer uses, nor anything it calls, and the argument that fills it - including an argument for a parameter the callee has dropped, which is taken out before the call is checked, so a generic's T is told by the argument that says it. A reducer keeps its state. --dry-run now counts the edits it would make. Every package was moved with it: 608 base_st parameters and their arguments, 1889 edits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8cf4b3fed6
commit
71735b10a2
151 changed files with 58668 additions and 54719 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# ground.ludic - a walker's tick: its needs, the alert, then the first of charging, reacting, going
|
||||
# to its spot, walking to something set out, eating, idling and wandering that has it this tick
|
||||
export function wildlife_tick_ground(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, dt: float, gh: float) -> void {
|
||||
wl_needs(base_st, wildlife_st, a, gh)
|
||||
export function wildlife_tick_ground(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float, gh: float) -> void {
|
||||
wl_needs(wildlife_st, a, gh)
|
||||
let dh = wl_near(wildlife_st, a.x, a.z)
|
||||
let np = wildlife_st.wl_near_i
|
||||
a.timer = a.timer - dt
|
||||
|
|
@ -12,18 +12,18 @@ export function wildlife_tick_ground(base_st: mut BaseState, wildlife_st: mut Wi
|
|||
a.speed = 0.0
|
||||
return
|
||||
}
|
||||
if wl_charge(base_st, wildlife_st, a, np, dh, dt) { return }
|
||||
wl_posture(base_st, wildlife_st, a, np, dt)
|
||||
if wl_react(base_st, wildlife_st, a, np, dt) { return }
|
||||
if wl_seek(base_st, wildlife_st, a, dt) { return }
|
||||
if wl_charge(wildlife_st, a, np, dh, dt) { return }
|
||||
wl_posture(wildlife_st, a, np, dt)
|
||||
if wl_react(wildlife_st, a, np, dt) { return }
|
||||
if wl_seek(wildlife_st, a, dt) { return }
|
||||
if wl_drink(wildlife_st, a, dt, gh) { return }
|
||||
if wl_approach(base_st, wildlife_st, a, dt) { return }
|
||||
if wl_eat(base_st, wildlife_st, a) { return }
|
||||
if wl_approach(wildlife_st, a, dt) { return }
|
||||
if wl_eat(wildlife_st, a) { return }
|
||||
let s = wl_sp(wildlife_st, a.sp)
|
||||
if a.state == WILD_IDLE {
|
||||
a.speed = 0.0
|
||||
if a.timer < 0.0 {
|
||||
if a.timer > -6.0 and s.tracks and wl_rnd(wildlife_st) < 0.06 { wl_fact(base_st, wildlife_st, WILD_BED, a) } # a long sit leaves crushed grass
|
||||
if a.timer > -6.0 and s.tracks and wl_rnd(wildlife_st) < 0.06 { wl_fact(wildlife_st, WILD_BED, a) } # a long sit leaves crushed grass
|
||||
a.state = WILD_WANDER
|
||||
a.timer = 6.0 + wl_rnd(wildlife_st) * 10.0
|
||||
wl_clamp(wildlife_st, a)
|
||||
|
|
@ -33,7 +33,7 @@ export function wildlife_tick_ground(base_st: mut BaseState, wildlife_st: mut Wi
|
|||
}
|
||||
wl_face(a, a.tx, a.tz, 2.0, dt)
|
||||
a.speed = s.walk
|
||||
wl_step(base_st, wildlife_st, a, dt)
|
||||
wl_step(wildlife_st, a, dt)
|
||||
if wl_at_target(a, 1.5) or a.timer < 0.0 {
|
||||
a.state = WILD_IDLE
|
||||
a.timer = 3.0 + wl_rnd(wildlife_st) * 8.0
|
||||
|
|
@ -41,19 +41,19 @@ export function wildlife_tick_ground(base_st: mut BaseState, wildlife_st: mut Wi
|
|||
}
|
||||
|
||||
# a charger close enough comes at the nearest player; true while it is charging
|
||||
function wl_charge(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, np: int, dh: float, dt: float) -> bool {
|
||||
function wl_charge(wildlife_st: mut WildlifeState, a: WildAnimal, np: int, dh: float, dt: float) -> bool {
|
||||
let s = wl_sp(wildlife_st, a.sp)
|
||||
if s.charges and a.state != WILD_CHARGE and dh < WildlifeWorld.charge_reach() and not (a.calm > 0.0) {
|
||||
a.state = WILD_CHARGE
|
||||
a.timer = 2.5
|
||||
wl_fact(base_st, wildlife_st, WILD_CHARGED, a).player = np
|
||||
wl_fact(wildlife_st, WILD_CHARGED, a).player = np
|
||||
}
|
||||
if a.state != WILD_CHARGE { return false }
|
||||
wl_face(a, WildlifeWorld.player_x(np), WildlifeWorld.player_z(np), 4.0, dt)
|
||||
a.speed = s.run
|
||||
wl_step(base_st, wildlife_st, a, dt)
|
||||
wl_step(wildlife_st, a, dt)
|
||||
if dh < 2.6 {
|
||||
wl_fact(base_st, wildlife_st, WILD_SHOVED, a).player = np
|
||||
wl_fact(wildlife_st, WILD_SHOVED, a).player = np
|
||||
wl_wander(wildlife_st, a, 8.0)
|
||||
a.calm = 30.0
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ function wl_charge(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: Wi
|
|||
|
||||
# Four postures read off the alert. Staring is a REACTION, not a condition: each times out and
|
||||
# hands the animal back to its business, and only a fresh rise above `seen` looks up again.
|
||||
function wl_posture(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: WildAnimal, np: int, dt: float) -> void {
|
||||
function wl_posture(wildlife_st: mut WildlifeState, a: WildAnimal, np: int, dt: float) -> void {
|
||||
if wl_sp(wildlife_st, a.sp).tame or a.state == WILD_EAT { return }
|
||||
if a.alert > 95.0 {
|
||||
if a.state != WILD_FLEE {
|
||||
|
|
@ -71,7 +71,7 @@ function wl_posture(base_st: mut BaseState, wildlife_st: mut WildlifeState, a: W
|
|||
a.timer = 3.0 + wl_rnd(wildlife_st) * 3.0
|
||||
a.spook = 120.0 + wl_rnd(wildlife_st) * 180.0
|
||||
a.alert = 70.0
|
||||
wl_fact(base_st, wildlife_st, WILD_FLED, a).player = np
|
||||
wl_fact(wildlife_st, WILD_FLED, a).player = np
|
||||
}
|
||||
} else if a.alert > 60.0 {
|
||||
if a.state != WILD_WARY and a.state != WILD_FLEE and a.alert > a.seen {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue