Skip to content

Commit e37c94c

Browse files
authored
fix: fix crash when playing ships with no ability (#682)
1 parent 3d015cf commit e37c94c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

engine/src/main/java/org/destinationsol/ui/nui/screens/MainGameScreen.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ public Float get() {
237237
@Override
238238
public UITextureRegion get() {
239239
Hero hero = solApplication.getGame().getHero();
240+
if (hero.getAbility() == null) {
241+
return null;
242+
}
243+
240244
SolItem example = hero.getAbility().getConfig().getChargeExample();
241245
if (example != null) {
242246
return Assets.getDSTexture(example.getIcon(solApplication.getGame()).name).getUiTexture();
@@ -247,7 +251,7 @@ public UITextureRegion get() {
247251
@Override
248252
public Float get() {
249253
Hero hero = solApplication.getGame().getHero();
250-
if (hero.getAbilityAwait() > 0) {
254+
if (hero.getAbility() != null && hero.getAbilityAwait() > 0) {
251255
return 1.0f - hero.getAbilityAwait() / hero.getAbility().getConfig().getRechargeTime();
252256
} else {
253257
return 1.0f;
@@ -265,6 +269,10 @@ public UITextureRegion get() {
265269
public Float get() {
266270
SolGame game = solApplication.getGame();
267271
Hero hero = game.getHero();
272+
if (hero.getAbility() == null) {
273+
return 0.0f;
274+
}
275+
268276
SolItem example = hero.getAbility().getConfig().getChargeExample();
269277
if (example != null) {
270278
return (float) hero.getItemContainer().count(example);
@@ -521,10 +529,12 @@ public void update(float delta) {
521529
gun2Stats.findAll(UIIconBar.class).iterator().next().setIcon(gun2ClipIcon);
522530
}
523531

524-
SolItem example = hero.getAbility().getConfig().getChargeExample();
525-
if (example != null) {
526-
UITextureRegion abilityIcon = Assets.getDSTexture(example.getIcon(solApplication.getGame()).name).getUiTexture();
527-
abilityStats.findAll(UIIconBar.class).iterator().next().setIcon(abilityIcon);
532+
if (hero.getAbility() != null) {
533+
SolItem example = hero.getAbility().getConfig().getChargeExample();
534+
if (example != null) {
535+
UITextureRegion abilityIcon = Assets.getDSTexture(example.getIcon(solApplication.getGame()).name).getUiTexture();
536+
abilityStats.findAll(UIIconBar.class).iterator().next().setIcon(abilityIcon);
537+
}
528538
}
529539

530540
zoneNameAnnouncer.update(solApplication.getGame(), solApplication.getGame().getContext());

0 commit comments

Comments
 (0)