mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Added hook for storage can accept item (#1373)
* Added hook for storage can accept item * Fixed order
This commit is contained in:
parent
e5742fd577
commit
65ae26cb53
@ -5,6 +5,10 @@ import { typeItemSingleton } from "../item_resolver";
|
|||||||
import { ColorItem } from "../items/color_item";
|
import { ColorItem } from "../items/color_item";
|
||||||
import { ShapeItem } from "../items/shape_item";
|
import { ShapeItem } from "../items/shape_item";
|
||||||
|
|
||||||
|
/** @type {{
|
||||||
|
* [x: string]: (item: BaseItem) => Boolean
|
||||||
|
* }} */
|
||||||
|
export const MODS_ADDITIONAL_STORAGE_ITEM_RESOLVER = {};
|
||||||
export class StorageComponent extends Component {
|
export class StorageComponent extends Component {
|
||||||
static getId() {
|
static getId() {
|
||||||
return "Storage";
|
return "Storage";
|
||||||
@ -56,11 +60,15 @@ export class StorageComponent extends Component {
|
|||||||
|
|
||||||
const itemType = item.getItemType();
|
const itemType = item.getItemType();
|
||||||
|
|
||||||
// Check type matches
|
|
||||||
if (itemType !== this.storedItem.getItemType()) {
|
if (itemType !== this.storedItem.getItemType()) {
|
||||||
|
// Check type matches
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MODS_ADDITIONAL_STORAGE_ITEM_RESOLVER[itemType]) {
|
||||||
|
return MODS_ADDITIONAL_STORAGE_ITEM_RESOLVER[itemType].apply(this, [item]);
|
||||||
|
}
|
||||||
|
|
||||||
if (itemType === "color") {
|
if (itemType === "color") {
|
||||||
return /** @type {ColorItem} */ (this.storedItem).color === /** @type {ColorItem} */ (item).color;
|
return /** @type {ColorItem} */ (this.storedItem).color === /** @type {ColorItem} */ (item).color;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user