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>
22 lines
1.5 KiB
Text
22 lines
1.5 KiB
Text
# swim.ludic - afloat: buoyancy, the descent, the breath, and the shore stopping the body
|
|
function chr_swim_tick(character_st: mut CharacterState, dx: float, dz: float, jump: bool, dt: float) -> void {
|
|
# standing still out here is floating, not swimming
|
|
if Math.abs(dx) + Math.abs(dz) > 0.05 { character_st.chr_float = 0.0 } else { character_st.chr_float = Math.min(1.0, character_st.chr_float + dt / 1.5) }
|
|
chr_dive_tick(character_st, jump, dt)
|
|
chr_breath_tick(character_st, dt)
|
|
chr_current_tick(character_st, dt)
|
|
let step = character_st.chr_speed * dt
|
|
if step > 0.0 {
|
|
chr_push(character_st, character_st.chr_x - Math.sin(character_st.chr_yaw) * step, character_st.chr_z - Math.cos(character_st.chr_yaw) * step, 0.35, character_st.chr_y, character_st.chr_y + CHAR_BODY)
|
|
let mx = character_st.chr_out_x - character_st.chr_x
|
|
let mz = character_st.chr_out_z - character_st.chr_z
|
|
character_st.chr_step = Math.sqrt(mx * mx + mz * mz)
|
|
character_st.chr_x = character_st.chr_out_x
|
|
character_st.chr_z = character_st.chr_out_z
|
|
}
|
|
# the surface, with a slow bob so a floating body is not a statue on glass
|
|
let bob = 0.04 * Math.sin(character_st.chr_time * 3.8)
|
|
character_st.chr_y = character_st.chr_water - 0.30 + bob - character_st.chr_depth
|
|
# shallow enough to stand up in, and at the top rather than under it
|
|
if chr_bed_depth(character_st.chr_x, character_st.chr_z) < CHAR_STAND_UP and character_st.chr_depth < 0.2 { chr_leave_water(character_st) }
|
|
}
|