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:
parent
65ae26cb53
commit
4466821557
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user