This repository has been archived on 2021-02-20. You can view files and clone it, but cannot push or open issues or pull requests.
shapez.io/src/js/game/map_chunk_view.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-05-09 16:45:23 +02: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) {
const systems = this.root.systemMgr.systems;
systems.mapResources.drawChunk(parameters, this);
systems.belt.drawChunk(parameters, this);
2020-05-09 16:45:23 +02:00
}
/**
* Draws the foreground layer
* @param {DrawParameters} parameters
*/
drawForegroundLayer(parameters) {
const systems = this.root.systemMgr.systems;
systems.miner.drawChunk(parameters, this);
systems.staticMapEntities.drawChunk(parameters, this);
2020-05-09 16:45:23 +02:00
}
/**
* Draws the wires layer
2020-05-09 16:45:23 +02:00
* @param {DrawParameters} parameters
*/
drawWiresForegroundLayer(parameters) {
2020-05-09 16:45:23 +02:00
const systems = this.root.systemMgr.systems;
systems.staticMapEntities.drawWiresChunk(parameters, this);
2020-05-09 16:45:23 +02:00
}
}