mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 07:27:18 +00:00
35 lines
996 B
C++
35 lines
996 B
C++
#include "LUPExhibitComponent.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
LUPExhibitComponent::LUPExhibitComponent(Entity* parent) : Component(parent) {
|
|
m_ExhibitIndex = 0;
|
|
m_UpdateTimer = 0.0f;
|
|
m_Exhibit = m_Exhibits.front();
|
|
m_DirtyExhibitInfo = true;
|
|
}
|
|
|
|
void LUPExhibitComponent::Update(float deltaTime) {
|
|
m_UpdateTimer += deltaTime;
|
|
if (m_UpdateTimer < 20.0f) return;
|
|
|
|
NextExhibit();
|
|
m_UpdateTimer = 0.0f;
|
|
}
|
|
|
|
void LUPExhibitComponent::NextExhibit() {
|
|
m_ExhibitIndex++;
|
|
|
|
// 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) {
|
|
outBitStream->Write(bIsInitialUpdate || m_DirtyExhibitInfo);
|
|
if (bIsInitialUpdate || m_DirtyExhibitInfo) {
|
|
outBitStream->Write(m_Exhibit);
|
|
if (!bIsInitialUpdate) m_DirtyExhibitInfo = false;
|
|
}
|
|
}
|