mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
WIP (#1203)
This commit is contained in:
parent
ad003634f4
commit
570c597148
@ -60,33 +60,35 @@ void RenderComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial
|
||||
outBitStream->Write<uint32_t>(m_Effects.size());
|
||||
|
||||
for (Effect* eff : m_Effects) {
|
||||
// Check that the effect is non-null
|
||||
assert(eff);
|
||||
// we still need to write 0 as the size for name if it is a nullptr
|
||||
if (!eff) {
|
||||
outBitStream->Write<uint8_t>(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
outBitStream->Write<uint8_t>(eff->name.size());
|
||||
for (const auto& value : eff->name)
|
||||
outBitStream->Write<uint8_t>(value);
|
||||
// if there is no name, then we don't write anything else
|
||||
if (eff->name.empty()) continue;
|
||||
|
||||
for (const auto& value : eff->name) outBitStream->Write<uint8_t>(value);
|
||||
|
||||
outBitStream->Write(eff->effectID);
|
||||
|
||||
outBitStream->Write<uint8_t>(eff->type.size());
|
||||
for (const auto& value : eff->type)
|
||||
outBitStream->Write<uint16_t>(value);
|
||||
for (const auto& value : eff->type) outBitStream->Write<uint16_t>(value);
|
||||
|
||||
outBitStream->Write<float_t>(eff->scale);
|
||||
outBitStream->Write<float_t>(eff->priority);
|
||||
outBitStream->Write<int64_t>(eff->secondary);
|
||||
}
|
||||
}
|
||||
|
||||
Effect* RenderComponent::AddEffect(const int32_t effectId, const std::string& name, const std::u16string& type) {
|
||||
Effect* RenderComponent::AddEffect(const int32_t effectId, const std::string& name, const std::u16string& type, const float priority) {
|
||||
auto* eff = new Effect();
|
||||
|
||||
eff->effectID = effectId;
|
||||
|
||||
eff->name = name;
|
||||
|
||||
eff->type = type;
|
||||
|
||||
eff->priority = priority;
|
||||
m_Effects.push_back(eff);
|
||||
|
||||
return eff;
|
||||
@ -143,7 +145,7 @@ void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& e
|
||||
|
||||
GameMessages::SendPlayFXEffect(m_Parent, effectId, effectType, name, secondary, priority, scale, serialize);
|
||||
|
||||
auto* effect = AddEffect(effectId, name, effectType);
|
||||
auto* effect = AddEffect(effectId, name, effectType, priority);
|
||||
|
||||
const auto& pair = m_DurationCache.find(effectId);
|
||||
|
||||
|
@ -17,7 +17,7 @@ class Entity;
|
||||
* here.
|
||||
*/
|
||||
struct Effect {
|
||||
Effect() { scale = 1.0f; }
|
||||
Effect() { priority = 1.0f; }
|
||||
|
||||
/**
|
||||
* The ID of the effect
|
||||
@ -35,9 +35,9 @@ struct Effect {
|
||||
std::u16string type = u"";
|
||||
|
||||
/**
|
||||
* How scaled (enlarged) the effect is
|
||||
* The importantness of the effect
|
||||
*/
|
||||
float scale = 1.0f;
|
||||
float priority = 1.0f;
|
||||
|
||||
/**
|
||||
* Some related entity that casted the effect
|
||||
@ -69,9 +69,10 @@ public:
|
||||
* @param effectId the ID of the effect
|
||||
* @param name the name of the effect
|
||||
* @param type the type of the effect
|
||||
* @param priority the priority of the effect
|
||||
* @return if successful, the effect that was created
|
||||
*/
|
||||
Effect* AddEffect(int32_t effectId, const std::string& name, const std::u16string& type);
|
||||
Effect* AddEffect(int32_t effectId, const std::string& name, const std::u16string& type, const float priority);
|
||||
|
||||
/**
|
||||
* Removes an effect for this entity
|
||||
|
Loading…
Reference in New Issue
Block a user