mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-07 05:50:54 +07:00
Call onRemoved() in StatusEffect.java when an effect is removed (#9801)
* Call onRemoved() in StatusEffect.java when an effect is removed * Call onRemoved() in StatusEffect.java when an effect is removed * cleanup * cleanup
This commit is contained in:
parent
0e618a2f71
commit
d9ea8beae2
@ -73,6 +73,7 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
}
|
||||
|
||||
void clearStatuses(){
|
||||
statuses.each(e -> e.effect.onRemoved(self()));
|
||||
statuses.clear();
|
||||
}
|
||||
|
||||
@ -80,6 +81,7 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
void unapply(StatusEffect effect){
|
||||
statuses.remove(e -> {
|
||||
if(e.effect == effect){
|
||||
e.effect.onRemoved(self());
|
||||
Pools.free(e);
|
||||
return true;
|
||||
}
|
||||
@ -189,6 +191,10 @@ abstract class StatusComp implements Posc, Flyingc{
|
||||
entry.time = Math.max(entry.time - Time.delta, 0);
|
||||
|
||||
if(entry.effect == null || (entry.time <= 0 && !entry.effect.permanent)){
|
||||
if(entry.effect != null){
|
||||
entry.effect.onRemoved(self());
|
||||
}
|
||||
|
||||
Pools.free(entry);
|
||||
index --;
|
||||
statuses.remove(index);
|
||||
|
@ -142,6 +142,11 @@ public class StatusEffect extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when status effect is removed. */
|
||||
public void onRemoved(Unit unit){
|
||||
|
||||
}
|
||||
|
||||
protected void trans(StatusEffect effect, TransitionHandler handler){
|
||||
transitions.put(effect, handler);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user