DarkflameServer/dGame/dComponents/LUPExhibitComponent.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
996 B
C++
Raw Normal View History

#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;
}
void LUPExhibitComponent::Update(float deltaTime) {
m_UpdateTimer += deltaTime;
2023-07-05 05:52:51 +00:00
if (m_UpdateTimer < 20.0f) return;
2023-07-05 05:52:51 +00:00
NextExhibit();
m_UpdateTimer = 0.0f;
}
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());
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
}
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;
}
}