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
|
|
@ -8,7 +8,7 @@ const VE_BOAT_TOP: float = 3.2
|
|||
const VE_BOAT_ACC: float = 1.2
|
||||
const VE_BOAT_TURN: float = 1.1
|
||||
|
||||
export function vehicle_update(base_st: mut BaseState, vehicles_st: mut VehiclesState, ix: float, iz: float, run: bool, dt: float) -> void {
|
||||
export function vehicle_update(vehicles_st: mut VehiclesState, ix: float, iz: float, run: bool, dt: float) -> void {
|
||||
let v = vehicles_st.ve_cur
|
||||
if v == null { return }
|
||||
var top = VE_BOAT_TOP
|
||||
|
|
@ -21,7 +21,7 @@ export function vehicle_update(base_st: mut BaseState, vehicles_st: mut Vehicles
|
|||
if run and v.fuel > 5.0 { top = VE_HORSE_GALLOP }
|
||||
}
|
||||
v.speed = v.speed + Math.clamp(iz * top - v.speed, -acc * dt, acc * dt)
|
||||
if v.kind == VEHICLE_BOAT { ve_swell(base_st, vehicles_st, v, dt) }
|
||||
if v.kind == VEHICLE_BOAT { ve_swell(vehicles_st, v, dt) }
|
||||
# Steering follows SIGNED speed: backing up with the stick left swings the nose right
|
||||
if Math.abs(v.speed) > 0.3 {
|
||||
var rate = Math.clamp(Math.abs(v.speed) / 3.0, 0.4, 1.0)
|
||||
|
|
@ -29,14 +29,14 @@ export function vehicle_update(base_st: mut BaseState, vehicles_st: mut Vehicles
|
|||
v.yaw = v.yaw - ix * turn * (dt * rate)
|
||||
}
|
||||
let d = v.speed * dt
|
||||
ve_travel(base_st, vehicles_st, v, v.x - Math.sin(v.yaw) * d, v.z - Math.cos(v.yaw) * d, d)
|
||||
ve_travel(vehicles_st, v, v.x - Math.sin(v.yaw) * d, v.z - Math.cos(v.yaw) * d, d)
|
||||
if v.kind == VEHICLE_HORSE { ve_stamina(v, d, dt) } else { ve_float(v, d, dt) }
|
||||
VehicleWorld.placed(v)
|
||||
VehicleRider.ride_at(v.x, v.y + v.seat_h, v.z, v.yaw, Math.abs(v.speed))
|
||||
}
|
||||
|
||||
# a boat only where there is water under it; a horse only on dry ground, up a walkable rise, clear
|
||||
function ve_travel(base_st: mut BaseState, vehicles_st: mut VehiclesState, v: Vehicle, nx: float, nz: float, d: float) -> void {
|
||||
function ve_travel(vehicles_st: mut VehiclesState, v: Vehicle, nx: float, nz: float, d: float) -> void {
|
||||
let nh = VehicleWorld.ground(nx, nz)
|
||||
var ok = true
|
||||
if v.kind == VEHICLE_BOAT { ok = nh < VehicleWorld.water(nx, nz) - 0.35 } else {
|
||||
|
|
@ -51,12 +51,12 @@ function ve_travel(base_st: mut BaseState, vehicles_st: mut VehiclesState, v: Ve
|
|||
v.x = nx
|
||||
v.z = nz
|
||||
if v.kind != VEHICLE_BOAT { v.y = nh }
|
||||
if Math.abs(d) > 0.0 { ve_say(base_st, vehicles_st, VEHICLE_MOVED, v, Math.abs(d)) }
|
||||
if Math.abs(d) > 0.0 { ve_say(vehicles_st, VEHICLE_MOVED, v, Math.abs(d)) }
|
||||
}
|
||||
|
||||
# a boat gets a longer leash than a swimmer and the same current at the end of it: the outward
|
||||
# part of the stroke only, so a boat at the limit can always be put about
|
||||
function ve_swell(base_st: mut BaseState, vehicles_st: mut VehiclesState, v: Vehicle, dt: float) -> void {
|
||||
function ve_swell(vehicles_st: mut VehiclesState, v: Vehicle, dt: float) -> void {
|
||||
var fx = -Math.sin(v.yaw)
|
||||
var fz = -Math.cos(v.yaw)
|
||||
if v.speed < 0.0 {
|
||||
|
|
@ -67,7 +67,7 @@ function ve_swell(base_st: mut BaseState, vehicles_st: mut VehiclesState, v: Veh
|
|||
v.speed = v.speed * (1.0 - take)
|
||||
if take > 0.55 and vehicles_st.ve_swell_said < 0.0 {
|
||||
vehicles_st.ve_swell_said = 14.0
|
||||
ve_say(base_st, vehicles_st, VEHICLE_SWELL, v, take)
|
||||
ve_say(vehicles_st, VEHICLE_SWELL, v, take)
|
||||
}
|
||||
vehicles_st.ve_swell_said = vehicles_st.ve_swell_said - dt
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue