Skip to content

Commit

Permalink
fix: fix crash when playing ships with no ability (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminAmos authored Mar 31, 2023
1 parent 3d015cf commit e37c94c
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ public Float get() {
@Override
public UITextureRegion get() {
Hero hero = solApplication.getGame().getHero();
if (hero.getAbility() == null) {
return null;
}

SolItem example = hero.getAbility().getConfig().getChargeExample();
if (example != null) {
return Assets.getDSTexture(example.getIcon(solApplication.getGame()).name).getUiTexture();
Expand All @@ -247,7 +251,7 @@ public UITextureRegion get() {
@Override
public Float get() {
Hero hero = solApplication.getGame().getHero();
if (hero.getAbilityAwait() > 0) {
if (hero.getAbility() != null && hero.getAbilityAwait() > 0) {
return 1.0f - hero.getAbilityAwait() / hero.getAbility().getConfig().getRechargeTime();
} else {
return 1.0f;
Expand All @@ -265,6 +269,10 @@ public UITextureRegion get() {
public Float get() {
SolGame game = solApplication.getGame();
Hero hero = game.getHero();
if (hero.getAbility() == null) {
return 0.0f;
}

SolItem example = hero.getAbility().getConfig().getChargeExample();
if (example != null) {
return (float) hero.getItemContainer().count(example);
Expand Down Expand Up @@ -521,10 +529,12 @@ public void update(float delta) {
gun2Stats.findAll(UIIconBar.class).iterator().next().setIcon(gun2ClipIcon);
}

SolItem example = hero.getAbility().getConfig().getChargeExample();
if (example != null) {
UITextureRegion abilityIcon = Assets.getDSTexture(example.getIcon(solApplication.getGame()).name).getUiTexture();
abilityStats.findAll(UIIconBar.class).iterator().next().setIcon(abilityIcon);
if (hero.getAbility() != null) {
SolItem example = hero.getAbility().getConfig().getChargeExample();
if (example != null) {
UITextureRegion abilityIcon = Assets.getDSTexture(example.getIcon(solApplication.getGame()).name).getUiTexture();
abilityStats.findAll(UIIconBar.class).iterator().next().setIcon(abilityIcon);
}
}

zoneNameAnnouncer.update(solApplication.getGame(), solApplication.getGame().getContext());
Expand Down

0 comments on commit e37c94c

Please sign in to comment.