mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
44 lines
939 B
JavaScript
44 lines
939 B
JavaScript
|
/* typehints:start */
|
||
|
import { GameRoot } from "./root";
|
||
|
import { DrawParameters } from "../core/draw_parameters";
|
||
|
/* typehints:end */
|
||
|
|
||
|
/**
|
||
|
* A game system processes all entities which match a given schema, usually a list of
|
||
|
* required components. This is the core of the game logic.
|
||
|
*/
|
||
|
export class GameSystem {
|
||
|
/**
|
||
|
* @param {GameRoot} root
|
||
|
*/
|
||
|
constructor(root) {
|
||
|
this.root = root;
|
||
|
}
|
||
|
|
||
|
///// PUBLIC API /////
|
||
|
|
||
|
/**
|
||
|
* Updates the game system, override to perform logic
|
||
|
*/
|
||
|
update() {}
|
||
|
|
||
|
/**
|
||
|
* Override, do not call this directly, use startDraw()
|
||
|
* @param {DrawParameters} parameters
|
||
|
*/
|
||
|
draw(parameters) {}
|
||
|
|
||
|
/**
|
||
|
* Should refresh all caches
|
||
|
*/
|
||
|
refreshCaches() {}
|
||
|
|
||
|
/**
|
||
|
* @see GameSystem.draw Wrapper arround the draw method
|
||
|
* @param {DrawParameters} parameters
|
||
|
*/
|
||
|
startDraw(parameters) {
|
||
|
this.draw(parameters);
|
||
|
}
|
||
|
}
|