html-tower/static/environment.js

22 lines
778 B
JavaScript

console.log("loading environment system");
const initEnvironmentSystem = (engine) => {
document.querySelectorAll(".environment")
.forEach(entity => {
console.log(entity);
if (!entity.id) {
entity.id = Date.now().toString(16);
}
engine("registerEntity", entity);
console.log(entity.dataset);
let collider = engine("getComponentConstructor", "collision")(
entity, {
layers: new Set(entity.dataset.collisionLayers.split(",")),
mask: new Set(entity.dataset.collisionMask.split(",")),
collsionShape: {}
});
engine("addComponent", entity, "collision", collider);
});
}