Fix various issues with enemy modifiers
This commit is contained in:
1 parent
d135591b75
commit
10733fd98d
5 files changed
+80
-31
No files matched your search
@@ -31,10 +31,14 @@ export class ModifierBar extends Phaser.GameObjects.Container {
|
||||
updateModifiers(modifiers: PersistentModifier[]) {
|
||||
this.removeAll(true);
|
||||
|
||||
for (let modifier of modifiers) {
|
||||
const visibleIconModifiers = modifiers.filter(m => m.isIconVisible(this.scene as BattleScene));
|
||||
|
||||
for (let modifier of visibleIconModifiers) {
|
||||
if (!modifier.isIconVisible(this.scene as BattleScene))
|
||||
continue;
|
||||
const icon = modifier.getIcon(this.scene as BattleScene);
|
||||
this.add(icon);
|
||||
this.setModifierIconPosition(icon, modifiers.length);
|
||||
this.setModifierIconPosition(icon, visibleIconModifiers.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +120,10 @@ export abstract class PersistentModifier extends Modifier {
|
||||
return 99;
|
||||
}
|
||||
|
||||
isIconVisible(scene: BattleScene): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
getIcon(scene: BattleScene, forSummary?: boolean): Phaser.GameObjects.Container {
|
||||
const container = scene.add.container(0, 0);
|
||||
|
||||
@@ -329,6 +337,11 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
|
||||
return true;
|
||||
}
|
||||
|
||||
isIconVisible(scene: BattleScene): boolean {
|
||||
const pokemon = this.getPokemon(scene);
|
||||
return pokemon instanceof PlayerPokemon || this.getPokemon(scene).isOnField();
|
||||
}
|
||||
|
||||
getIcon(scene: BattleScene, forSummary?: boolean): Phaser.GameObjects.Container {
|
||||
const container = !forSummary ? scene.add.container(0, 0) : super.getIcon(scene);
|
||||
|
||||
|
||||
Reference in new issue
Block a user