Implement Blue teleporter exit

A blue teleporter for all intents and purposes except it can only be exited, not entered.
This commit is contained in:
Timothy Stiles 2021-02-16 16:21:12 +11:00
parent b7cedc2426
commit 62a3ed99aa
5 changed files with 58 additions and 12 deletions

View File

@ -829,6 +829,11 @@ const TILE_ENCODING = {
name: 'dash_floor',
is_extension: true,
},
0xd9: {
name: 'teleport_blue_exit',
modifier: modifier_wire,
is_extension: true,
},
0xe0: {
name: 'gift_bow',
has_next: true,

View File

@ -2155,6 +2155,33 @@ export class Level extends LevelInterface {
}
}
//same as above, but accepts multiple tiles
*iter_tiles_in_reading_order(start_cell, names, reverse = false) {
let i = this.coords_to_scalar(start_cell.x, start_cell.y);
let index = TILE_TYPES[names[0]].layer;
while (true) {
if (reverse) {
i -= 1;
if (i < 0) {
i += this.size_x * this.size_y;
}
}
else {
i += 1;
i %= this.size_x * this.size_y;
}
let cell = this.linear_cells[i];
let tile = cell[index];
if (tile && names.indexOf(tile.type.name) >= 0) {
yield tile;
}
if (cell === start_cell)
return;
}
}
// Iterates over the grid in a diamond pattern, spreading out from the given start cell (but not
// including it). Only used for connecting orange buttons.
*iter_cells_in_diamond(start_cell) {

View File

@ -1072,7 +1072,7 @@ class WireOperation extends DrawOperation {
// TODO probably a better way to do this
if (! tile)
continue;
if (['floor', 'steel', 'button_pink', 'button_black', 'teleport_blue', 'teleport_red', 'light_switch_on', 'light_switch_off', 'circuit_block'].indexOf(tile.type.name) < 0)
if (['floor', 'steel', 'button_pink', 'button_black', 'teleport_blue', 'teleport_red', 'light_switch_on', 'light_switch_off', 'circuit_block', 'teleport_blue_exit'].indexOf(tile.type.name) < 0)
continue;
tile = {...tile};
@ -1606,6 +1606,7 @@ const EDITOR_PALETTE = [{
'fire_sticks',
'turntable_cw',
'turntable_ccw',
'teleport_blue_exit',
'electrified_floor',
'halo',
'item_lock',
@ -2197,7 +2198,7 @@ const EDITOR_TILE_DESCRIPTIONS = {
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",
name: "Global cycler",
desc: "When activated, every terrain/item/actor on the surrounding four tiles in the entire level becomes the terrain/item/actor one clockwise. Adjacent tiles with a 'no sign' on them are ignored. Two of the same tile in a row mean that tile will not be transformed and will stay as-is. Actors facing different directions will cause a relative direction change. Tiles next to Global Cyclers are not transformed.",
},
halo: {
@ -2205,19 +2206,19 @@ const EDITOR_TILE_DESCRIPTIONS = {
desc: "Protects the player from death once, destroying the would-be killer in the process.",
},
fire_sticks: {
name: "Dormant Lava",
name: "Dormant lava",
desc: "Acts like dirt. However, fireballs will enter it and turn it into Fire in the process.",
},
turntable_cw: {
name: "Turntable (Clockwise)",
name: "Turntable (clockwise)",
desc: "Rotates anything entering this tile clockwise. Frame blocks are rotated too. If connected to wire, only functions while receiving power.",
},
turntable_ccw: {
name: "Turntable (Counterclockwise)",
name: "Turntable (counterclockwise)",
desc: "Rotates anything entering this tile counterclockwise. Frame blocks are rotated too. If connected to wire, only functions while receiving power.",
},
electrified_floor: {
name: "Electrified Floor",
name: "Electrified floor",
desc: "Conducts power (like a blue teleporter). While powered, destroys anything not wearing lightning boots (except dirt blocks).",
},
hole: {
@ -2225,11 +2226,11 @@ const EDITOR_TILE_DESCRIPTIONS = {
desc: "A bottomless pit. Destroys everything (except ghosts).",
},
cracked_floor: {
name: "Cracked Floor",
name: "Cracked floor",
desc: "Turns into a hole when something steps off of it (except ghosts).",
},
cracked_ice: {
name: "Cracked Ice",
name: "Cracked ice",
desc: "Turns into water when something steps off of it (except ghosts).",
},
score_5x: {
@ -2245,13 +2246,17 @@ const EDITOR_TILE_DESCRIPTIONS = {
desc: "Similar to a dirt block, but rolls when pushed. Boulders transfer momentum to each other. Has ice block/frame block collision. Turns into gravel in water. Spreads slime.",
},
item_lock: {
name: "Item Lock",
name: "Item lock",
desc: "When placed atop an item, you must have that item to enter the tile. When you do, pay the item and destroy the item lock. Also can be placed on top of a bonus, and you must pay that amount of bonus to enter.",
},
dash_floor: {
name: "Dash Floor",
name: "Dash floor",
desc: "Anything walking on it moves at double speed. Stacks with speed shoes!",
},
teleport_blue_exit: {
name: "Blue teleporter exit",
desc: "A blue teleporter for all intents and purposes except it can only be exited, not entered.",
},
};
const SPECIAL_PALETTE_ENTRIES = {

View File

@ -1073,6 +1073,11 @@ export const LL_TILESET_LAYOUT = Object.assign({}, CC2_TILESET_LAYOUT, {
boulder: [8, 40],
item_lock: [12, 43],
dash_floor: [[0, 44], [1, 44], [2, 44], [3, 44], [4, 44], [5, 44], [6, 44], [7, 44]],
teleport_blue_exit: {
__special__: 'wires',
base: [0, 2],
wired: [11, 41],
},
});
export const TILESET_LAYOUTS = {

View File

@ -1647,7 +1647,7 @@ const TILE_TYPES = {
// TODO cc2 has a bug where, once it wraps around to the bottom right, it seems to
// forget that it was ever looking for an unwired teleport and will just grab the
// first one it sees
for (let dest of level.iter_tiles_in_reading_order(me.cell, 'teleport_blue', true)) {
for (let dest of level.iter_tiles_in_reading_order(me.cell, ['teleport_blue', 'teleport_blue_exit'], true)) {
if (! dest.wire_directions) {
yield [dest, exit_direction];
}
@ -1680,7 +1680,7 @@ const TILE_TYPES = {
walked_circuits.add(circuit);
for (let [tile, edges] of circuit.tiles.entries()) {
if (tile.type === me.type) {
if (tile.type === me.type || tile.type.name === 'teleport_blue_exit') {
candidate_teleporters.add(tile);
}
else if (tile.type.name === 'logic_gate' && ! circuit.inputs.get(tile)) {
@ -1715,6 +1715,10 @@ const TILE_TYPES = {
}
},
},
teleport_blue_exit: {
layer: LAYERS.terrain,
wire_propagation_mode: 'all',
},
teleport_red: {
layer: LAYERS.terrain,
slide_mode: 'teleport',