mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-12 07:43:43 +00:00
feat: Add a bunch of behaviors (All rotations, DoDamage, OnTimer, OnStartup, MoveBackToStart) and make models move based on normals, not world axes (#2038)
* add rotation behavior logic (not working correctly for multiple axes) * Fix FetchContent_Declare speed * remove manual quaternion math * feat: working rotations * remove flag * feat: make directional movements based on model rotation and not world axes * poggers rotation on the strip * Add OnStartup and OnTimer * go home works * Add DoDamage behavior and dont try and start the same node multiple times * fix: pause bbb models * interrupt rotations and save interrupt count across resets
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#include "Amf3.h"
|
||||
|
||||
SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, const int32_t componentID) : PhysicsComponent(parent, componentID) {
|
||||
RegisterMsg(&SimplePhysicsComponent::OnGetAngularVelocity);
|
||||
RegisterMsg(&SimplePhysicsComponent::OnSetAngularVelocity);
|
||||
RegisterMsg(&SimplePhysicsComponent::OnGetObjectReportInfo);
|
||||
|
||||
m_Position = m_Parent->GetDefaultPosition();
|
||||
@@ -38,6 +40,7 @@ SimplePhysicsComponent::~SimplePhysicsComponent() {
|
||||
}
|
||||
|
||||
void SimplePhysicsComponent::Update(const float deltaTime) {
|
||||
// Rotation is driven by ModelComponent; angular velocity is only relayed to clients.
|
||||
if (m_Velocity == NiPoint3Constant::ZERO) return;
|
||||
m_Position += m_Velocity * deltaTime;
|
||||
m_DirtyPosition = true;
|
||||
@@ -52,8 +55,12 @@ void SimplePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIs
|
||||
|
||||
outBitStream.Write(m_DirtyVelocity || bIsInitialUpdate);
|
||||
if (m_DirtyVelocity || bIsInitialUpdate) {
|
||||
outBitStream.Write(m_Velocity);
|
||||
outBitStream.Write(m_AngularVelocity);
|
||||
outBitStream.Write(m_Velocity.x);
|
||||
outBitStream.Write(m_Velocity.y);
|
||||
outBitStream.Write(m_Velocity.z);
|
||||
outBitStream.Write(m_AngularVelocity.x);
|
||||
outBitStream.Write(m_AngularVelocity.y);
|
||||
outBitStream.Write(m_AngularVelocity.z);
|
||||
|
||||
m_DirtyVelocity = false;
|
||||
}
|
||||
@@ -85,3 +92,16 @@ bool SimplePhysicsComponent::OnGetObjectReportInfo(GameMessages::GetObjectReport
|
||||
info.PushDebug<AMFStringValue>("Climbable Type") = StringifiedEnum::ToString(m_ClimbableType).data();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimplePhysicsComponent::OnSetAngularVelocity(GameMessages::SetAngularVelocity& setAngVel) {
|
||||
m_DirtyVelocity |= setAngVel.bForceFlagDirty || (m_AngularVelocity != setAngVel.angVelocity);
|
||||
m_AngularVelocity = setAngVel.angVelocity;
|
||||
LOG_DEBUG("Angular velocity is now %f %f %f", m_AngularVelocity.x, m_AngularVelocity.y, m_AngularVelocity.z);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimplePhysicsComponent::OnGetAngularVelocity(GameMessages::GetAngularVelocity& getAngVel) {
|
||||
getAngVel.angVelocity = m_AngularVelocity;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user