Undo GCing the actor list
This commit is contained in:
parent
5ccaad4666
commit
afa132bd4c
13
js/game.js
13
js/game.js
@ -356,16 +356,16 @@ export class Level {
|
||||
|
||||
if (actor.animation_speed) {
|
||||
// Deal with movement animation
|
||||
actor.animation_progress += 1;
|
||||
this._set_prop(actor, 'animation_progress', actor.animation_progress + 1);
|
||||
if (actor.animation_progress >= actor.animation_speed) {
|
||||
if (actor.type.ttl) {
|
||||
// This is purely an animation so it disappears once it's played
|
||||
this.remove_tile(actor);
|
||||
continue;
|
||||
}
|
||||
actor.previous_cell = null;
|
||||
actor.animation_progress = null;
|
||||
actor.animation_speed = null;
|
||||
this._set_prop(actor, 'previous_cell', null);
|
||||
this._set_prop(actor, 'animation_progress', null);
|
||||
this._set_prop(actor, 'animation_speed', null);
|
||||
if (! this.compat.tiles_react_instantly) {
|
||||
this.step_on_cell(actor);
|
||||
}
|
||||
@ -544,6 +544,7 @@ export class Level {
|
||||
}
|
||||
|
||||
// Strip out any destroyed actors from the acting order
|
||||
// FIXME this is O(n), where n is /usually/ small, but i still don't love it
|
||||
let p = 0;
|
||||
for (let i = 0, l = this.actors.length; i < l; i++) {
|
||||
let actor = this.actors[i];
|
||||
@ -553,6 +554,10 @@ export class Level {
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else {
|
||||
let local_p = p;
|
||||
this.pending_undo.push(() => this.actors.splice(local_p, 0, actor));
|
||||
}
|
||||
}
|
||||
this.actors.length = p;
|
||||
|
||||
|
||||
@ -549,6 +549,7 @@ export class Tileset {
|
||||
w, h);
|
||||
}
|
||||
else {
|
||||
if (!coords) console.error(name, tile);
|
||||
this.blit(ctx, coords[0], coords[1], x, y);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user