From 03a5aa4da0935d82dbe1a848f5d3185e647cdd59 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Tue, 17 May 2022 21:27:08 -0500 Subject: [PATCH 1/4] climbable server side settings --- dGame/dComponents/SimplePhysicsComponent.cpp | 21 ++++++++++---- dGame/dComponents/SimplePhysicsComponent.h | 29 ++++++++++++++++++-- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 8a4cff4e..58bcee18 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -17,6 +17,17 @@ SimplePhysicsComponent::SimplePhysicsComponent(uint32_t componentID, Entity* par m_Position = m_Parent->GetDefaultPosition(); m_Rotation = m_Parent->GetDefaultRotation(); m_IsDirty = true; + + std::u16string climbable_type = m_Parent->GetVar(u"climbable"); + if (climbable_type == u"wall") { + SetClimbableType(CLIMBABLE_TYPE_WALL); + } else if (climbable_type == u"ladder") { + SetClimbableType(CLIMBABLE_TYPE_LADDER); + } else if (climbable_type == u"wallstick") { + SetClimbableType(CLIMBABLE_TYPE_WALL_STICK); + } else { + SetClimbableType(CLIMBABLE_TYPE_NOT); + } } SimplePhysicsComponent::~SimplePhysicsComponent() { @@ -24,10 +35,10 @@ SimplePhysicsComponent::~SimplePhysicsComponent() { void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { if (bIsInitialUpdate) { - outBitStream->Write0(); // climbable - outBitStream->Write(0); // climbableType + outBitStream->Write(m_ClimbableType > 0); + outBitStream->Write(m_ClimbableType); } - + outBitStream->Write(m_DirtyVelocity || bIsInitialUpdate); if (m_DirtyVelocity || bIsInitialUpdate) { outBitStream->Write(m_Velocity); @@ -46,7 +57,7 @@ void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIs { outBitStream->Write0(); } - + outBitStream->Write(m_IsDirty || bIsInitialUpdate); if (m_IsDirty || bIsInitialUpdate) { outBitStream->Write(m_Position.x); @@ -66,7 +77,7 @@ uint32_t SimplePhysicsComponent::GetPhysicsMotionState() const return m_PhysicsMotionState; } -void SimplePhysicsComponent::SetPhysicsMotionState(uint32_t value) +void SimplePhysicsComponent::SetPhysicsMotionState(uint32_t value) { m_PhysicsMotionState = value; } diff --git a/dGame/dComponents/SimplePhysicsComponent.h b/dGame/dComponents/SimplePhysicsComponent.h index 081b056b..bff84522 100644 --- a/dGame/dComponents/SimplePhysicsComponent.h +++ b/dGame/dComponents/SimplePhysicsComponent.h @@ -14,16 +14,24 @@ class Entity; +enum eClimbableType : int32_t { + CLIMBABLE_TYPE_NOT, + CLIMBABLE_TYPE_LADDER, + CLIMBABLE_TYPE_WALL, + CLIMBABLE_TYPE_WALL_STICK +}; + + /** * Component that serializes locations of entities to the client */ class SimplePhysicsComponent : public Component { public: static const uint32_t ComponentType = COMPONENT_TYPE_SIMPLE_PHYSICS; - + SimplePhysicsComponent(uint32_t componentID, Entity* parent); ~SimplePhysicsComponent() override; - + void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); /** @@ -86,6 +94,18 @@ public: */ void SetPhysicsMotionState(uint32_t value); + /** + * Returns the ClimbableType of this entity + * @return the ClimbableType of this entity + */ + const eClimbableType& GetClimabbleType() { return m_ClimbableType; } + + /** + * Sets the ClimbableType of this entity + * @param value the ClimbableType to set + */ + void SetClimbableType(const eClimbableType& value) { m_ClimbableType = value; } + private: /** @@ -122,6 +142,11 @@ private: * The current physics motion state */ uint32_t m_PhysicsMotionState = 0; + + /** + * Whether or not the entity is climbable + */ + eClimbableType m_ClimbableType = CLIMBABLE_TYPE_NOT; }; #endif // SIMPLEPHYSICSCOMPONENT_H From 9169d844e2ba6593204319f236a2a58ec74018fa Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Tue, 17 May 2022 21:38:36 -0500 Subject: [PATCH 2/4] explicit set to 0 --- dGame/dComponents/SimplePhysicsComponent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dComponents/SimplePhysicsComponent.h b/dGame/dComponents/SimplePhysicsComponent.h index bff84522..6ad4cac6 100644 --- a/dGame/dComponents/SimplePhysicsComponent.h +++ b/dGame/dComponents/SimplePhysicsComponent.h @@ -15,7 +15,7 @@ class Entity; enum eClimbableType : int32_t { - CLIMBABLE_TYPE_NOT, + CLIMBABLE_TYPE_NOT = 0, CLIMBABLE_TYPE_LADDER, CLIMBABLE_TYPE_WALL, CLIMBABLE_TYPE_WALL_STICK From 813aca9d20141783750d8e77f6482379c17722d3 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Wed, 18 May 2022 06:36:21 -0500 Subject: [PATCH 3/4] resolve comments --- dGame/dComponents/SimplePhysicsComponent.cpp | 10 +++++----- dGame/dComponents/SimplePhysicsComponent.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 58bcee18..8a052313 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -18,15 +18,15 @@ SimplePhysicsComponent::SimplePhysicsComponent(uint32_t componentID, Entity* par m_Rotation = m_Parent->GetDefaultRotation(); m_IsDirty = true; - std::u16string climbable_type = m_Parent->GetVar(u"climbable"); + const auto& climbable_type = m_Parent->GetVar(u"climbable"); if (climbable_type == u"wall") { - SetClimbableType(CLIMBABLE_TYPE_WALL); + SetClimbableType(eClimbableType::CLIMBABLE_TYPE_WALL); } else if (climbable_type == u"ladder") { - SetClimbableType(CLIMBABLE_TYPE_LADDER); + SetClimbableType(eClimbableType::CLIMBABLE_TYPE_LADDER); } else if (climbable_type == u"wallstick") { - SetClimbableType(CLIMBABLE_TYPE_WALL_STICK); + SetClimbableType(eClimbableType::CLIMBABLE_TYPE_WALL_STICK); } else { - SetClimbableType(CLIMBABLE_TYPE_NOT); + SetClimbableType(eClimbableType::CLIMBABLE_TYPE_NOT); } } diff --git a/dGame/dComponents/SimplePhysicsComponent.h b/dGame/dComponents/SimplePhysicsComponent.h index 6ad4cac6..49e6be5b 100644 --- a/dGame/dComponents/SimplePhysicsComponent.h +++ b/dGame/dComponents/SimplePhysicsComponent.h @@ -14,7 +14,7 @@ class Entity; -enum eClimbableType : int32_t { +enum class eClimbableType : int32_t { CLIMBABLE_TYPE_NOT = 0, CLIMBABLE_TYPE_LADDER, CLIMBABLE_TYPE_WALL, @@ -146,7 +146,7 @@ private: /** * Whether or not the entity is climbable */ - eClimbableType m_ClimbableType = CLIMBABLE_TYPE_NOT; + eClimbableType m_ClimbableType = eClimbableType::CLIMBABLE_TYPE_NOT; }; #endif // SIMPLEPHYSICSCOMPONENT_H From 06df15717c05ce07ded563094b70c74ade1e3a59 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Thu, 19 May 2022 08:40:50 -0500 Subject: [PATCH 4/4] maybe fix it --- dGame/dComponents/SimplePhysicsComponent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 8a052313..c9a42971 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -35,8 +35,8 @@ SimplePhysicsComponent::~SimplePhysicsComponent() { void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { if (bIsInitialUpdate) { - outBitStream->Write(m_ClimbableType > 0); - outBitStream->Write(m_ClimbableType); + outBitStream->Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT); + outBitStream->Write(m_ClimbableType); } outBitStream->Write(m_DirtyVelocity || bIsInitialUpdate);