From 67b4e0be8b8ef3487b54d0f2de8fa99fc947fd53 Mon Sep 17 00:00:00 2001 From: DJ1TJOO Date: Sat, 5 Feb 2022 22:50:31 +0100 Subject: [PATCH] Added hook for storage can accept item --- src/js/game/components/storage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/js/game/components/storage.js b/src/js/game/components/storage.js index be243a44..4a4f7cf0 100644 --- a/src/js/game/components/storage.js +++ b/src/js/game/components/storage.js @@ -5,6 +5,10 @@ import { typeItemSingleton } from "../item_resolver"; import { ColorItem } from "../items/color_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 { static getId() { return "Storage"; @@ -56,8 +60,12 @@ export class StorageComponent extends Component { const itemType = item.getItemType(); - // Check type matches + if (MODS_ADDITIONAL_STORAGE_ITEM_RESOLVER[itemType]) { + return MODS_ADDITIONAL_STORAGE_ITEM_RESOLVER[itemType].apply(this, [item]); + } + if (itemType !== this.storedItem.getItemType()) { + // Check type matches return false; }