wip(0.S3): the packages migrated by ludic migrate state packages - every package test green
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e8b5b0523
commit
07505e7ef2
294 changed files with 14996 additions and 14675 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# call.ludic - a player's boat or horse brought to a place: made there the first time, fetched there
|
||||
# after; gone when its player leaves
|
||||
function ve_add(kind: int, x: float, z: float, yaw: float) -> Vehicle {
|
||||
function ve_add(vehicles_st: mut VehiclesState, kind: int, x: float, z: float, yaw: float) -> Vehicle {
|
||||
if kind != VEHICLE_HORSE and kind != VEHICLE_BOAT { return null }
|
||||
let v = new Vehicle
|
||||
v.nid = VehicleWorld.next_id()
|
||||
|
|
@ -14,7 +14,7 @@ function ve_add(kind: int, x: float, z: float, yaw: float) -> Vehicle {
|
|||
v.seat_h = 0.30
|
||||
}
|
||||
ve_put(v, x, z)
|
||||
push(ve_all(), v)
|
||||
push(ve_all(vehicles_st), v)
|
||||
VehicleWorld.made(v)
|
||||
return v
|
||||
}
|
||||
|
|
@ -31,46 +31,46 @@ function ve_put(v: Vehicle, x: float, z: float) -> void {
|
|||
|
||||
# Bring player pid's boat or horse to place k. False when the place is somebody else's, or it is
|
||||
# being ridden. A horse faces the trough: the bay lies on its near side.
|
||||
export function vehicle_call_for(pid: int, kind: int, k: int) -> bool {
|
||||
if not ve_have_dock or k < 0 or k >= VEHICLE_PLACES { return false }
|
||||
let here = vehicle_in_place(kind, k)
|
||||
let v = vehicle_of(pid, kind)
|
||||
export function vehicle_call_for(vehicles_st: mut VehiclesState, pid: int, kind: int, k: int) -> bool {
|
||||
if not vehicles_st.ve_have_dock or k < 0 or k >= VEHICLE_PLACES { return false }
|
||||
let here = vehicle_in_place(vehicles_st, kind, k)
|
||||
let v = vehicle_of(vehicles_st, pid, kind)
|
||||
if here != null { return v != null and here.nid == v.nid }
|
||||
var yaw = ve_dock_yaw
|
||||
if kind == VEHICLE_HORSE { yaw = ve_rail_yaw }
|
||||
var yaw = vehicles_st.ve_dock_yaw
|
||||
if kind == VEHICLE_HORSE { yaw = vehicles_st.ve_rail_yaw }
|
||||
if v == null {
|
||||
let made = ve_add(kind, vehicle_place_x(kind, k), vehicle_place_z(kind, k), yaw)
|
||||
let made = ve_add(vehicles_st, kind, vehicle_place_x(vehicles_st, kind, k), vehicle_place_z(vehicles_st, kind, k), yaw)
|
||||
if made == null { return false }
|
||||
made.owner = pid
|
||||
if pid == 0 { ve_apply_kept(made) }
|
||||
if pid == 0 { ve_apply_kept(vehicles_st, made) }
|
||||
return true
|
||||
}
|
||||
if v.rider >= 0 { return false }
|
||||
ve_put(v, vehicle_place_x(kind, k), vehicle_place_z(kind, k))
|
||||
ve_put(v, vehicle_place_x(vehicles_st, kind, k), vehicle_place_z(vehicles_st, kind, k))
|
||||
v.yaw = yaw
|
||||
VehicleWorld.placed(v)
|
||||
return true
|
||||
}
|
||||
|
||||
# a player left: their boat and horse go with them, and their places are free
|
||||
export function vehicles_release(pid: int) -> void {
|
||||
export function vehicles_release(vehicles_st: mut VehiclesState, pid: int) -> void {
|
||||
if pid == 0 { return }
|
||||
let keep = new []Vehicle
|
||||
let l = ve_all()
|
||||
let l = ve_all(vehicles_st)
|
||||
for i in 0 .. len(l) {
|
||||
if l[i].owner != pid { push(keep, l[i]) } else { VehicleWorld.gone(l[i]) }
|
||||
}
|
||||
ve_list = keep
|
||||
vehicles_st.ve_list = keep
|
||||
}
|
||||
|
||||
# hired or rented for the trip
|
||||
export function vehicle_own(v: Vehicle) -> void { if v != null { v.owned = true } }
|
||||
|
||||
# hay for a horse, up to a full belly
|
||||
export function vehicle_feed(v: Vehicle, amount: float) -> void {
|
||||
export function vehicle_feed(base_st: mut BaseState, vehicles_st: mut VehiclesState, v: Vehicle, amount: float) -> void {
|
||||
if v == null { return }
|
||||
v.food = Math.min(v.food + amount, 100.0)
|
||||
ve_say(VEHICLE_FED, v, amount)
|
||||
ve_say(base_st, vehicles_st, VEHICLE_FED, v, amount)
|
||||
}
|
||||
|
||||
# a horse nobody rides goes where its animal goes, round the home it is tied at (home_x, home_z)
|
||||
|
|
@ -83,22 +83,19 @@ export function vehicle_follow(v: Vehicle, x: float, y: float, z: float, yaw: fl
|
|||
}
|
||||
|
||||
# a saved trip's word on this player's own: hired, and how fed
|
||||
export function vehicle_restore(kind: int, owned: bool, food: float) -> void {
|
||||
export function vehicle_restore(vehicles_st: mut VehiclesState, kind: int, owned: bool, food: float) -> void {
|
||||
if kind == VEHICLE_HORSE {
|
||||
ve_kept_horse = owned
|
||||
ve_kept_food = food
|
||||
} else { ve_kept_boat = owned }
|
||||
let v = vehicle_find(kind)
|
||||
if v != null { ve_apply_kept(v) }
|
||||
vehicles_st.ve_kept_horse = owned
|
||||
vehicles_st.ve_kept_food = food
|
||||
} else { vehicles_st.ve_kept_boat = owned }
|
||||
let v = vehicle_find(vehicles_st, kind)
|
||||
if v != null { ve_apply_kept(vehicles_st, v) }
|
||||
}
|
||||
|
||||
var ve_kept_horse: bool = false
|
||||
var ve_kept_boat: bool = false
|
||||
var ve_kept_food: float = 40.0
|
||||
|
||||
function ve_apply_kept(v: Vehicle) -> void {
|
||||
function ve_apply_kept(vehicles_st: VehiclesState, v: Vehicle) -> void {
|
||||
if v.kind == VEHICLE_HORSE {
|
||||
v.owned = ve_kept_horse
|
||||
v.food = ve_kept_food
|
||||
} else { v.owned = ve_kept_boat }
|
||||
v.owned = vehicles_st.ve_kept_horse
|
||||
v.food = vehicles_st.ve_kept_food
|
||||
} else { v.owned = vehicles_st.ve_kept_boat }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue