mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
physics: send MSG_MOVE_START/STOP_ASCEND and START_DESCEND during flight
When flyingActive_, detect Space/X key transitions and emit proper flight vertical movement opcodes so the server (and other players) see the correct ascending/descending animation state: - MSG_MOVE_START_ASCEND (Space pressed while flying) → sets ASCENDING flag - MSG_MOVE_STOP_ASCEND (Space released while flying) → clears ASCENDING flag - MSG_MOVE_START_DESCEND (X pressed while flying) → clears ASCENDING flag - MSG_MOVE_STOP_ASCEND (X released while flying) → clears vertical state Track wasAscending_/wasDescending_ member state to detect transitions. Also clear lingering vertical state when leaving flight mode.
This commit is contained in:
parent
a9ddfe70c2
commit
132598fc88
3 changed files with 43 additions and 0 deletions
|
|
@ -217,6 +217,7 @@ void CameraController::update(float deltaTime) {
|
|||
bool shiftDown = !uiWantsKeyboard && (input.isKeyPressed(SDL_SCANCODE_LSHIFT) || input.isKeyPressed(SDL_SCANCODE_RSHIFT));
|
||||
bool ctrlDown = !uiWantsKeyboard && (input.isKeyPressed(SDL_SCANCODE_LCTRL) || input.isKeyPressed(SDL_SCANCODE_RCTRL));
|
||||
bool nowJump = !uiWantsKeyboard && !sitting && !movementSuppressed && input.isKeyJustPressed(SDL_SCANCODE_SPACE);
|
||||
bool spaceDown = !uiWantsKeyboard && !sitting && !movementSuppressed && input.isKeyPressed(SDL_SCANCODE_SPACE);
|
||||
|
||||
// Idle camera: any input resets the timer; timeout triggers a slow orbit pan
|
||||
bool anyInput = leftMouseDown || rightMouseDown || keyW || keyS || keyA || keyD || keyQ || keyE || nowJump;
|
||||
|
|
@ -1795,6 +1796,35 @@ void CameraController::update(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
// Flight ascend/descend transitions (Space = ascend, X = descend while mounted+flying)
|
||||
if (movementCallback && !externalFollow_) {
|
||||
const bool nowAscending = flyingActive_ && spaceDown;
|
||||
const bool nowDescending = flyingActive_ && xDown && mounted_;
|
||||
|
||||
if (flyingActive_) {
|
||||
if (nowAscending && !wasAscending_) {
|
||||
movementCallback(static_cast<uint32_t>(game::Opcode::MSG_MOVE_START_ASCEND));
|
||||
} else if (!nowAscending && wasAscending_) {
|
||||
movementCallback(static_cast<uint32_t>(game::Opcode::MSG_MOVE_STOP_ASCEND));
|
||||
}
|
||||
if (nowDescending && !wasDescending_) {
|
||||
movementCallback(static_cast<uint32_t>(game::Opcode::MSG_MOVE_START_DESCEND));
|
||||
} else if (!nowDescending && wasDescending_) {
|
||||
// No separate STOP_DESCEND opcode; STOP_ASCEND ends all vertical movement
|
||||
movementCallback(static_cast<uint32_t>(game::Opcode::MSG_MOVE_STOP_ASCEND));
|
||||
}
|
||||
} else {
|
||||
// Left flight mode: clear any lingering vertical movement states
|
||||
if (wasAscending_) {
|
||||
movementCallback(static_cast<uint32_t>(game::Opcode::MSG_MOVE_STOP_ASCEND));
|
||||
} else if (wasDescending_) {
|
||||
movementCallback(static_cast<uint32_t>(game::Opcode::MSG_MOVE_STOP_ASCEND));
|
||||
}
|
||||
}
|
||||
wasAscending_ = nowAscending;
|
||||
wasDescending_ = nowDescending;
|
||||
}
|
||||
|
||||
// Update previous-frame state
|
||||
wasSwimming = swimming;
|
||||
wasMovingForward = nowForward;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue