#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, uint32_t& flags) const { // Start ScriptedActivityComponent outBitStream->Write(true); if (m_CurrentPlayerID == LWOOBJID_EMPTY) { outBitStream->Write(0); } else { outBitStream->Write(1); for (size_t i = 0; i < 10; i++) { outBitStream->Write(0.0f); } } // End ScriptedActivityComponent if (isInitialUpdate) { outBitStream->Write(m_StaticParams.cameraPosition.GetX()); outBitStream->Write(m_StaticParams.cameraPosition.GetY()); outBitStream->Write(m_StaticParams.cameraPosition.GetZ()); outBitStream->Write(m_StaticParams.cameraLookatPosition.GetX()); outBitStream->Write(m_StaticParams.cameraLookatPosition.GetY()); outBitStream->Write(m_StaticParams.cameraLookatPosition.GetZ()); } outBitStream->Write(m_Dirty || isInitialUpdate); if (m_Dirty || isInitialUpdate) { outBitStream->Write(m_DynamicParams.cannonVelocity); outBitStream->Write(m_DynamicParams.cannonRefireRate); outBitStream->Write(m_DynamicParams.cannonMinDistance); outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetX()); outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetY()); outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetZ()); outBitStream->Write(m_DynamicParams.cannonAngle); outBitStream->Write(m_DynamicParams.facing.GetX()); outBitStream->Write(m_DynamicParams.facing.GetY()); outBitStream->Write(m_DynamicParams.facing.GetZ()); outBitStream->Write(m_CurrentPlayerID); outBitStream->Write(m_DynamicParams.cannonTimeout); outBitStream->Write(m_DynamicParams.cannonFOV); } }