|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
import { GameRoot } from "../../root";
|
|
|
|
|
import { Vector } from "../../../core/vector";
|
|
|
|
|
import { Entity } from "../../entity";
|
|
|
|
|
import { DrawParameters } from "../../../core/draw_parameters";
|
|
|
|
|
import { StaticMapEntityComponent } from "../../components/static_map_entity";
|
|
|
|
|
import { createLogger } from "../../../core/logging";
|
|
|
|
|
import { Loader } from "../../../core/loader";
|
|
|
|
|
import { createLogger } from "../../../core/logging";
|
|
|
|
|
import { Vector } from "../../../core/vector";
|
|
|
|
|
import { Entity } from "../../entity";
|
|
|
|
|
import { GameRoot } from "../../root";
|
|
|
|
|
|
|
|
|
|
const logger = createLogger("blueprint");
|
|
|
|
|
|
|
|
|
@ -17,6 +16,7 @@ export class Blueprint {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new blueprint from the given entity uids
|
|
|
|
|
* @param {GameRoot} root
|
|
|
|
|
* @param {Array<number>} uids
|
|
|
|
|
*/
|
|
|
|
@ -48,7 +48,7 @@ export class Blueprint {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* Draws the blueprint at the given origin
|
|
|
|
|
* @param {DrawParameters} parameters
|
|
|
|
|
*/
|
|
|
|
|
draw(parameters, tile) {
|
|
|
|
@ -93,6 +93,31 @@ export class Blueprint {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rotates the blueprint clockwise
|
|
|
|
|
*/
|
|
|
|
|
rotateCw() {
|
|
|
|
|
for (let i = 0; i < this.entities.length; ++i) {
|
|
|
|
|
const entity = this.entities[i];
|
|
|
|
|
const staticComp = entity.components.StaticMapEntity;
|
|
|
|
|
|
|
|
|
|
staticComp.rotation = (staticComp.rotation + 90) % 360;
|
|
|
|
|
staticComp.originalRotation = (staticComp.originalRotation + 90) % 360;
|
|
|
|
|
staticComp.origin = staticComp.origin.rotateFastMultipleOf90(90);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rotates the blueprint counter clock wise
|
|
|
|
|
*/
|
|
|
|
|
rotateCcw() {
|
|
|
|
|
// Well ...
|
|
|
|
|
for (let i = 0; i < 3; ++i) {
|
|
|
|
|
this.rotateCw();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if the blueprint can be placed at the given tile
|
|
|
|
|
* @param {GameRoot} root
|
|
|
|
|
* @param {Vector} tile
|
|
|
|
|
*/
|
|
|
|
@ -123,10 +148,12 @@ export class Blueprint {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Attempts to place the blueprint at the given tile
|
|
|
|
|
* @param {GameRoot} root
|
|
|
|
|
* @param {Vector} tile
|
|
|
|
|
*/
|
|
|
|
|
tryPlace(root, tile) {
|
|
|
|
|
return root.logic.performBulkOperation(() => {
|
|
|
|
|
let anyPlaced = false;
|
|
|
|
|
for (let i = 0; i < this.entities.length; ++i) {
|
|
|
|
|
let placeable = true;
|
|
|
|
@ -172,5 +199,6 @@ export class Blueprint {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return anyPlaced;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|