mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +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
|
||||
@ -109,15 +110,15 @@ public:
|
||||
* if it has the animation assigned to its group. If it does, the animation is echo'd
|
||||
* down to all clients to be played and the duration of the played animation is returned.
|
||||
* If the animation did not exist or the function was called in an invalid state, 0 is returned.
|
||||
*
|
||||
*
|
||||
* The logic here matches the exact client logic.
|
||||
*
|
||||
*
|
||||
* @param self The entity that wants to play an animation
|
||||
* @param animation The animation_type (animationID in the client) to be played.
|
||||
* @param sendAnimation Whether or not to echo the animation down to all clients.
|
||||
* @param priority The priority of the animation. Only used if sendAnimation is true.
|
||||
* @param scale The scale of the animation. Only used if sendAnimation is true.
|
||||
*
|
||||
*
|
||||
* @return The duration of the animation that was played.
|
||||
*/
|
||||
static float DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority = 0.0f, float scale = 1.0f);
|
||||
|
Loading…
Reference in New Issue
Block a user