1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-06 18:57:45 +00:00

Add function to remove multiple statuseffects by id

This commit is contained in:
Rushi 2024-06-21 16:12:33 +02:00
parent 6b72992b9f
commit 2965d8a03a
3 changed files with 21 additions and 6 deletions

View file

@ -15,12 +15,7 @@ public:
void onExpire( Entity::Chara& actor ) override void onExpire( Entity::Chara& actor ) override
{ {
actor.removeSingleStatusEffectById( Unchained ); actor.removeStatusEffectById( { Unchained, Wrath, WrathII, WrathIII, WrathIV, Infuriated } );
actor.removeSingleStatusEffectById( Wrath );
actor.removeSingleStatusEffectById( WrathII );
actor.removeSingleStatusEffectById( WrathIII );
actor.removeSingleStatusEffectById( WrathIV );
actor.removeSingleStatusEffectById( Infuriated );
} }
}; };

View file

@ -559,6 +559,24 @@ void Chara::removeSingleStatusEffectById( uint32_t id )
} }
} }
void Chara::removeStatusEffectById( std::vector< uint32_t > ids )
{
for( auto effectIt = m_statusEffectMap.begin(); effectIt != m_statusEffectMap.end(); )
{
auto foundStatus = std::find( ids.begin(), ids.end(), effectIt->second->getId() );
if( foundStatus != ids.end() )
{
effectIt = removeStatusEffect( effectIt->first );
ids.erase( foundStatus );
}
else
{
++effectIt;
}
}
}
void Chara::removeStatusEffectByFlag( Common::StatusEffectFlag flag ) void Chara::removeStatusEffectByFlag( Common::StatusEffectFlag flag )
{ {
for( auto effectIt = m_statusEffectMap.begin(); effectIt != m_statusEffectMap.end(); ) for( auto effectIt = m_statusEffectMap.begin(); effectIt != m_statusEffectMap.end(); )

View file

@ -114,6 +114,8 @@ namespace Sapphire::Entity
void removeSingleStatusEffectById( uint32_t id ); void removeSingleStatusEffectById( uint32_t id );
void removeStatusEffectById( std::vector< uint32_t > ids );
void removeStatusEffectByFlag( Common::StatusEffectFlag flag ); void removeStatusEffectByFlag( Common::StatusEffectFlag flag );
void updateStatusEffects(); void updateStatusEffects();