diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 78de197b5..b09c655a0 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -47,7 +47,10 @@ bool ModelComponent::OnResetModelToDefaults(GameMessages::ResetModelToDefaults& if (reset.bResetPos) m_Parent->SetPosition(m_OriginalPosition); if (reset.bResetRot) m_Parent->SetRotation(m_OriginalRotation); m_Parent->SetVelocity(NiPoint3Constant::ZERO); + // Save and increment the interrupt count so other behaviors on this model move to their next action instead of getting stuck + const auto moveInterruptCount = m_Move.interruptCount + 1; m_Move = MoveState{}; + m_Move.interruptCount = moveInterruptCount; SyncLinearVelocity(); ResetRotationState(m_Parent->GetRotation()); diff --git a/dGame/dGameMessages/CMakeLists.txt b/dGame/dGameMessages/CMakeLists.txt index 0f28dea4f..90a4388c2 100644 --- a/dGame/dGameMessages/CMakeLists.txt +++ b/dGame/dGameMessages/CMakeLists.txt @@ -14,10 +14,12 @@ target_include_directories(dGameMessages PUBLIC "." "${PROJECT_SOURCE_DIR}/dGame/dComponents" # direct MissionComponent.h "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # direct SlashCommandHandler.h "${PROJECT_SOURCE_DIR}/dGame/dPropertyBehaviors" # direct ControlBehaviors.h + "${PROJECT_SOURCE_DIR}/dGame/dPropertyBehaviors/ControlBehaviorMessages" # direct ControlBehaviors.h "${PROJECT_SOURCE_DIR}/dGame/dMission" # via MissionComponent.h "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # via InventoryComponent.h "${PROJECT_SOURCE_DIR}/dGame/dInventory" # via InventoryComponent.h "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager/Spawner.h "${PROJECT_SOURCE_DIR}/dZoneManager" # via GameMessages.cpp, GameMessageHandler.cpp + "${PROJECT_SOURCE_DIR}/dGame/d" ) target_precompile_headers(dGameMessages REUSE_FROM dGameBase) diff --git a/dGame/dPropertyBehaviors/Strip.cpp b/dGame/dPropertyBehaviors/Strip.cpp index 5074ef4ab..889a3596b 100644 --- a/dGame/dPropertyBehaviors/Strip.cpp +++ b/dGame/dPropertyBehaviors/Strip.cpp @@ -212,6 +212,7 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent, Up // Y axis const float direction = nextActionType == "SpinNegative" ? -1.0f : 1.0f; if (number != 0.0 && modelComponent.TryStartRotation(1, direction, m_Speed)) { + m_MoveInterruptCount = modelComponent.GetMoveInterruptCount(); m_InActionRotation.y = direction * number; m_RotationProgress = 0.0f; } @@ -219,6 +220,7 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent, Up // X axis const float direction = nextActionType == "TiltNegative" ? -1.0f : 1.0f; if (number != 0.0 && modelComponent.TryStartRotation(0, direction, m_Speed)) { + m_MoveInterruptCount = modelComponent.GetMoveInterruptCount(); m_InActionRotation.x = direction * number; m_RotationProgress = 0.0f; } @@ -226,6 +228,7 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent, Up // Z axis const float direction = nextActionType == "RollNegative" ? -1.0f : 1.0f; if (number != 0.0 && modelComponent.TryStartRotation(2, direction, m_Speed)) { + m_MoveInterruptCount = modelComponent.GetMoveInterruptCount(); m_InActionRotation.z = direction * number; m_RotationProgress = 0.0f; } @@ -372,6 +375,14 @@ bool Strip::CheckMovement(float deltaTime, ModelComponent& modelComponent) { } bool Strip::CheckRotation(float deltaTime, ModelComponent& modelComponent) { + if (m_MoveInterruptCount != modelComponent.GetMoveInterruptCount()) { + for (int axis = 0; axis < 3; axis++) { + if (m_InActionRotation[axis] != 0.0f) modelComponent.StopRotation(axis); + } + m_InActionRotation = NiPoint3Constant::ZERO; + m_RotationProgress = 0.0f; + } + for (int axis = 0; axis < 3; axis++) { const float target = m_InActionRotation[axis]; if (target == 0.0f) continue; diff --git a/dGame/dPropertyBehaviors/Strip.h b/dGame/dPropertyBehaviors/Strip.h index 0ac937ff1..d29ca7b54 100644 --- a/dGame/dPropertyBehaviors/Strip.h +++ b/dGame/dPropertyBehaviors/Strip.h @@ -82,7 +82,7 @@ private: // Whether this strip is waiting on a MoveBackToStart to arrive bool m_MovingToStart{ false }; - // The model's move interrupt count when this strip's current move started + // The model's move interrupt count when this strip's current move or rotation started uint32_t m_MoveInterruptCount{}; static constexpr float DEFAULT_SPEED = 3.0f;