mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-06-26 14:49:53 +00:00
feat: add speed behavior (#1831)
This commit is contained in:
parent
2618e9a864
commit
1f580491c7
@ -37,6 +37,7 @@ bool ModelComponent::OnResetModelToDefaults(GameMessages::GameMsg& msg) {
|
|||||||
m_Parent->SetRotation(m_OriginalRotation);
|
m_Parent->SetRotation(m_OriginalRotation);
|
||||||
m_Parent->SetVelocity(NiPoint3Constant::ZERO);
|
m_Parent->SetVelocity(NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
|
m_Speed = 3.0f;
|
||||||
m_NumListeningInteract = 0;
|
m_NumListeningInteract = 0;
|
||||||
m_NumActiveUnSmash = 0;
|
m_NumActiveUnSmash = 0;
|
||||||
m_Dirty = true;
|
m_Dirty = true;
|
||||||
@ -279,6 +280,7 @@ bool ModelComponent::TrySetVelocity(const NiPoint3& velocity) const {
|
|||||||
currentVelocity = velocity;
|
currentVelocity = velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentVelocity *= m_Speed;
|
||||||
m_Parent->SetVelocity(currentVelocity);
|
m_Parent->SetVelocity(currentVelocity);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,8 @@ public:
|
|||||||
void SetVelocity(const NiPoint3& velocity) const;
|
void SetVelocity(const NiPoint3& velocity) const;
|
||||||
|
|
||||||
void OnChatMessageReceived(const std::string& sMessage);
|
void OnChatMessageReceived(const std::string& sMessage);
|
||||||
|
|
||||||
|
void SetSpeed(const float newSpeed) { m_Speed = newSpeed; }
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Loads a behavior from the database.
|
// Loads a behavior from the database.
|
||||||
@ -185,4 +187,7 @@ private:
|
|||||||
* The ID of the user that made the model
|
* The ID of the user that made the model
|
||||||
*/
|
*/
|
||||||
LWOOBJID m_userModelID;
|
LWOOBJID m_userModelID;
|
||||||
|
|
||||||
|
// The speed at which this model moves
|
||||||
|
float m_Speed{ 3.0f };
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "ChatPackets.h"
|
#include "ChatPackets.h"
|
||||||
#include "PropertyManagementComponent.h"
|
#include "PropertyManagementComponent.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
|
#include "SimplePhysicsComponent.h"
|
||||||
|
|
||||||
#include "dChatFilter.h"
|
#include "dChatFilter.h"
|
||||||
|
|
||||||
@ -154,16 +155,18 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
|||||||
if (nextActionType == "MoveRight" || nextActionType == "MoveLeft") {
|
if (nextActionType == "MoveRight" || nextActionType == "MoveLeft") {
|
||||||
// X axis
|
// X axis
|
||||||
bool isMoveLeft = nextActionType == "MoveLeft";
|
bool isMoveLeft = nextActionType == "MoveLeft";
|
||||||
|
int negative = isMoveLeft ? -1 : 1;
|
||||||
// Default velocity is 3 units per second.
|
// Default velocity is 3 units per second.
|
||||||
if (modelComponent.TrySetVelocity(NiPoint3{ isMoveLeft ? -3.0f : 3.0f, 0.0f, 0.0f })) {
|
if (modelComponent.TrySetVelocity(NiPoint3Constant::UNIT_X * negative)) {
|
||||||
m_PreviousFramePosition = entity.GetPosition();
|
m_PreviousFramePosition = entity.GetPosition();
|
||||||
m_InActionMove.x = isMoveLeft ? -number : number;
|
m_InActionMove.x = isMoveLeft ? -number : number;
|
||||||
}
|
}
|
||||||
} else if (nextActionType == "FlyUp" || nextActionType == "FlyDown") {
|
} else if (nextActionType == "FlyUp" || nextActionType == "FlyDown") {
|
||||||
// Y axis
|
// Y axis
|
||||||
bool isFlyDown = nextActionType == "FlyDown";
|
bool isFlyDown = nextActionType == "FlyDown";
|
||||||
|
int negative = isFlyDown ? -1 : 1;
|
||||||
// Default velocity is 3 units per second.
|
// Default velocity is 3 units per second.
|
||||||
if (modelComponent.TrySetVelocity(NiPoint3{ 0.0f, isFlyDown ? -3.0f : 3.0f, 0.0f })) {
|
if (modelComponent.TrySetVelocity(NiPoint3Constant::UNIT_Y * negative)) {
|
||||||
m_PreviousFramePosition = entity.GetPosition();
|
m_PreviousFramePosition = entity.GetPosition();
|
||||||
m_InActionMove.y = isFlyDown ? -number : number;
|
m_InActionMove.y = isFlyDown ? -number : number;
|
||||||
}
|
}
|
||||||
@ -171,14 +174,21 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
|||||||
} else if (nextActionType == "MoveForward" || nextActionType == "MoveBackward") {
|
} else if (nextActionType == "MoveForward" || nextActionType == "MoveBackward") {
|
||||||
// Z axis
|
// Z axis
|
||||||
bool isMoveBackward = nextActionType == "MoveBackward";
|
bool isMoveBackward = nextActionType == "MoveBackward";
|
||||||
|
int negative = isMoveBackward ? -1 : 1;
|
||||||
// Default velocity is 3 units per second.
|
// Default velocity is 3 units per second.
|
||||||
if (modelComponent.TrySetVelocity(NiPoint3{ 0.0f, 0.0f, isMoveBackward ? -3.0f : 3.0f })) {
|
if (modelComponent.TrySetVelocity(NiPoint3Constant::UNIT_Z * negative)) {
|
||||||
m_PreviousFramePosition = entity.GetPosition();
|
m_PreviousFramePosition = entity.GetPosition();
|
||||||
m_InActionMove.z = isMoveBackward ? -number : number;
|
m_InActionMove.z = isMoveBackward ? -number : number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* END Move */
|
/* END Move */
|
||||||
|
|
||||||
|
/* BEGIN Navigation */
|
||||||
|
else if (nextActionType == "SetSpeed") {
|
||||||
|
modelComponent.SetSpeed(number);
|
||||||
|
}
|
||||||
|
/* END Navigation */
|
||||||
|
|
||||||
/* BEGIN Action */
|
/* BEGIN Action */
|
||||||
else if (nextActionType == "Smash") {
|
else if (nextActionType == "Smash") {
|
||||||
if (!modelComponent.IsUnSmashing()) {
|
if (!modelComponent.IsUnSmashing()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user