Skip to content

Commit

Permalink
fixed entity removed before shoot task complete error
Browse files Browse the repository at this point in the history
  • Loading branch information
samsully committed Sep 15, 2023
1 parent 3b8cafe commit b97baee
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,17 @@ private void onCollisionEnd(Fixture me, Fixture other) {
}
}

/**
* Choose the weapon to use against the given fixture.
*
* If the fixture has been removed (died) return null, else return the weapon to use.
* */
public Weapon chooseWeapon(Fixture other) {
Entity target = ((BodyUserData) other.getBody().getUserData()).entity;
BodyUserData data = ((BodyUserData) other.getBody().getUserData());
if (data == null) {
return null;
}
Entity target = data.entity;
Weapon weapon = null;
if (target.getComponent(CombatStatsComponent.class) != null) {
weapon = combatStats.getWeapon(target);
Expand Down

0 comments on commit b97baee

Please sign in to comment.