fix game crashing on ship destruction
This commit is contained in:
parent
7bd1935723
commit
f138654ccb
3 changed files with 6 additions and 1 deletions
|
@ -66,6 +66,8 @@ class World {
|
|||
body.update(data.slice(i, i + body.interface.size));
|
||||
} else if (discharge) {
|
||||
discharge.update(data.slice(i, i + 2));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
i += body.interface.size;
|
||||
|
|
|
@ -13,7 +13,7 @@ class Room {
|
|||
this.teamB = new Set();
|
||||
this.world = new World(this);
|
||||
this.name = (Math.random() * 100000 | 0).toString(36);
|
||||
this.tps = wingbase.args.development ? 5 : 60;
|
||||
this.tps = wingbase.args.development ? 60 : 60;
|
||||
|
||||
this.idGenerator = (function*() {
|
||||
let i = 0;
|
||||
|
|
|
@ -89,6 +89,8 @@ class World {
|
|||
applyDelta(data, bodyPos) {
|
||||
data = data.map(v => +(v.toFixed(3)));
|
||||
this.players.forEach(player => {
|
||||
if (!player.ship)
|
||||
return;
|
||||
let dx = player.ship.pos.x - bodyPos.x;
|
||||
let dy = player.ship.pos.y - bodyPos.y;
|
||||
if (dx * dx + dy * dy < 900)
|
||||
|
@ -132,6 +134,7 @@ class World {
|
|||
}
|
||||
|
||||
removeBody(body) {
|
||||
if(!body) return;
|
||||
body.destruct();
|
||||
this.bodies.delete(body);
|
||||
this.asteroids.delete(body);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue