81 public function remove(
Effect $effectType) :
void{
82 $index = spl_object_id($effectType);
83 if(isset($this->effects[$index])){
84 $effect = $this->effects[$index];
87 if($ev->isCancelled()){
88 foreach($this->effectAddHooks as $hook){
89 $hook($ev->getEffect(),
true);
94 unset($this->effects[$index]);
95 $effect->getType()->remove($this->entity, $effect);
96 foreach($this->effectRemoveHooks as $hook){
100 $this->recalculateEffectColor();
130 $index = spl_object_id($effect->getType());
131 if(isset($this->effects[$index])){
132 $oldEffect = $this->effects[$index];
134 abs($effect->getAmplifier()) < $oldEffect->getAmplifier()
135 || (abs($effect->getAmplifier()) === abs($oldEffect->getAmplifier()) && $effect->
getDuration() < $oldEffect->getDuration())
141 $ev =
new EntityEffectAddEvent($this->entity, $effect, $oldEffect);
147 if($ev->isCancelled()){
151 if($oldEffect !==
null){
152 $oldEffect->getType()->remove($this->entity, $oldEffect);
155 $effect->getType()->add($this->entity, $effect);
156 foreach($this->effectAddHooks as $hook){
157 $hook($effect, $oldEffect !==
null);
160 $this->effects[$index] = $effect;
162 $this->recalculateEffectColor();
174 foreach($this->effects as $effect){
175 if($effect->isVisible() && $effect->getType()->hasBubbles()){
176 $level = $effect->getEffectLevel();
177 $color = $effect->getColor();
178 for($i = 0; $i < $level; ++$i){
182 if(!$effect->isAmbient()){
188 if(count($colors) > 0){
189 $this->bubbleColor = Color::mix(...$colors);
190 $this->onlyAmbientEffects = $ambient;
192 $this->bubbleColor =
new Color(0, 0, 0, 0);
193 $this->onlyAmbientEffects =
false;