Passive nano powers boilerplate

This commit is contained in:
gsemaj
2022-07-20 09:15:01 -07:00
committed by gsemaj
parent eb7daf8eaa
commit 36f329c302
8 changed files with 137 additions and 22 deletions

View File

@@ -10,7 +10,6 @@ void Buff::tick() {
BuffStack& stack = *it;
if(stack.onTick) stack.onTick(self, &stack);
if(stack.durationTicks > 0) stack.durationTicks--;
if(stack.durationTicks == 0) {
// erase() destroys the callbacks
// with the stack struct, so we need
@@ -18,7 +17,10 @@ void Buff::tick() {
BuffStack deadStack = stack;
it = stacks.erase(it);
if(deadStack.onExpire) deadStack.onExpire(self, &deadStack);
} else it++;
} else {
if(stack.durationTicks > 0) stack.durationTicks--;
it++;
}
}
}
@@ -31,9 +33,10 @@ void Buff::clear() {
}
void Buff::addStack(BuffStack* stack) {
stack->buff = this;
if(stack->onApply) stack->onApply(self, stack);
stacks.push_back(*stack);
BuffStack newStack = *stack;
newStack.buff = this;
if(newStack.onApply) newStack.onApply(self, &newStack);
stacks.push_back(newStack);
}
bool Buff::hasClass(BuffClass buffClass) {