HollowBond/Public/ecma/Models/HoleModel.ecma.js

49 lines
1.5 KiB
JavaScript

"use strict";
const HoleModel = (function(){
const HoleModel = function(hollow_bond, inputs = {}){
const self = this;
// Límites lógicos absolutos
this.xf = Common.get_value("xf", inputs, 0) | 0;
this.yf = Common.get_value("yf", inputs, 0) | 0; // Piso inferior
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 superior
this.zt = Common.get_value("zt", inputs, 0) | 0;
this.width = this.xt - this.xf;
this.height = this.yt - this.yf;
this.depth = this.zt - this.zf;
this.id = HoleModel.get_id(self.xf, self.yf, self.zf, self.xt, self.yt, self.zt);
this.rooms = Common.get_value("rooms", inputs, []);
this.stairs = Common.get_value("stairs", inputs, []);
const constructor = () => {
hollow_bond.builders.stairs.generate(self);
};
this.get_world_bounds = () => {
return {
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
};
};
constructor();
};
HoleModel.get_id = (xf, yf, zf, xt, yt, zt) => `hole_${xf}_${yf}_${zf}_${xt}_${yt}_${zt}`;
return HoleModel;
})();