1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00

Added display hook for getting the signelton and the drawing (#1374)

This commit is contained in:
Thomas (DJ1TJOO) 2022-02-13 21:06:42 +01:00 committed by GitHub
parent 65ae26cb53
commit 4466821557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,15 @@ import { isTrueItem } from "../items/boolean_item";
import { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
import { MapChunkView } from "../map_chunk_view";
/** @type {{
* [x: string]: (item: BaseItem) => BaseItem
* }} */
export const MODS_ADDITIONAL_DISPLAY_ITEM_RESOLVER = {};
/** @type {{
* [x: string]: (parameters: import("../../core/draw_parameters").DrawParameters, entity: import("../entity").Entity, item: BaseItem) => BaseItem
* }} */
export const MODS_ADDITIONAL_DISPLAY_ITEM_DRAW = {};
export class DisplaySystem extends GameSystem {
constructor(root) {
super(root);
@ -32,6 +41,10 @@ export class DisplaySystem extends GameSystem {
return null;
}
if (MODS_ADDITIONAL_DISPLAY_ITEM_RESOLVER[value.getItemType()]) {
return MODS_ADDITIONAL_DISPLAY_ITEM_RESOLVER[value.getItemType()].apply(this, [value]);
}
switch (value.getItemType()) {
case "boolean": {
return isTrueItem(value) ? COLOR_ITEM_SINGLETONS[enumColors.white] : null;
@ -74,6 +87,14 @@ export class DisplaySystem extends GameSystem {
continue;
}
if (MODS_ADDITIONAL_DISPLAY_ITEM_DRAW[value.getItemType()]) {
return MODS_ADDITIONAL_DISPLAY_ITEM_DRAW[value.getItemType()].apply(this, [
parameters,
entity,
value,
]);
}
const origin = entity.components.StaticMapEntity.origin;
if (value.getItemType() === "color") {
this.displaySprites[/** @type {ColorItem} */ (value).color].drawCachedCentered(