mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 15:37:20 +00:00
LUPExhibitComponent cleanup
This commit is contained in:
parent
cfec9801a8
commit
68a2a04e5d
@ -3,42 +3,32 @@
|
||||
#include "EntityManager.h"
|
||||
|
||||
LUPExhibitComponent::LUPExhibitComponent(Entity* parent) : Component(parent) {
|
||||
m_Exhibits = { 11121, 11295, 11423, 11979 };
|
||||
|
||||
m_ExhibitIndex = 0;
|
||||
|
||||
m_Exhibit = m_Exhibits[m_ExhibitIndex];
|
||||
|
||||
|
||||
}
|
||||
|
||||
LUPExhibitComponent::~LUPExhibitComponent() {
|
||||
|
||||
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;
|
||||
|
||||
if (m_UpdateTimer > 20.0f) {
|
||||
NextExhibit();
|
||||
|
||||
m_UpdateTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void LUPExhibitComponent::NextExhibit() {
|
||||
m_ExhibitIndex++;
|
||||
|
||||
if (m_ExhibitIndex >= m_Exhibits.size()) {
|
||||
m_ExhibitIndex = 0;
|
||||
}
|
||||
|
||||
m_Exhibit = m_Exhibits[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->Write1(); // Dirty flag?
|
||||
outBitStream->Write(bIsInitialUpdate || m_DirtyExhibitInfo);
|
||||
if (bIsInitialUpdate || m_DirtyExhibitInfo) {
|
||||
outBitStream->Write(m_Exhibit);
|
||||
if (!bIsInitialUpdate) m_DirtyExhibitInfo = false;
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,12 @@
|
||||
* Component that handles the LOT that is shown in the LUP exhibit in the LUP world. Works by setting a timer and
|
||||
* switching the LOTs around that we'd like to display.
|
||||
*/
|
||||
class LUPExhibitComponent : public Component
|
||||
class LUPExhibitComponent final : public Component
|
||||
{
|
||||
public:
|
||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::EXHIBIT;
|
||||
|
||||
LUPExhibitComponent(Entity* parent);
|
||||
~LUPExhibitComponent();
|
||||
void Update(float deltaTime) override;
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags);
|
||||
|
||||
@ -36,10 +35,13 @@ private:
|
||||
/**
|
||||
* The list of possible exhibits to show
|
||||
*/
|
||||
std::vector<LOT> m_Exhibits;
|
||||
const std::vector<LOT> m_Exhibits = { 11121, 11295, 11423, 11979 };
|
||||
|
||||
/**
|
||||
* The current index in the exhibit list
|
||||
*/
|
||||
size_t m_ExhibitIndex;
|
||||
|
||||
// Whether or not to notify clients of a change in the visible exhibit
|
||||
bool m_DirtyExhibitInfo;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user