2021-12-05 17:54:36 +00:00
|
|
|
#include "LUPExhibitComponent.h"
|
|
|
|
|
|
|
|
#include "EntityManager.h"
|
|
|
|
|
|
|
|
LUPExhibitComponent::LUPExhibitComponent(Entity* parent) : Component(parent) {
|
|
|
|
m_ExhibitIndex = 0;
|
2023-07-05 05:52:51 +00:00
|
|
|
m_UpdateTimer = 0.0f;
|
|
|
|
m_Exhibit = m_Exhibits.front();
|
|
|
|
m_DirtyExhibitInfo = true;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LUPExhibitComponent::Update(float deltaTime) {
|
|
|
|
m_UpdateTimer += deltaTime;
|
2023-07-05 05:52:51 +00:00
|
|
|
if (m_UpdateTimer < 20.0f) return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-05 05:52:51 +00:00
|
|
|
NextExhibit();
|
|
|
|
m_UpdateTimer = 0.0f;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LUPExhibitComponent::NextExhibit() {
|
|
|
|
m_ExhibitIndex++;
|
|
|
|
|
2023-07-05 05:52:51 +00:00
|
|
|
// After 1361 years, this will skip exhibit 4 one time. I think modulo is ok here.
|
|
|
|
m_Exhibit = m_Exhibits.at(m_ExhibitIndex % m_Exhibits.size());
|
2023-06-09 09:46:01 +00:00
|
|
|
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) {
|
2023-07-05 05:52:51 +00:00
|
|
|
outBitStream->Write(bIsInitialUpdate || m_DirtyExhibitInfo);
|
|
|
|
if (bIsInitialUpdate || m_DirtyExhibitInfo) {
|
|
|
|
outBitStream->Write(m_Exhibit);
|
|
|
|
if (!bIsInitialUpdate) m_DirtyExhibitInfo = false;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|