1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Added display hook for getting the signelton and the drawing

This commit is contained in:
DJ1TJOO 2022-02-06 00:03:14 +01:00
parent 86b104080f
commit d3bc4c30e5

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(