Move too many hotbar items notification to injectable

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-03-01 13:34:47 -05:00
1 parent 38de2edc50
commit 1dd172eafe
6 files changed
+47 -33

No files matched your search

+2 -3
View File
@@ -8,10 +8,8 @@ import type { BaseStoreDependencies } from "../base-store/base-store";
import { BaseStore } from "../base-store/base-store";
import { toJS } from "../utils";
import type { CatalogEntity } from "../catalog";
import { broadcastMessage } from "../ipc";
import type { Hotbar, CreateHotbarData, CreateHotbarOptions } from "./types";
import { defaultHotbarCells, getEmptyHotbar } from "./types";
import { hotbarTooManyItemsChannel } from "../ipc/hotbar";
import type { GeneralEntity } from "../catalog-entities";
import type { Logger } from "../logger";
import assert from "assert";
@@ -24,6 +22,7 @@ export interface HotbarStoreModel {
interface Dependencies extends BaseStoreDependencies {
readonly catalogCatalogEntity: GeneralEntity;
readonly logger: Logger;
onTooManyHotbarItems: () => void;
}
export class HotbarStore extends BaseStore<HotbarStoreModel> {
@@ -195,7 +194,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
if (emptyCellIndex != -1) {
hotbar.items[emptyCellIndex] = newItem;
} else {
broadcastMessage(hotbarTooManyItemsChannel);
this.dependencies.onTooManyHotbarItems();
}
} else if (0 <= cellIndex && cellIndex < hotbar.items.length) {
hotbar.items[cellIndex] = newItem;