ludic.things: a Thing's seats (a run of the game's seat rows, saved; a bit per seat taken, not); ludic.character: char_sit takes the seat's top and its height above the feet, char_sit_leave names where standing up goes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e84a59aeff
commit
a22b8a572b
12 changed files with 107 additions and 11 deletions
|
|
@ -1,18 +1,31 @@
|
|||
# sit.ludic - sitting: on a seat's point, or on the ground where the body stands. The pose either
|
||||
# side is a still one, so the sit's own weight (body_sit_t) eases 0 -> 1 over a quarter second and
|
||||
# the body walks the last step to the seat over the same time rather than jumping there.
|
||||
export function char_sit(character_st: mut CharacterState, x: float, z: float, yaw: float, mode: int) -> void {
|
||||
|
||||
# y is the seat's top and h how far above the feet it is, so the feet rest y - h (0 on the ground);
|
||||
# standing up leaves from the seat's own point unless char_sit_leave names another
|
||||
export function char_sit(character_st: mut CharacterState, x: float, y: float, z: float, yaw: float, mode: int, h: float) -> void {
|
||||
character_st.chr_sit = true
|
||||
character_st.chr_sit_mode = mode
|
||||
character_st.chr_speed = 0.0
|
||||
character_st.chr_move = 0.0
|
||||
character_st.chr_run = 0.0
|
||||
character_st.chr_sit_x = x
|
||||
character_st.chr_sit_y = y
|
||||
character_st.chr_sit_z = z
|
||||
character_st.chr_sit_h = Math.max(h, 0.0)
|
||||
character_st.chr_sit_yaw = yaw
|
||||
character_st.chr_leave_x = x
|
||||
character_st.chr_leave_z = z
|
||||
character_st.chr_water = CharacterGround.water(character_st.chr_x, character_st.chr_z)
|
||||
}
|
||||
|
||||
# where the body stands when it gets up out of this seat: in front of a bench, beside a boat's thwart
|
||||
export function char_sit_leave(character_st: mut CharacterState, x: float, z: float) -> void {
|
||||
character_st.chr_leave_x = x
|
||||
character_st.chr_leave_z = z
|
||||
}
|
||||
|
||||
function chr_sit_tick(character_st: mut CharacterState, dt: float) -> void {
|
||||
var want = 0.0
|
||||
if character_st.chr_sit { want = 1.0 }
|
||||
|
|
@ -22,7 +35,7 @@ function chr_sit_tick(character_st: mut CharacterState, dt: float) -> void {
|
|||
character_st.chr_x = Math.lerp(character_st.chr_x, character_st.chr_sit_x, k)
|
||||
character_st.chr_z = Math.lerp(character_st.chr_z, character_st.chr_sit_z, k)
|
||||
character_st.chr_yaw = character_st.chr_yaw + char_wrap(character_st.chr_sit_yaw - character_st.chr_yaw) * k
|
||||
character_st.chr_y = CharacterGround.height(character_st.chr_x, character_st.chr_z)
|
||||
character_st.chr_y = Math.lerp(character_st.chr_y, character_st.chr_sit_y - character_st.chr_sit_h, k)
|
||||
character_st.chr_water = CharacterGround.water(character_st.chr_x, character_st.chr_z)
|
||||
}
|
||||
|
||||
|
|
@ -38,17 +51,18 @@ export function char_sit_here(character_st: mut CharacterState) -> int {
|
|||
if character_st.chr_air { return CHAR_NOT_AIRBORNE }
|
||||
if CharacterGround.slope(character_st.chr_x, character_st.chr_z) > 0.35 { return CHAR_NOT_STEEP }
|
||||
if character_st.chr_y < character_st.chr_water + 0.9 { return CHAR_NOT_WET }
|
||||
char_sit(character_st, character_st.chr_x, character_st.chr_z, character_st.chr_yaw, CHAR_SIT_GROUND)
|
||||
char_sit(character_st, character_st.chr_x, character_st.chr_y, character_st.chr_z, character_st.chr_yaw, CHAR_SIT_GROUND, 0.0)
|
||||
return CHAR_SAT
|
||||
}
|
||||
|
||||
# standing up out of a seat put down against a boulder or a bank must not leave the body inside it
|
||||
export function char_stand(character_st: mut CharacterState) -> void {
|
||||
character_st.chr_sit = false
|
||||
if char_safe_spot(character_st, character_st.chr_x, character_st.chr_z, character_st.chr_y, 0.0) {
|
||||
let from_y = character_st.chr_y
|
||||
if char_safe_spot(character_st, character_st.chr_leave_x, character_st.chr_leave_z, from_y, 0.0) {
|
||||
character_st.chr_x = character_st.chr_safe_x
|
||||
character_st.chr_z = character_st.chr_safe_z
|
||||
character_st.chr_y = CharacterGround.height(character_st.chr_x, character_st.chr_z)
|
||||
character_st.chr_y = char_stand_at(character_st.chr_x, character_st.chr_z, from_y)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue