HollowBond/Public/ecma/Models/StairsModel.ecma.js

48 lines
1.7 KiB
JavaScript

"use strict";
const StairsModel = (function(){
const StairsModel = function(hollow_bond, inputs = {}){
const self = this;
this.id = Common.get_value("id", inputs, "") || hollow_bond.get_id("stairs");
this.hole_id = Common.get_value("hole_id", inputs, "");
// Coordenadas lógicas de la caja total 4x1x2 o 1x4x2
this.xf = Common.get_value("xf", inputs, 0) | 0;
this.yf = Common.get_value("yf", inputs, 0) | 0; // Piso de salida
this.zf = Common.get_value("zf", inputs, 0) | 0;
this.xt = Common.get_value("xt", inputs, 0) | 0;
this.yt = Common.get_value("yt", inputs, 0) | 0; // Piso de llegada (yf + 2)
this.zt = Common.get_value("zt", inputs, 0) | 0;
// "north", "south", "east", "west" (a qué pared interior del pozo se pega)
this.wall = Common.get_value("wall", inputs, "north");
// Sentido de subida: 1 (hacia coordenadas crecientes) o -1 (hacia decrecientes)
this.direction = Common.get_value("direction", inputs, 1);
this.width = this.xt - this.xf;
this.depth = this.zt - this.zf;
this.height = this.yt - this.yf;
this.padding = hollow_bond.stairs_padding;
// Habitaciones conectadas por los descansillos inferior y superior
this.room_from = Common.get_value("room_from", inputs, null);
this.room_to = Common.get_value("room_to", inputs, null);
this.get_world_bounds = () => ({
x : self.xf,
y : self.yf * hollow_bond.room_height,
z : self.zf,
width : self.width,
height : self.height * hollow_bond.room_height,
depth : self.depth
});
};
return StairsModel;
})();