mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 22:47:25 +00:00
b261e63233
* chore: Change entity and component logic to use bitstream references * merge
68 lines
2.4 KiB
C++
68 lines
2.4 KiB
C++
#include "ShootingGalleryComponent.h"
|
|
#include "EntityManager.h"
|
|
#include "ScriptedActivityComponent.h"
|
|
|
|
ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent) : Component(parent) {
|
|
}
|
|
|
|
ShootingGalleryComponent::~ShootingGalleryComponent() = default;
|
|
|
|
void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams& params) {
|
|
m_StaticParams = params;
|
|
}
|
|
|
|
void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryParams& params) {
|
|
m_DynamicParams = params;
|
|
m_Dirty = true;
|
|
Game::entityManager->SerializeEntity(m_Parent);
|
|
}
|
|
|
|
void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) {
|
|
// Start ScriptedActivityComponent
|
|
outBitStream.Write<bool>(true);
|
|
if (m_CurrentPlayerID == LWOOBJID_EMPTY) {
|
|
outBitStream.Write<uint32_t>(0);
|
|
} else {
|
|
outBitStream.Write<uint32_t>(1);
|
|
outBitStream.Write<LWOOBJID>(m_CurrentPlayerID);
|
|
for (size_t i = 0; i < 10; i++) {
|
|
outBitStream.Write<float_t>(0.0f);
|
|
}
|
|
|
|
}
|
|
// End ScriptedActivityComponent
|
|
|
|
if (isInitialUpdate) {
|
|
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetX());
|
|
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetY());
|
|
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetZ());
|
|
|
|
outBitStream.Write<float_t>(m_StaticParams.cameraLookatPosition.GetX());
|
|
outBitStream.Write<float_t>(m_StaticParams.cameraLookatPosition.GetY());
|
|
outBitStream.Write<float_t>(m_StaticParams.cameraLookatPosition.GetZ());
|
|
}
|
|
|
|
outBitStream.Write<bool>(m_Dirty || isInitialUpdate);
|
|
if (m_Dirty || isInitialUpdate) {
|
|
outBitStream.Write<double_t>(m_DynamicParams.cannonVelocity);
|
|
outBitStream.Write<double_t>(m_DynamicParams.cannonRefireRate);
|
|
outBitStream.Write<double_t>(m_DynamicParams.cannonMinDistance);
|
|
|
|
outBitStream.Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetX());
|
|
outBitStream.Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetY());
|
|
outBitStream.Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetZ());
|
|
|
|
outBitStream.Write<float_t>(m_DynamicParams.cannonAngle);
|
|
|
|
outBitStream.Write<float_t>(m_DynamicParams.facing.GetX());
|
|
outBitStream.Write<float_t>(m_DynamicParams.facing.GetY());
|
|
outBitStream.Write<float_t>(m_DynamicParams.facing.GetZ());
|
|
|
|
outBitStream.Write<LWOOBJID>(m_CurrentPlayerID);
|
|
outBitStream.Write<float_t>(m_DynamicParams.cannonTimeout);
|
|
outBitStream.Write<float_t>(m_DynamicParams.cannonFOV);
|
|
if (!isInitialUpdate) m_Dirty = false;
|
|
}
|
|
}
|
|
|