2020-05-09 14:45:23 +00:00
|
|
|
import { MapChunk } from "./map_chunk";
|
|
|
|
import { GameRoot } from "./root";
|
|
|
|
import { DrawParameters } from "../core/draw_parameters";
|
|
|
|
|
|
|
|
export class MapChunkView extends MapChunk {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {GameRoot} root
|
|
|
|
* @param {number} x
|
|
|
|
* @param {number} y
|
|
|
|
*/
|
|
|
|
constructor(root, x, y) {
|
|
|
|
super(root, x, y);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whenever something changes, we increase this number - so we know we need to redraw
|
|
|
|
*/
|
|
|
|
this.renderIteration = 0;
|
|
|
|
|
|
|
|
this.markDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Marks this chunk as dirty, rerendering all caches
|
|
|
|
*/
|
|
|
|
markDirty() {
|
|
|
|
++this.renderIteration;
|
|
|
|
this.renderKey = this.x + "/" + this.y + "@" + this.renderIteration;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws the background layer
|
|
|
|
* @param {DrawParameters} parameters
|
|
|
|
*/
|
|
|
|
drawBackgroundLayer(parameters) {
|
2020-07-06 19:33:37 +00:00
|
|
|
const systems = this.root.systemMgr.systems;
|
|
|
|
systems.mapResources.drawChunk(parameters, this);
|
|
|
|
systems.belt.drawChunk(parameters, this);
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws the foreground layer
|
|
|
|
* @param {DrawParameters} parameters
|
|
|
|
*/
|
|
|
|
drawForegroundLayer(parameters) {
|
2020-07-06 19:33:37 +00:00
|
|
|
const systems = this.root.systemMgr.systems;
|
|
|
|
systems.miner.drawChunk(parameters, this);
|
|
|
|
systems.staticMapEntities.drawChunk(parameters, this);
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-06 19:33:37 +00:00
|
|
|
* Draws the wires layer
|
2020-05-09 14:45:23 +00:00
|
|
|
* @param {DrawParameters} parameters
|
|
|
|
*/
|
2020-07-06 19:33:37 +00:00
|
|
|
drawWiresForegroundLayer(parameters) {
|
2020-05-09 14:45:23 +00:00
|
|
|
const systems = this.root.systemMgr.systems;
|
2020-07-06 19:33:37 +00:00
|
|
|
systems.staticMapEntities.drawWiresChunk(parameters, this);
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
}
|