From 4d23acb27e8ee17ecfeaec48781189be203cd74f Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Sat, 12 Dec 2020 19:00:58 -0700 Subject: [PATCH] Add on_approach; use it to erase animations and fix popdown floors --- js/game.js | 12 ++++++++++++ js/tiletypes.js | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/js/game.js b/js/game.js index 609a316..f14d35d 100644 --- a/js/game.js +++ b/js/game.js @@ -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); } diff --git a/js/tiletypes.js b/js/tiletypes.js index daaa8a8..8ca84e8 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -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