2021-12-05 17:54:36 +00:00
|
|
|
#include "ShootingGalleryComponent.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "ScriptedActivityComponent.h"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent) : Component(parent) {
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ShootingGalleryComponent::~ShootingGalleryComponent() = default;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams& params) {
|
|
|
|
m_StaticParams = params;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryParams& params) {
|
|
|
|
m_DynamicParams = params;
|
|
|
|
m_Dirty = true;
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->SerializeEntity(m_Parent);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-08-10 21:33:15 +00:00
|
|
|
void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) {
|
2022-07-28 13:39:57 +00:00
|
|
|
// Start ScriptedActivityComponent
|
|
|
|
outBitStream->Write<bool>(true);
|
|
|
|
if (m_CurrentPlayerID == LWOOBJID_EMPTY) {
|
|
|
|
outBitStream->Write<uint32_t>(0);
|
|
|
|
} else {
|
|
|
|
outBitStream->Write<uint32_t>(1);
|
2023-12-23 17:50:14 +00:00
|
|
|
outBitStream->Write<LWOOBJID>(m_CurrentPlayerID);
|
2022-07-28 13:39:57 +00:00
|
|
|
for (size_t i = 0; i < 10; i++) {
|
|
|
|
outBitStream->Write<float_t>(0.0f);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
|
|
|
// End ScriptedActivityComponent
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
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());
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
outBitStream->Write<float_t>(m_StaticParams.cameraLookatPosition.GetX());
|
|
|
|
outBitStream->Write<float_t>(m_StaticParams.cameraLookatPosition.GetY());
|
|
|
|
outBitStream->Write<float_t>(m_StaticParams.cameraLookatPosition.GetZ());
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
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);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
outBitStream->Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetX());
|
|
|
|
outBitStream->Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetY());
|
|
|
|
outBitStream->Write<float_t>(m_DynamicParams.cameraBarrelOffset.GetZ());
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
outBitStream->Write<float_t>(m_DynamicParams.cannonAngle);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
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);
|
2023-12-23 17:50:14 +00:00
|
|
|
if (!isInitialUpdate) m_Dirty = false;
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|