mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
fix: LUP Exhibit component type and use delta compression on serialization (#1365)
* fix: component type and use delta compression on serialization * sorry jett, emo made me do it
This commit is contained in:
parent
15954413ae
commit
1bdce8384f
@ -1,44 +1,24 @@
|
|||||||
#include "LUPExhibitComponent.h"
|
#include "LUPExhibitComponent.h"
|
||||||
|
|
||||||
#include "EntityManager.h"
|
#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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void LUPExhibitComponent::Update(float deltaTime) {
|
void LUPExhibitComponent::Update(float deltaTime) {
|
||||||
m_UpdateTimer += deltaTime;
|
m_UpdateTimer += deltaTime;
|
||||||
|
|
||||||
if (m_UpdateTimer > 20.0f) {
|
if (m_UpdateTimer > 20.0f) {
|
||||||
NextExhibit();
|
NextLUPExhibit();
|
||||||
|
|
||||||
m_UpdateTimer = 0.0f;
|
m_UpdateTimer = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LUPExhibitComponent::NextExhibit() {
|
void LUPExhibitComponent::NextLUPExhibit() {
|
||||||
m_ExhibitIndex++;
|
m_LUPExhibitIndex++;
|
||||||
|
m_DirtyLUPExhibit = true;
|
||||||
if (m_ExhibitIndex >= m_Exhibits.size()) {
|
|
||||||
m_ExhibitIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Exhibit = m_Exhibits[m_ExhibitIndex];
|
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
||||||
outBitStream->Write1(); // Dirty flag?
|
outBitStream->Write(m_DirtyLUPExhibit);
|
||||||
outBitStream->Write(m_Exhibit);
|
if (m_DirtyLUPExhibit) {
|
||||||
|
outBitStream->Write(m_LUPExhibits[m_LUPExhibitIndex % m_LUPExhibits.size()]);
|
||||||
|
if (!bIsInitialUpdate) m_DirtyLUPExhibit = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <array>
|
||||||
|
#include "dCommonVars.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -11,35 +14,15 @@
|
|||||||
class LUPExhibitComponent : public Component
|
class LUPExhibitComponent : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::EXHIBIT;
|
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::LUP_EXHIBIT;
|
||||||
|
|
||||||
LUPExhibitComponent(Entity* parent);
|
LUPExhibitComponent(Entity* parent) : Component(parent) {};
|
||||||
~LUPExhibitComponent();
|
|
||||||
void Update(float deltaTime) override;
|
void Update(float deltaTime) override;
|
||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||||
|
void NextLUPExhibit();
|
||||||
/**
|
|
||||||
* After the timer runs out, this changes the currently exhibited LOT to the next one
|
|
||||||
*/
|
|
||||||
void NextExhibit();
|
|
||||||
private:
|
private:
|
||||||
/**
|
float m_UpdateTimer = 0.0f;
|
||||||
* The LOT that's currently on exhibit
|
std::array<LOT, 4> m_LUPExhibits = { 11121, 11295, 11423, 11979 };
|
||||||
*/
|
uint8_t m_LUPExhibitIndex = 0;
|
||||||
LOT m_Exhibit;
|
bool m_DirtyLUPExhibit = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* The time since we've last updated the exhibit
|
|
||||||
*/
|
|
||||||
float m_UpdateTimer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The list of possible exhibits to show
|
|
||||||
*/
|
|
||||||
std::vector<LOT> m_Exhibits;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current index in the exhibit list
|
|
||||||
*/
|
|
||||||
size_t m_ExhibitIndex;
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user