From a0b34217b49f3d8d6436045d2a502f5e08642396 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Thu, 24 Dec 2020 09:44:29 -0700 Subject: [PATCH] Implement the goofy CC2 "open trap" tile --- js/format-c2g.js | 14 ++++++++++++-- js/tiletypes.js | 9 +++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/js/format-c2g.js b/js/format-c2g.js index 4b8d2bc..dbd4c6a 100644 --- a/js/format-c2g.js +++ b/js/format-c2g.js @@ -358,8 +358,18 @@ const TILE_ENCODING = { has_next: true, }, 0x41: { - // FIXME cc2lp1 uses this, i don't know what it actually does - error: "Open trap is not yet implemented!", + name: 'trap', + // Not actually a modifier, just using this for hax + // FIXME round-trip this, maybe expose it in the editor (sigh) + modifier: { + dummy: true, + decode(tile, mod) { + tile._initially_open = true; + }, + encode(tile) { + return 0; + }, + }, }, 0x42: { name: 'trap', diff --git a/js/tiletypes.js b/js/tiletypes.js index 0ef171e..3d50de7 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -782,8 +782,6 @@ const TILE_TYPES = { }, slime: { draw_layer: DRAW_LAYERS.terrain, - // FIXME kills everything except ghosts, blobs, blocks - // FIXME blobs spread slime onto floor tiles, even destroying wiring on_arrive(me, level, other) { if (other.type.name === 'dirt_block' || other.type.name === 'ice_block') { level.transmute_tile(me, 'floor'); @@ -1085,10 +1083,13 @@ const TILE_TYPES = { }, remove_press(me, level) { level._set_tile_prop(me, 'presses', me.presses - 1); + if (me._initially_open) { + level._set_tile_prop(me, '_initially_open', false); + } }, // FIXME also doesn't trap ghosts, is that a special case??? traps(me, actor) { - return ! me.presses; + return ! me.presses && ! me._initially_open && actor.type.name !== 'ghost'; }, on_power(me, level) { // Treat being powered or not as an extra kind of brown button press @@ -1098,7 +1099,7 @@ const TILE_TYPES = { me.type.remove_press(me, level); }, visual_state(me) { - if (me && me.presses) { + if (me && (me.presses || me._initially_open)) { return 'open'; } else {