mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
interrupt rotations and save interrupt count across resets
This commit is contained in:
@@ -47,7 +47,10 @@ bool ModelComponent::OnResetModelToDefaults(GameMessages::ResetModelToDefaults&
|
|||||||
if (reset.bResetPos) m_Parent->SetPosition(m_OriginalPosition);
|
if (reset.bResetPos) m_Parent->SetPosition(m_OriginalPosition);
|
||||||
if (reset.bResetRot) m_Parent->SetRotation(m_OriginalRotation);
|
if (reset.bResetRot) m_Parent->SetRotation(m_OriginalRotation);
|
||||||
m_Parent->SetVelocity(NiPoint3Constant::ZERO);
|
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 = MoveState{};
|
||||||
|
m_Move.interruptCount = moveInterruptCount;
|
||||||
SyncLinearVelocity();
|
SyncLinearVelocity();
|
||||||
ResetRotationState(m_Parent->GetRotation());
|
ResetRotationState(m_Parent->GetRotation());
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ target_include_directories(dGameMessages PUBLIC "."
|
|||||||
"${PROJECT_SOURCE_DIR}/dGame/dComponents" # direct MissionComponent.h
|
"${PROJECT_SOURCE_DIR}/dGame/dComponents" # direct MissionComponent.h
|
||||||
"${PROJECT_SOURCE_DIR}/dGame/dUtilities" # direct SlashCommandHandler.h
|
"${PROJECT_SOURCE_DIR}/dGame/dUtilities" # direct SlashCommandHandler.h
|
||||||
"${PROJECT_SOURCE_DIR}/dGame/dPropertyBehaviors" # direct ControlBehaviors.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/dMission" # via MissionComponent.h
|
||||||
"${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # via InventoryComponent.h
|
"${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # via InventoryComponent.h
|
||||||
"${PROJECT_SOURCE_DIR}/dGame/dInventory" # via InventoryComponent.h
|
"${PROJECT_SOURCE_DIR}/dGame/dInventory" # via InventoryComponent.h
|
||||||
"${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager/Spawner.h
|
"${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager/Spawner.h
|
||||||
"${PROJECT_SOURCE_DIR}/dZoneManager" # via GameMessages.cpp, GameMessageHandler.cpp
|
"${PROJECT_SOURCE_DIR}/dZoneManager" # via GameMessages.cpp, GameMessageHandler.cpp
|
||||||
|
"${PROJECT_SOURCE_DIR}/dGame/d"
|
||||||
)
|
)
|
||||||
target_precompile_headers(dGameMessages REUSE_FROM dGameBase)
|
target_precompile_headers(dGameMessages REUSE_FROM dGameBase)
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent, Up
|
|||||||
// Y axis
|
// Y axis
|
||||||
const float direction = nextActionType == "SpinNegative" ? -1.0f : 1.0f;
|
const float direction = nextActionType == "SpinNegative" ? -1.0f : 1.0f;
|
||||||
if (number != 0.0 && modelComponent.TryStartRotation(1, direction, m_Speed)) {
|
if (number != 0.0 && modelComponent.TryStartRotation(1, direction, m_Speed)) {
|
||||||
|
m_MoveInterruptCount = modelComponent.GetMoveInterruptCount();
|
||||||
m_InActionRotation.y = direction * number;
|
m_InActionRotation.y = direction * number;
|
||||||
m_RotationProgress = 0.0f;
|
m_RotationProgress = 0.0f;
|
||||||
}
|
}
|
||||||
@@ -219,6 +220,7 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent, Up
|
|||||||
// X axis
|
// X axis
|
||||||
const float direction = nextActionType == "TiltNegative" ? -1.0f : 1.0f;
|
const float direction = nextActionType == "TiltNegative" ? -1.0f : 1.0f;
|
||||||
if (number != 0.0 && modelComponent.TryStartRotation(0, direction, m_Speed)) {
|
if (number != 0.0 && modelComponent.TryStartRotation(0, direction, m_Speed)) {
|
||||||
|
m_MoveInterruptCount = modelComponent.GetMoveInterruptCount();
|
||||||
m_InActionRotation.x = direction * number;
|
m_InActionRotation.x = direction * number;
|
||||||
m_RotationProgress = 0.0f;
|
m_RotationProgress = 0.0f;
|
||||||
}
|
}
|
||||||
@@ -226,6 +228,7 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent, Up
|
|||||||
// Z axis
|
// Z axis
|
||||||
const float direction = nextActionType == "RollNegative" ? -1.0f : 1.0f;
|
const float direction = nextActionType == "RollNegative" ? -1.0f : 1.0f;
|
||||||
if (number != 0.0 && modelComponent.TryStartRotation(2, direction, m_Speed)) {
|
if (number != 0.0 && modelComponent.TryStartRotation(2, direction, m_Speed)) {
|
||||||
|
m_MoveInterruptCount = modelComponent.GetMoveInterruptCount();
|
||||||
m_InActionRotation.z = direction * number;
|
m_InActionRotation.z = direction * number;
|
||||||
m_RotationProgress = 0.0f;
|
m_RotationProgress = 0.0f;
|
||||||
}
|
}
|
||||||
@@ -372,6 +375,14 @@ bool Strip::CheckMovement(float deltaTime, ModelComponent& modelComponent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Strip::CheckRotation(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++) {
|
for (int axis = 0; axis < 3; axis++) {
|
||||||
const float target = m_InActionRotation[axis];
|
const float target = m_InActionRotation[axis];
|
||||||
if (target == 0.0f) continue;
|
if (target == 0.0f) continue;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
// Whether this strip is waiting on a MoveBackToStart to arrive
|
// Whether this strip is waiting on a MoveBackToStart to arrive
|
||||||
bool m_MovingToStart{ false };
|
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{};
|
uint32_t m_MoveInterruptCount{};
|
||||||
|
|
||||||
static constexpr float DEFAULT_SPEED = 3.0f;
|
static constexpr float DEFAULT_SPEED = 3.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user