mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 21:40:05 +00:00
Add overload to remove specific class of buff
I initially added this because, despite the higher tickrate for composite condition calculations thanks to the last commit, there is still a slight status icon delay when rapidly switching nanos. I attempted to use this to make that problem go away and for whatever reason it wasn't effective, but I figure it would be useful to have anyway so I'm keeping it.
This commit is contained in:
parent
457c320d48
commit
1709d2b0ef
@ -34,6 +34,18 @@ void Buff::clear() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Buff::clear(BuffClass buffClass) {
|
||||||
|
auto it = stacks.begin();
|
||||||
|
while(it != stacks.end()) {
|
||||||
|
BuffStack& stack = *it;
|
||||||
|
if(stack.buffStackClass == buffClass) {
|
||||||
|
BuffStack deadStack = stack;
|
||||||
|
it = stacks.erase(it);
|
||||||
|
if(onUpdate) onUpdate(self, this, ETBU_DEL, &deadStack);
|
||||||
|
} else it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Buff::addStack(BuffStack* stack) {
|
void Buff::addStack(BuffStack* stack) {
|
||||||
stacks.push_back(*stack);
|
stacks.push_back(*stack);
|
||||||
if(onUpdate) onUpdate(self, this, ETBU_ADD, &stacks.back());
|
if(onUpdate) onUpdate(self, this, ETBU_ADD, &stacks.back());
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
void tick(time_t);
|
void tick(time_t);
|
||||||
void combatTick(time_t);
|
void combatTick(time_t);
|
||||||
void clear();
|
void clear();
|
||||||
|
void clear(BuffClass buffClass);
|
||||||
void addStack(BuffStack* stack);
|
void addStack(BuffStack* stack);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,6 +48,16 @@ void Player::removeBuff(int buffId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::removeBuff(int buffId, int buffClass) {
|
||||||
|
if(hasBuff(buffId)) {
|
||||||
|
buffs[buffId]->clear((BuffClass)buffClass);
|
||||||
|
if(buffs[buffId]->isStale()) {
|
||||||
|
delete buffs[buffId];
|
||||||
|
buffs.erase(buffId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Player::hasBuff(int buffId) {
|
bool Player::hasBuff(int buffId) {
|
||||||
auto buff = buffs.find(buffId);
|
auto buff = buffs.find(buffId);
|
||||||
return buff != buffs.end() && !buff->second->isStale();
|
return buff != buffs.end() && !buff->second->isStale();
|
||||||
@ -161,6 +171,8 @@ Buff* CombatNPC::getBuff(int buffId) { /* stubbed */
|
|||||||
|
|
||||||
void CombatNPC::removeBuff(int buffId) { /* stubbed */ }
|
void CombatNPC::removeBuff(int buffId) { /* stubbed */ }
|
||||||
|
|
||||||
|
void CombatNPC::removeBuff(int buffId, int buffClass) { /* stubbed */ }
|
||||||
|
|
||||||
bool CombatNPC::hasBuff(int buffId) { /* stubbed */
|
bool CombatNPC::hasBuff(int buffId) { /* stubbed */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
virtual bool addBuff(int, BuffCallback<int, BuffStack*>, BuffCallback<time_t>, BuffStack*) = 0;
|
virtual bool addBuff(int, BuffCallback<int, BuffStack*>, BuffCallback<time_t>, BuffStack*) = 0;
|
||||||
virtual Buff* getBuff(int) = 0;
|
virtual Buff* getBuff(int) = 0;
|
||||||
virtual void removeBuff(int) = 0;
|
virtual void removeBuff(int) = 0;
|
||||||
|
virtual void removeBuff(int, int) = 0;
|
||||||
virtual bool hasBuff(int) = 0;
|
virtual bool hasBuff(int) = 0;
|
||||||
virtual int getCompositeCondition() = 0;
|
virtual int getCompositeCondition() = 0;
|
||||||
virtual int takeDamage(EntityRef, int) = 0;
|
virtual int takeDamage(EntityRef, int) = 0;
|
||||||
@ -124,6 +125,7 @@ struct CombatNPC : public BaseNPC, public ICombatant {
|
|||||||
virtual bool addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) override;
|
virtual bool addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) override;
|
||||||
virtual Buff* getBuff(int buffId) override;
|
virtual Buff* getBuff(int buffId) override;
|
||||||
virtual void removeBuff(int buffId) override;
|
virtual void removeBuff(int buffId) override;
|
||||||
|
virtual void removeBuff(int buffId, int buffClass) override;
|
||||||
virtual bool hasBuff(int buffId) override;
|
virtual bool hasBuff(int buffId) override;
|
||||||
virtual int getCompositeCondition() override;
|
virtual int getCompositeCondition() override;
|
||||||
virtual int takeDamage(EntityRef src, int amt) override;
|
virtual int takeDamage(EntityRef src, int amt) override;
|
||||||
|
@ -90,6 +90,7 @@ struct Player : public Entity, public ICombatant {
|
|||||||
virtual bool addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) override;
|
virtual bool addBuff(int buffId, BuffCallback<int, BuffStack*> onUpdate, BuffCallback<time_t> onTick, BuffStack* stack) override;
|
||||||
virtual Buff* getBuff(int buffId) override;
|
virtual Buff* getBuff(int buffId) override;
|
||||||
virtual void removeBuff(int buffId) override;
|
virtual void removeBuff(int buffId) override;
|
||||||
|
virtual void removeBuff(int buffId, int buffClass) override;
|
||||||
virtual bool hasBuff(int buffId) override;
|
virtual bool hasBuff(int buffId) override;
|
||||||
virtual int getCompositeCondition() override;
|
virtual int getCompositeCondition() override;
|
||||||
virtual int takeDamage(EntityRef src, int amt) override;
|
virtual int takeDamage(EntityRef src, int amt) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user