diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index ac79c0d1..38ead341 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -249,12 +249,40 @@ MoverPlatformSubComponent::MoverPlatformSubComponent(MovingPlatformComponent* pa } +void MoverPlatformSubComponent::LoadConfigData() { + m_AllowPositionSnapping = m_ParentComponent->GetParent()->GetVar(u"allowPosSnap"); + if(m_ParentComponent->GetParent()->HasVar(u"maxLerpDist")){ + m_MaxLerpDistnace = m_ParentComponent->GetParent()->GetVar(u"maxLerpDist"); + m_MaxLerpDistnace = m_MaxLerpDistnace * m_MaxLerpDistnace; + } + +} //------------- MoverPlatformSubComponent end -------------- //------------- RotatorPlatformSubComponent begin -------------- RotatorPlatformSubComponent::RotatorPlatformSubComponent(MovingPlatformComponent* parentComponent) : PlatformSubComponent(parentComponent) { +} +void RotatorPlatformSubComponent::LoadConfigData() { + if(m_ParentComponent->GetParent()->HasVar(u"rotX")){ + m_Rotation.x = m_ParentComponent->GetParent()->GetVar(u"rotX") * M_PI; + } + if(m_ParentComponent->GetParent()->HasVar(u"rotY")){ + m_Rotation.y = m_ParentComponent->GetParent()->GetVar(u"rotY") * M_PI; + } + if(m_ParentComponent->GetParent()->HasVar(u"rotZ")){ + m_Rotation.z = m_ParentComponent->GetParent()->GetVar(u"rotZ") * M_PI; + } + if(m_ParentComponent->GetParent()->HasVar(u"allowRotSnap")){ + m_AllowRotationSnapping = m_ParentComponent->GetParent()->GetVar(u"allowRotSnap"); + } + if(m_AllowRotationSnapping) { + if(m_ParentComponent->GetParent()->HasVar(u"maxLerpAngle")){ + m_MaxLerpAngle = (m_ParentComponent->GetParent()->GetVar(u"maxLerpAngle") * M_PI) / 180; + } + } + } //------------- RotatorPlatformSubComponent end -------------- diff --git a/dGame/dComponents/MovingPlatformComponent.h b/dGame/dComponents/MovingPlatformComponent.h index fc2b9f3f..270dc0cc 100644 --- a/dGame/dComponents/MovingPlatformComponent.h +++ b/dGame/dComponents/MovingPlatformComponent.h @@ -123,6 +123,11 @@ public: MoverPlatformSubComponent(MovingPlatformComponent* parentComponent); ~MoverPlatformSubComponent() override = default; eMoverSubComponentType GetPlatformType() override { return eMoverSubComponentType::Mover; } + void LoadConfigData() override; + +private: + bool m_AllowPositionSnapping = true; + float m_MaxLerpDistnace = 16.0f; }; class RotatorPlatformSubComponent : public PlatformSubComponent { @@ -131,7 +136,16 @@ public: RotatorPlatformSubComponent(MovingPlatformComponent* parentComponent); ~RotatorPlatformSubComponent() override = default; eMoverSubComponentType GetPlatformType() override { return eMoverSubComponentType::Rotator; } + void LoadConfigData() override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override { PlatformSubComponent::Serialize(outBitStream, bIsInitialUpdate); }; +private: + NiPoint3 m_Rotation = NiPoint3Constant::ZERO; + float m_Rate = 0.0f; + NiPoint3 m_AngularVelocity = NiPoint3Constant::ZERO; + bool m_AllowRotationSnapping = true; + float m_MaxLerpAngle = 0.1396263; + bool m_DirtyAngularVelocity = false; + float m_UnknownFloat = 0.0f; }; // Only moves. Has NO path. This moving platform gets its initial position and rotation from the server on serialization.