From 471c171d47982399cbf9902dfc704374137b5628 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 12 Jul 2021 00:51:03 -0400 Subject: [PATCH] Add FurnitureMysteryBoxLogic --- src/nitro/room/RoomObjectLogicFactory.ts | 5 +++- .../furniture/FurnitureMysteryBoxLogic.ts | 25 +++++++++++++++++++ .../room/object/logic/furniture/index.ts | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/nitro/room/object/logic/furniture/FurnitureMysteryBoxLogic.ts diff --git a/src/nitro/room/RoomObjectLogicFactory.ts b/src/nitro/room/RoomObjectLogicFactory.ts index a283179f..24ba2a42 100644 --- a/src/nitro/room/RoomObjectLogicFactory.ts +++ b/src/nitro/room/RoomObjectLogicFactory.ts @@ -4,7 +4,7 @@ import { IEventDispatcher } from '../../core/events/IEventDispatcher'; import { IRoomObjectEventHandler } from '../../room/object/logic/IRoomObjectEventHandler'; import { IRoomObjectLogicFactory } from '../../room/object/logic/IRoomObjectLogicFactory'; import { RoomObjectLogicBase } from '../../room/object/logic/RoomObjectLogicBase'; -import { FurnitureEffectBoxLogic, FurnitureLoveLockLogic, FurnitureMonsterplantSeedLogic, FurnitureMysteryTrophyLogic, FurnitureRandomTeleportLogic, FurnitureRentableSpaceLogic } from './object'; +import { FurnitureEffectBoxLogic, FurnitureLoveLockLogic, FurnitureMonsterplantSeedLogic, FurnitureMysteryBoxLogic, FurnitureMysteryTrophyLogic, FurnitureRandomTeleportLogic, FurnitureRentableSpaceLogic } from './object'; import { AvatarLogic } from './object/logic/avatar/AvatarLogic'; import { FurnitureBadgeDisplayLogic } from './object/logic/furniture/FurnitureBadgeDisplayLogic'; import { FurnitureChangeStateWhenStepOnLogic } from './object/logic/furniture/FurnitureChangeStateWhenStepOnLogic'; @@ -295,6 +295,9 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory case RoomObjectLogicType.FURNITURE_MONSTERPLANT_SEED: logic = FurnitureMonsterplantSeedLogic; break; + case RoomObjectLogicType.FURNITURE_MYSTERYBOX: + logic = FurnitureMysteryBoxLogic; + break; case RoomObjectLogicType.FURNITURE_MYSTERYTROPHY: logic = FurnitureMysteryTrophyLogic; break; diff --git a/src/nitro/room/object/logic/furniture/FurnitureMysteryBoxLogic.ts b/src/nitro/room/object/logic/furniture/FurnitureMysteryBoxLogic.ts new file mode 100644 index 00000000..0733706a --- /dev/null +++ b/src/nitro/room/object/logic/furniture/FurnitureMysteryBoxLogic.ts @@ -0,0 +1,25 @@ +import { ContextMenuEnum } from '../../../../ui'; +import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent'; +import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic'; + +export class FurnitureMysteryBoxLogic extends FurnitureMultiStateLogic +{ + public getEventTypes(): string[] + { + const types = [ RoomObjectWidgetRequestEvent.MYSTERYBOX_OPEN_DIALOG ]; + + return this.mergeTypes(super.getEventTypes(), types); + } + + public useObject(): void + { + if(!this.eventDispatcher || !this.object) return; + + this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MYSTERYBOX_OPEN_DIALOG, this.object)); + } + + public get contextMenu(): string + { + return ContextMenuEnum.MYSTERY_BOX; + } +} diff --git a/src/nitro/room/object/logic/furniture/index.ts b/src/nitro/room/object/logic/furniture/index.ts index 16cc63b8..21de5e59 100644 --- a/src/nitro/room/object/logic/furniture/index.ts +++ b/src/nitro/room/object/logic/furniture/index.ts @@ -24,6 +24,7 @@ export * from './FurnitureMannequinLogic'; export * from './FurnitureMonsterplantSeedLogic'; export * from './FurnitureMultiHeightLogic'; export * from './FurnitureMultiStateLogic'; +export * from './FurnitureMysteryBoxLogic'; export * from './FurnitureMysteryTrophyLogic'; export * from './FurnitureOneWayDoorLogic'; export * from './FurniturePetCustomizationLogic';