mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 23:50:52 +01:00
Add FurnitureAchievementResolutionLogic
This commit is contained in:
parent
361d280f93
commit
2fc1a4ede0
@ -0,0 +1,75 @@
|
||||
import { FurnitureBadgeDisplayLogic } from '.';
|
||||
import { ObjectSelectedMessage } from '../../..';
|
||||
import { RoomObjectEvent } from '../../../../..';
|
||||
import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage';
|
||||
import { RoomObjectBadgeAssetEvent } from '../../../events/RoomObjectBadgeAssetEvent';
|
||||
import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent';
|
||||
import { ObjectGroupBadgeUpdateMessage } from '../../../messages/ObjectGroupBadgeUpdateMessage';
|
||||
import { RoomObjectVariable } from '../../RoomObjectVariable';
|
||||
|
||||
export class FurnitureAchievementResolutionLogic extends FurnitureBadgeDisplayLogic
|
||||
{
|
||||
public static STATE_RESOLUTION_NOT_STARTED: number = 0;
|
||||
public static STATE_RESOLUTION_IN_PROGRESS: number = 1;
|
||||
public static STATE_RESOLUTION_ACHIEVED: number = 2;
|
||||
public static STATE_RESOLUTION_FAILED: number = 3;
|
||||
private static ACH_NOT_SET: string = 'ach_0';
|
||||
private static BADGE_VISIBLE_IN_STATE: number = 2;
|
||||
|
||||
public getEventTypes(): string[]
|
||||
{
|
||||
const types = [ RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_OPEN, RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_ENGRAVING, RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_FAILED, RoomObjectBadgeAssetEvent.LOAD_BADGE ];
|
||||
|
||||
return this.mergeTypes(super.getEventTypes(), types);
|
||||
}
|
||||
|
||||
public processUpdateMessage(message: RoomObjectUpdateMessage): void
|
||||
{
|
||||
super.processUpdateMessage(message);
|
||||
|
||||
if(message instanceof ObjectGroupBadgeUpdateMessage)
|
||||
{
|
||||
if(message.assetName !== 'loading_icon')
|
||||
{
|
||||
this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_VISIBLE_IN_STATE, FurnitureAchievementResolutionLogic.BADGE_VISIBLE_IN_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
if(message instanceof ObjectSelectedMessage)
|
||||
{
|
||||
if(!this.eventDispatcher || !this.object) return;
|
||||
|
||||
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object));
|
||||
}
|
||||
}
|
||||
|
||||
public useObject(): void
|
||||
{
|
||||
if(!this.object || !this.eventDispatcher) return;
|
||||
|
||||
let event: RoomObjectEvent = null;
|
||||
|
||||
switch(this.object.getState(0))
|
||||
{
|
||||
case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_NOT_STARTED:
|
||||
case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_IN_PROGRESS:
|
||||
event = new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_OPEN, this.object);
|
||||
break;
|
||||
case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_ACHIEVED:
|
||||
event = new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_ENGRAVING, this.object);
|
||||
break;
|
||||
case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_FAILED:
|
||||
event = new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_FAILED, this.object);
|
||||
break;
|
||||
}
|
||||
|
||||
if(event) this.eventDispatcher.dispatchEvent(event);
|
||||
}
|
||||
|
||||
protected updateBadge(badgeId: string): void
|
||||
{
|
||||
if(badgeId === FurnitureAchievementResolutionLogic.ACH_NOT_SET) return;
|
||||
|
||||
super.updateBadge(badgeId);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user