Terraformer alt behaviour when it has an item on top

When activated, if there's an item on its tile, copies the item to the tile in front of it. Otherwise, copies the item AND terrain BEHIND it to the tile in front of it.
This commit is contained in:
Timothy Stiles 2021-02-06 23:08:39 +11:00
parent 0100f1e12c
commit 4f0ff2b346
2 changed files with 19 additions and 7 deletions

View File

@ -2178,7 +2178,7 @@ const EDITOR_TILE_DESCRIPTIONS = {
},
terraformer_n: {
name: "Terraformer",
desc: "When activated, copies the terrain and item behind it to the tile in front of it.",
desc: "When activated, if there's an item on its tile, copies the item to the tile in front of it. Otherwise, copies the item AND terrain BEHIND it to the tile in front of it.",
},
global_cycler: {
name: "Global Cycler",

View File

@ -91,12 +91,23 @@ function _define_gate(key) {
function activate_terraformer(me, level, dx, dy) {
let did_something = false;
let old_cell = level.cell(
let item_only = false;
let old_cell = level.cell(me.cell.x, me.cell.y);
if (old_cell.get_item() != null)
{
item_only = true;
}
else
{
old_cell = level.cell(
(me.cell.x - dx + level.width) % level.width,
(me.cell.y - dy + level.height) % level.height);
}
let new_cell = level.cell(
(me.cell.x + dx + level.width) % level.width,
(me.cell.y + dy + level.height) % level.height);
if (!item_only)
{
let old_terrain = old_cell.get_terrain();
let new_terrain = new_cell.get_terrain();
if (old_terrain.type.name != new_terrain.type.name)
@ -104,6 +115,7 @@ function activate_terraformer(me, level, dx, dy) {
level.transmute_tile(new_cell.get_terrain(), old_terrain.type.name);
did_something = true;
}
}
let old_item = old_cell.get_item();
if (old_item != null)
{