Initialize direction when placing actor tiles in the editor

This commit is contained in:
Eevee (Evelyn Woods) 2020-11-23 22:18:40 -07:00
parent ca4eaa86cb
commit fb301b3b3e
3 changed files with 10 additions and 4 deletions

View File

@ -4,7 +4,9 @@ import TILE_TYPES from './tiletypes.js';
export class Tile {
constructor(type, direction = 'south') {
this.type = type;
if (type.is_actor) {
this.direction = direction;
}
this.cell = null;
if (type.is_actor) {

View File

@ -772,6 +772,10 @@ export class Editor extends PrimaryView {
return;
let type = TILE_TYPES[name];
let direction;
if (type.is_actor) {
direction = 'south';
}
let cell = this.stored_level.cells[y][x];
// For terrain tiles, erase the whole cell. For other tiles, only
// replace whatever's on the same layer
@ -779,7 +783,7 @@ export class Editor extends PrimaryView {
// combine e.g. the tent with thin walls
if (type.draw_layer === 0) {
cell.length = 0;
cell.push({type});
cell.push({type, direction});
}
else {
for (let i = cell.length - 1; i >= 0; i--) {
@ -787,7 +791,7 @@ export class Editor extends PrimaryView {
cell.splice(i, 1);
}
}
cell.push({type});
cell.push({type, direction});
cell.sort((a, b) => a.type.draw_layer - b.type.draw_layer);
}
}

View File

@ -1428,7 +1428,7 @@ class Splash extends PrimaryView {
cell.push({type: TILE_TYPES['floor']});
stored_level.linear_cells.push(cell);
}
stored_level.linear_cells[0].push({type: TILE_TYPES['player']});
stored_level.linear_cells[0].push({type: TILE_TYPES['player'], direction: 'south'});
// FIXME definitely gonna need a name here chief
let stored_game = new format_base.StoredGame(null);