Add on_approach; use it to erase animations and fix popdown floors

This commit is contained in:
Eevee (Evelyn Woods) 2020-12-12 19:00:58 -07:00
parent 077ac65650
commit 4d23acb27e
2 changed files with 24 additions and 2 deletions

View File

@ -996,6 +996,18 @@ export class Level {
this.sfx.play_once('step-floor');
}
// Announce we're approaching
for (let tile of Array.from(actor.cell)) {
if (tile === actor)
continue;
if (actor.ignores(tile.type.name))
continue;
if (tile.type.on_approach) {
tile.type.on_approach(tile, this, actor);
}
}
if (this.compat.tiles_react_instantly) {
this.step_on_cell(actor, actor.cell);
}

View File

@ -284,8 +284,7 @@ const TILE_TYPES = {
popdown_floor: {
draw_layer: DRAW_LAYERS.terrain,
blocks_collision: COLLISION.block_cc1 | COLLISION.block_cc2,
// FIXME should be on_approach
on_arrive(me, level, other) {
on_approach(me, level, other) {
// FIXME could probably do this with state? or, eh
level.transmute_tile(me, 'popdown_floor_visible');
},
@ -2301,6 +2300,11 @@ const TILE_TYPES = {
collision_mask: 0,
blocks_collision: COLLISION.player,
ttl: 6,
// If anything else even begins to step on an animation, it's erased
// FIXME possibly erased too fast; cc2 shows it briefly? could i get away with on_arrive here?
on_approach(me, level, other) {
level.remove_tile(me);
},
},
explosion: {
draw_layer: DRAW_LAYERS.overlay,
@ -2308,6 +2312,9 @@ const TILE_TYPES = {
collision_mask: 0,
blocks_collision: COLLISION.player,
ttl: 6,
on_approach(me, level, other) {
level.remove_tile(me);
},
},
// Used as an easy way to show an invisible wall when bumped
wall_invisible_revealed: {
@ -2325,6 +2332,9 @@ const TILE_TYPES = {
collision_mask: 0,
blocks_collision: COLLISION.player,
ttl: 6,
on_approach(me, level, other) {
level.remove_tile(me);
},
},
// Invalid tiles that appear in some CCL levels because community level