Skip to content

Commit

Permalink
fix: colliding with a small object doesn't cause the game to crash
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacLic committed Aug 17, 2020
1 parent 0ec6a7f commit 517607c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.destinationsol.common.SolMath;
import org.destinationsol.game.SolGame;
import org.destinationsol.game.SolObject;
import org.destinationsol.game.SolObjectEntityWrapper;
import org.destinationsol.game.planet.Planet;
import org.destinationsol.game.ship.SolShip;
import org.terasology.gestalt.entitysystem.entity.EntityRef;

public class SmallObjAvoider {
public static final float MANEUVER_TIME = 2f;
Expand Down Expand Up @@ -85,7 +87,11 @@ public float avoid(SolGame game, SolShip ship, float toDestAngle, Planet np) {
private class MyRayBack implements RayCastCallback {
@Override
public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
SolObject o = (SolObject) fixture.getBody().getUserData();
Object data = fixture.getBody().getUserData();
if (data instanceof EntityRef) {
data = new SolObjectEntityWrapper((EntityRef) data);
}
SolObject o = (SolObject) data;
if (myShip == o) {
return -1;
}
Expand Down

0 comments on commit 517607c

Please sign in to comment.