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:
parent
0100f1e12c
commit
4f0ff2b346
@ -2178,7 +2178,7 @@ const EDITOR_TILE_DESCRIPTIONS = {
|
|||||||
},
|
},
|
||||||
terraformer_n: {
|
terraformer_n: {
|
||||||
name: "Terraformer",
|
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: {
|
global_cycler: {
|
||||||
name: "Global Cycler",
|
name: "Global Cycler",
|
||||||
|
|||||||
@ -91,18 +91,30 @@ function _define_gate(key) {
|
|||||||
|
|
||||||
function activate_terraformer(me, level, dx, dy) {
|
function activate_terraformer(me, level, dx, dy) {
|
||||||
let did_something = false;
|
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.x - dx + level.width) % level.width,
|
||||||
(me.cell.y - dy + level.height) % level.height);
|
(me.cell.y - dy + level.height) % level.height);
|
||||||
|
}
|
||||||
let new_cell = level.cell(
|
let new_cell = level.cell(
|
||||||
(me.cell.x + dx + level.width) % level.width,
|
(me.cell.x + dx + level.width) % level.width,
|
||||||
(me.cell.y + dy + level.height) % level.height);
|
(me.cell.y + dy + level.height) % level.height);
|
||||||
let old_terrain = old_cell.get_terrain();
|
if (!item_only)
|
||||||
let new_terrain = new_cell.get_terrain();
|
|
||||||
if (old_terrain.type.name != new_terrain.type.name)
|
|
||||||
{
|
{
|
||||||
level.transmute_tile(new_cell.get_terrain(), old_terrain.type.name);
|
let old_terrain = old_cell.get_terrain();
|
||||||
did_something = true;
|
let new_terrain = new_cell.get_terrain();
|
||||||
|
if (old_terrain.type.name != new_terrain.type.name)
|
||||||
|
{
|
||||||
|
level.transmute_tile(new_cell.get_terrain(), old_terrain.type.name);
|
||||||
|
did_something = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let old_item = old_cell.get_item();
|
let old_item = old_cell.get_item();
|
||||||
if (old_item != null)
|
if (old_item != null)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user