mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-11-03 22:21:59 +00:00 
			
		
		
		
	LUPExhibitComponent cleanup
This commit is contained in:
		@@ -3,42 +3,32 @@
 | 
				
			|||||||
#include "EntityManager.h"
 | 
					#include "EntityManager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LUPExhibitComponent::LUPExhibitComponent(Entity* parent) : Component(parent) {
 | 
					LUPExhibitComponent::LUPExhibitComponent(Entity* parent) : Component(parent) {
 | 
				
			||||||
	m_Exhibits = { 11121, 11295, 11423, 11979 };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	m_ExhibitIndex = 0;
 | 
						m_ExhibitIndex = 0;
 | 
				
			||||||
 | 
						m_UpdateTimer = 0.0f;
 | 
				
			||||||
	m_Exhibit = m_Exhibits[m_ExhibitIndex];
 | 
						m_Exhibit = m_Exhibits.front();
 | 
				
			||||||
 | 
						m_DirtyExhibitInfo = true;
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
LUPExhibitComponent::~LUPExhibitComponent() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LUPExhibitComponent::Update(float deltaTime) {
 | 
					void LUPExhibitComponent::Update(float deltaTime) {
 | 
				
			||||||
	m_UpdateTimer += deltaTime;
 | 
						m_UpdateTimer += deltaTime;
 | 
				
			||||||
 | 
						if (m_UpdateTimer < 20.0f) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (m_UpdateTimer > 20.0f) {
 | 
					 | 
				
			||||||
	NextExhibit();
 | 
						NextExhibit();
 | 
				
			||||||
 | 
					 | 
				
			||||||
	m_UpdateTimer = 0.0f;
 | 
						m_UpdateTimer = 0.0f;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LUPExhibitComponent::NextExhibit() {
 | 
					void LUPExhibitComponent::NextExhibit() {
 | 
				
			||||||
	m_ExhibitIndex++;
 | 
						m_ExhibitIndex++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (m_ExhibitIndex >= m_Exhibits.size()) {
 | 
						// After 1361 years, this will skip exhibit 4 one time.  I think modulo is ok here.
 | 
				
			||||||
		m_ExhibitIndex = 0;
 | 
						m_Exhibit = m_Exhibits.at(m_ExhibitIndex % m_Exhibits.size());
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	m_Exhibit = m_Exhibits[m_ExhibitIndex];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	EntityManager::Instance()->SerializeEntity(m_ParentEntity);
 | 
						EntityManager::Instance()->SerializeEntity(m_ParentEntity);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) {
 | 
					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);
 | 
							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
 | 
					 * 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.
 | 
					 * switching the LOTs around that we'd like to display.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class LUPExhibitComponent : public Component
 | 
					class LUPExhibitComponent final : public Component
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	inline static const eReplicaComponentType ComponentType = eReplicaComponentType::EXHIBIT;
 | 
						inline static const eReplicaComponentType ComponentType = eReplicaComponentType::EXHIBIT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LUPExhibitComponent(Entity* parent);
 | 
						LUPExhibitComponent(Entity* parent);
 | 
				
			||||||
	~LUPExhibitComponent();
 | 
					 | 
				
			||||||
	void Update(float deltaTime) override;
 | 
						void Update(float deltaTime) override;
 | 
				
			||||||
	void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags);
 | 
						void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -36,10 +35,13 @@ private:
 | 
				
			|||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * The list of possible exhibits to show
 | 
						 * 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
 | 
						 * The current index in the exhibit list
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	size_t m_ExhibitIndex;
 | 
						size_t m_ExhibitIndex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Whether or not to notify clients of a change in the visible exhibit
 | 
				
			||||||
 | 
						bool m_DirtyExhibitInfo;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user