mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-15 08:17:13 +00:00
refactor(component): physics components load in the client's phases
The physics row's collision group in LoadDataFromTemplate and the level's CollisionGroupID in LoadConfigData; each physics type then reads its own level keys and makes its physics after that, in the same order as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,11 +49,16 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity, const
|
||||
m_ImmuneToStunMoveCount = 0;
|
||||
m_ImmuneToStunTurnCount = 0;
|
||||
m_ImmuneToStunUseItemCount = 0;
|
||||
}
|
||||
|
||||
if (entity->GetLOT() != 1) // Other physics entities we care about will be added by BaseCombatAI
|
||||
// After the physics config: a character's body, in the physics component's group
|
||||
void ControllablePhysicsComponent::LoadConfigData() {
|
||||
PhysicsComponent::LoadConfigData();
|
||||
|
||||
if (m_Parent->GetLOT() != 1) // Other physics entities we care about will be added by BaseCombatAI
|
||||
return;
|
||||
|
||||
if (entity->GetLOT() == 1) {
|
||||
if (m_Parent->GetLOT() == 1) {
|
||||
LOG("Using patch to load minifig physics");
|
||||
|
||||
float radius = 1.5f;
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CONTROLLABLE_PHYSICS;
|
||||
|
||||
ControllablePhysicsComponent(Entity* entity, const int32_t componentID);
|
||||
|
||||
void LoadConfigData() override;
|
||||
~ControllablePhysicsComponent() override;
|
||||
|
||||
void Run(float deltaTime) override;
|
||||
|
||||
@@ -49,6 +49,11 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent, const int32_t c
|
||||
|
||||
m_IsDirectional = false;
|
||||
m_Direction = NiPoint3(); // * m_DirectionalMultiplier
|
||||
}
|
||||
|
||||
// After the physics config: the volume's blocker, respawn settings and its physics
|
||||
void PhantomPhysicsComponent::LoadConfigData() {
|
||||
PhysicsComponent::LoadConfigData();
|
||||
|
||||
// A phantom volume enemies can't walk into when it carves the navmesh (e.g. the Sentinel camp walls)
|
||||
RegisterMovementBlocker(ComponentType, false, m_Scale);
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PHANTOM_PHYSICS;
|
||||
|
||||
PhantomPhysicsComponent(Entity* parent, const int32_t componentID);
|
||||
|
||||
void LoadConfigData() override;
|
||||
~PhantomPhysicsComponent() override;
|
||||
void Run(float deltaTime) override;
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
@@ -52,18 +52,24 @@ PhysicsComponent::PhysicsComponent(Entity* parent, const int32_t componentID) :
|
||||
m_Rotation = QuatUtils::IDENTITY;
|
||||
m_DirtyPosition = false;
|
||||
|
||||
RegisterMsg(&PhysicsComponent::OnGetPosition);
|
||||
}
|
||||
|
||||
// The PhysicsComponent row's collision group
|
||||
void PhysicsComponent::LoadDataFromTemplate() {
|
||||
CDPhysicsComponentTable* physicsComponentTable = CDClientManager::GetTable<CDPhysicsComponentTable>();
|
||||
|
||||
if (physicsComponentTable) {
|
||||
auto* info = physicsComponentTable->GetByID(componentID);
|
||||
auto* info = physicsComponentTable->GetByID(m_ComponentID);
|
||||
if (info) {
|
||||
m_CollisionGroup = info->collisionGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The level config's CollisionGroupID, when there, replaces it
|
||||
void PhysicsComponent::LoadConfigData() {
|
||||
if (m_Parent->HasVar(u"CollisionGroupID")) m_CollisionGroup = m_Parent->GetVar<int32_t>(u"CollisionGroupID");
|
||||
|
||||
RegisterMsg(&PhysicsComponent::OnGetPosition);
|
||||
}
|
||||
|
||||
PhysicsComponent::~PhysicsComponent() {
|
||||
|
||||
@@ -24,6 +24,9 @@ class dpEntity;
|
||||
class PhysicsComponent : public Component {
|
||||
public:
|
||||
PhysicsComponent(Entity* parent, const int32_t componentID);
|
||||
|
||||
void LoadDataFromTemplate() override;
|
||||
void LoadConfigData() override;
|
||||
virtual ~PhysicsComponent();
|
||||
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
@@ -19,6 +19,11 @@ RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* paren
|
||||
m_Position = m_Parent->GetDefaultPosition();
|
||||
m_Rotation = m_Parent->GetDefaultRotation();
|
||||
m_Scale = m_Parent->GetDefaultScale();
|
||||
}
|
||||
|
||||
// After the physics config: its physics
|
||||
void RigidbodyPhantomPhysicsComponent::LoadConfigData() {
|
||||
PhysicsComponent::LoadConfigData();
|
||||
|
||||
if (m_Parent->GetVar<bool>(u"create_physics")) {
|
||||
m_dpEntity = CreatePhysicsLnv(m_Scale, ComponentType);
|
||||
|
||||
@@ -23,6 +23,8 @@ public:
|
||||
|
||||
RigidbodyPhantomPhysicsComponent(Entity* parent, const int32_t componentID);
|
||||
|
||||
void LoadConfigData() override;
|
||||
|
||||
void Run(const float deltaTime) override;
|
||||
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||
|
||||
@@ -20,6 +20,11 @@ SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, const int32_t com
|
||||
|
||||
m_Position = m_Parent->GetDefaultPosition();
|
||||
m_Rotation = m_Parent->GetDefaultRotation();
|
||||
}
|
||||
|
||||
// After the physics config: climbable type, motion type and the blocker
|
||||
void SimplePhysicsComponent::LoadConfigData() {
|
||||
PhysicsComponent::LoadConfigData();
|
||||
|
||||
const auto& climbable_type = m_Parent->GetVar<std::u16string>(u"climbable");
|
||||
if (climbable_type == u"wall") {
|
||||
|
||||
@@ -36,6 +36,8 @@ public:
|
||||
static constexpr uint32_t MOTION_TYPE_FIXED = 5;
|
||||
|
||||
SimplePhysicsComponent(Entity* parent, const int32_t componentID);
|
||||
|
||||
void LoadConfigData() override;
|
||||
~SimplePhysicsComponent() override;
|
||||
|
||||
void Run(const float deltaTime) override;
|
||||
|
||||
Reference in New Issue
Block a user