refactor(packages): 0.R5 - a question no longer starts its state - 64 lazy starts ('if st.x == null { st.x = ... }' inside a getter) are the state's defaults, gear__ensure is gone, and ludic migrate state --tighten took mut off 208 package parameters: things_all, thing_find, gear_charge, gear_level, jobs_state and the rest read
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
54f5efb23f
commit
9862ec82e3
102 changed files with 320 additions and 351 deletions
|
|
@ -14,7 +14,7 @@ function wl_face(a: WildAnimal, tx: float, tz: float, rate: float, dt: float) ->
|
|||
}
|
||||
|
||||
# true when it moved
|
||||
function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bool {
|
||||
function wl_step(wildlife_st: WildlifeState, a: WildAnimal, dt: float) -> bool {
|
||||
let d = a.speed * dt
|
||||
if d < 0.0001 { return false }
|
||||
let nx = a.x - Math.sin(a.yaw) * d
|
||||
|
|
@ -36,7 +36,7 @@ function wl_step(wildlife_st: mut WildlifeState, a: WildAnimal, dt: float) -> bo
|
|||
return true
|
||||
}
|
||||
|
||||
function wl_pick_target(wildlife_st: mut WildlifeState, a: WildAnimal, radius: float) -> void {
|
||||
function wl_pick_target(wildlife_st: WildlifeState, a: WildAnimal, radius: float) -> void {
|
||||
let ang = wl_rnd(wildlife_st) * WL_TAU
|
||||
let d = wl_rnd(wildlife_st) * radius
|
||||
a.tx = a.home_x + Math.cos(ang) * d
|
||||
|
|
@ -50,14 +50,14 @@ function wl_at_target(a: WildAnimal, r: float) -> bool {
|
|||
}
|
||||
|
||||
# back to wandering about home after `t` seconds of whatever it was doing
|
||||
function wl_wander(wildlife_st: mut WildlifeState, a: WildAnimal, t: float) -> void {
|
||||
function wl_wander(wildlife_st: WildlifeState, a: WildAnimal, t: float) -> void {
|
||||
a.state = WILD_WANDER
|
||||
a.timer = t
|
||||
wl_pick_target(wildlife_st, a, wl_sp(wildlife_st, a.sp).home)
|
||||
}
|
||||
|
||||
# home where it stands now, kept inside its range
|
||||
function wl_rehome(wildlife_st: mut WildlifeState, a: WildAnimal) -> void {
|
||||
function wl_rehome(wildlife_st: WildlifeState, a: WildAnimal) -> void {
|
||||
a.home_x = a.x
|
||||
a.home_z = a.z
|
||||
wl_clamp(wildlife_st, a)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue