mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-30 03:00:51 +01:00
Update methods to async
This commit is contained in:
parent
a0ca11fa2e
commit
c95b1e852b
@ -1,10 +1,10 @@
|
||||
import { IDisposable } from './IDisposable';
|
||||
import { INitroEvent } from './INitroEvent';
|
||||
|
||||
export interface IEventDispatcher extends IDisposable
|
||||
export interface IEventDispatcher
|
||||
{
|
||||
addEventListener(type: string, callback: Function): void
|
||||
dispose(): void;
|
||||
addEventListener<T extends INitroEvent>(type: string, callback: (event: T) => void): void;
|
||||
removeEventListener(type: string, callback: Function): void;
|
||||
removeAllListeners(): void;
|
||||
dispatchEvent(event: INitroEvent): boolean;
|
||||
dispatchEvent<T extends INitroEvent>(event: T): boolean;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { IEventDispatcher } from '../../common';
|
||||
|
||||
export interface IAvatarAssetDownloadLibrary extends IEventDispatcher
|
||||
export interface IAvatarAssetDownloadLibrary
|
||||
{
|
||||
downloadAsset(): void;
|
||||
downloadAsset(): Promise<void>;
|
||||
readonly libraryName: string;
|
||||
readonly isLoaded: boolean;
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { AvatarAssetDownloadManager, AvatarStructure } from '../../../nitro';
|
||||
import { IAssetManager, IGraphicAsset } from '../../asset';
|
||||
import { INitroManager } from '../../common';
|
||||
import { IAvatarEffectListener } from './IAvatarEffectListener';
|
||||
import { IAvatarFigureContainer } from './IAvatarFigureContainer';
|
||||
import { IAvatarImage } from './IAvatarImage';
|
||||
import { IAvatarImageListener } from './IAvatarImageListener';
|
||||
import { IStructureData } from './structure';
|
||||
|
||||
export interface IAvatarRenderManager extends INitroManager
|
||||
export interface IAvatarRenderManager
|
||||
{
|
||||
init(): Promise<void>;
|
||||
createFigureContainer(figure: string): IAvatarFigureContainer;
|
||||
isFigureContainerReady(container: IAvatarFigureContainer): boolean;
|
||||
createAvatarImage(figure: string, size: string, gender: string, listener?: IAvatarImageListener, effectListener?: IAvatarEffectListener): IAvatarImage;
|
||||
@ -19,7 +19,6 @@ export interface IAvatarRenderManager extends INitroManager
|
||||
getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[];
|
||||
getAssetByName(name: string): IGraphicAsset;
|
||||
assets: IAssetManager;
|
||||
isReady: boolean;
|
||||
structure: AvatarStructure;
|
||||
structureData: IStructureData;
|
||||
downloadManager: AvatarAssetDownloadManager;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { IAssetAnimation } from '../../asset';
|
||||
import { IEventDispatcher } from '../../common';
|
||||
|
||||
export interface IEffectAssetDownloadLibrary extends IEventDispatcher
|
||||
export interface IEffectAssetDownloadLibrary
|
||||
{
|
||||
downloadAsset(): void;
|
||||
readonly libraryName: string;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { Resource, Texture } from '@pixi/core';
|
||||
import { IEventDispatcher } from '../../common';
|
||||
import { IRoomCameraWidgetEffect } from './IRoomCameraWidgetEffect';
|
||||
import { IRoomCameraWidgetSelectedEffect } from './IRoomCameraWidgetSelectedEffect';
|
||||
|
||||
@ -7,7 +6,6 @@ export interface IRoomCameraWidgetManager
|
||||
{
|
||||
init(): void;
|
||||
applyEffects(texture: Texture<Resource>, selectedEffects: IRoomCameraWidgetSelectedEffect[], isZoomed: boolean): Promise<HTMLImageElement>;
|
||||
events: IEventDispatcher;
|
||||
effects: Map<string, IRoomCameraWidgetEffect>;
|
||||
isLoaded: boolean;
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
import { INitroManager } from '../../common';
|
||||
import { IConnection } from './IConnection';
|
||||
import { IMessageEvent } from './IMessageEvent';
|
||||
import { INitroCommunicationDemo } from './INitroCommunicationDemo';
|
||||
|
||||
export interface INitroCommunicationManager extends INitroManager
|
||||
export interface ICommunicationManager
|
||||
{
|
||||
init(): Promise<void>;
|
||||
registerMessageEvent(event: IMessageEvent): IMessageEvent;
|
||||
removeMessageEvent(event: IMessageEvent): void;
|
||||
demo: INitroCommunicationDemo;
|
||||
connection: IConnection;
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
import { IEventDispatcher } from '../../common';
|
||||
import { IMessageComposer } from './IMessageComposer';
|
||||
import { IMessageConfiguration } from './IMessageConfiguration';
|
||||
import { IMessageEvent } from './IMessageEvent';
|
||||
|
||||
export interface IConnection extends IEventDispatcher
|
||||
export interface IConnection
|
||||
{
|
||||
init(socketUrl: string): void;
|
||||
dispose(): void;
|
||||
onReady(): void;
|
||||
ready(): void;
|
||||
authenticated(): void;
|
||||
send(...composers: IMessageComposer<unknown[]>[]): void;
|
||||
processReceivedData(): void;
|
||||
|
@ -1,3 +0,0 @@
|
||||
import { INitroManager } from '../../common';
|
||||
|
||||
export type INitroCommunicationDemo = INitroManager
|
@ -1,4 +1,5 @@
|
||||
export * from './ICodec';
|
||||
export * from './ICommunicationManager';
|
||||
export * from './IConnection';
|
||||
export * from './IConnectionStateListener';
|
||||
export * from './IMessageComposer';
|
||||
@ -6,6 +7,4 @@ export * from './IMessageConfiguration';
|
||||
export * from './IMessageDataWrapper';
|
||||
export * from './IMessageEvent';
|
||||
export * from './IMessageParser';
|
||||
export * from './INitroCommunicationDemo';
|
||||
export * from './INitroCommunicationManager';
|
||||
export * from './enums';
|
||||
|
@ -1,3 +1,6 @@
|
||||
import { INitroManager } from '../../common';
|
||||
|
||||
export type IConfigurationManager = INitroManager
|
||||
|
||||
export interface IConfigurationManager
|
||||
{
|
||||
init(): Promise<void>;
|
||||
reloadConfiguration(): Promise<void>;
|
||||
}
|
||||
|
@ -6,6 +6,13 @@ export class NitroConfiguration
|
||||
private static _config: any = {};
|
||||
private static _missingKeys: string[] = [];
|
||||
|
||||
public static resetConfiguration(): void
|
||||
{
|
||||
this._definitions.clear();
|
||||
this._config = {};
|
||||
this._missingKeys = [];
|
||||
}
|
||||
|
||||
public static parseConfiguration(data: { [index: string]: any }, overrides: boolean = false): boolean
|
||||
{
|
||||
if(!data) return false;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { INitroManager } from '../../common';
|
||||
|
||||
export interface INitroLocalizationManager extends INitroManager
|
||||
export interface ILocalizationManager
|
||||
{
|
||||
init(): Promise<void>;
|
||||
getRomanNumeral(number: number): string;
|
||||
getPreviousLevelBadgeId(badgeName: string): string;
|
||||
hasValue(key: string): boolean;
|
@ -1 +1 @@
|
||||
export * from './INitroLocalizationManager';
|
||||
export * from './ILocalizationManager';
|
||||
|
@ -3,14 +3,11 @@ import { IPetColorResult, IRoomContentListener } from '.';
|
||||
import { IGraphicAssetCollection, IGraphicAssetGifCollection } from '../../asset';
|
||||
import { IEventDispatcher } from '../../common';
|
||||
import { IRoomObject } from '../../room';
|
||||
import { ISessionDataManager } from '../session';
|
||||
|
||||
export interface IRoomContentLoader
|
||||
{
|
||||
dispose: () => void;
|
||||
initialize(events: IEventDispatcher): void;
|
||||
setSessionDataManager(sessionData: ISessionDataManager): void;
|
||||
downloadAsset(type: string, events: IEventDispatcher): void;
|
||||
init(): Promise<void>;
|
||||
downloadAsset(type: string): Promise<void>;
|
||||
isLoaderType(type: string): boolean;
|
||||
getCollection(name: string): IGraphicAssetCollection;
|
||||
getPlaceholderName(type: string): string;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { RenderTexture } from '@pixi/core';
|
||||
import { DisplayObject } from '@pixi/display';
|
||||
import { Point, Rectangle } from '@pixi/math';
|
||||
import { INitroManager } from '../../common';
|
||||
import { IRoomGeometry, IRoomManager, IRoomObject, IRoomObjectController, IRoomObjectLogicFactory, IRoomObjectVisualizationFactory, IRoomRendererFactory, IRoomRenderingCanvas, IVector3D } from '../../room';
|
||||
import { IPetCustomPart } from '../avatar';
|
||||
import { IRoomSessionManager, ISessionDataManager } from '../session';
|
||||
@ -12,10 +11,10 @@ import { IRoomContentLoader } from './IRoomContentLoader';
|
||||
import { IRoomObjectEventManager } from './IRoomObjectEventManager';
|
||||
import { IObjectData, IRoomMapData } from './object';
|
||||
|
||||
export interface IRoomEngine extends INitroManager
|
||||
export interface IRoomEngine
|
||||
{
|
||||
init(): Promise<void>;
|
||||
setActiveRoomId(roomId: number): void;
|
||||
onRoomEngineInitalized(flag: boolean): void;
|
||||
disableUpdate(flag: boolean): void;
|
||||
runUpdate(): void;
|
||||
createRoomInstance(roomId: number, roomMap: IRoomMapData): void;
|
||||
@ -96,7 +95,6 @@ export interface IRoomEngine extends INitroManager
|
||||
logicFactory: IRoomObjectLogicFactory;
|
||||
roomContentLoader: IRoomContentLoader;
|
||||
activeRoomId: number;
|
||||
ready: boolean;
|
||||
disposed: boolean;
|
||||
selectedAvatarId: number;
|
||||
isDecorating: boolean;
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { IEventDispatcher } from '../../common';
|
||||
import { IConnection } from '../../communication';
|
||||
import { IRoomInstance, IRoomObjectController, IRoomRenderingCanvas, IVector3D } from '../../room';
|
||||
import { IConnection } from '../communication';
|
||||
import { IRoomSessionManager, ISessionDataManager } from '../session';
|
||||
import { ISelectedRoomObjectData } from './ISelectedRoomObjectData';
|
||||
import { IObjectData } from './object';
|
||||
@ -42,6 +41,5 @@ export interface IRoomEngineServices
|
||||
sessionDataManager: ISessionDataManager;
|
||||
roomSessionManager: IRoomSessionManager;
|
||||
activeRoomId: number;
|
||||
events: IEventDispatcher;
|
||||
isDecorating: boolean;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IMessageDataWrapper } from '../../../../communication';
|
||||
import { IRoomObjectModel } from '../../../../room';
|
||||
import { IMessageDataWrapper } from '../../../communication';
|
||||
|
||||
export interface IObjectData
|
||||
{
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { IEventDispatcher } from '../../common';
|
||||
import { IRoomSession } from './IRoomSession';
|
||||
|
||||
export interface IRoomHandlerListener
|
||||
@ -6,5 +5,4 @@ export interface IRoomHandlerListener
|
||||
getSession(id: number): IRoomSession;
|
||||
sessionUpdate(id: number, type: string): void;
|
||||
sessionReinitialize(fromRoomId: number, toRoomId: number): void;
|
||||
events: IEventDispatcher;
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { INitroManager } from '../../common';
|
||||
import { INitroCommunicationManager } from '../communication';
|
||||
import { ICommunicationManager } from '../communication';
|
||||
import { IRoomSession } from './IRoomSession';
|
||||
|
||||
export interface IRoomSessionManager extends INitroManager
|
||||
export interface IRoomSessionManager
|
||||
{
|
||||
init(): Promise<void>;
|
||||
getSession(id: number): IRoomSession;
|
||||
createSession(roomId: number, password?: string): boolean;
|
||||
startSession(session: IRoomSession): boolean;
|
||||
removeSession(id: number, openLandingView?: boolean): void;
|
||||
communication: INitroCommunicationManager;
|
||||
communication: ICommunicationManager;
|
||||
viewerSession: IRoomSession;
|
||||
}
|
||||
|
@ -1,16 +1,14 @@
|
||||
import { Resource, Texture } from '@pixi/core';
|
||||
import { INitroManager } from '../../common';
|
||||
import { INitroCommunicationManager } from '../communication';
|
||||
import { ICommunicationManager } from '../communication';
|
||||
import { IFurnitureData } from './IFurnitureData';
|
||||
import { IFurnitureDataListener } from './IFurnitureDataListener';
|
||||
import { IGroupInformationManager } from './IGroupInformationManager';
|
||||
import { IIgnoredUsersManager } from './IIgnoredUsersManager';
|
||||
import { IProductData } from './IProductData';
|
||||
|
||||
export interface ISessionDataManager extends INitroManager
|
||||
export interface ISessionDataManager
|
||||
{
|
||||
getAllFurnitureData(listener: IFurnitureDataListener): IFurnitureData[];
|
||||
removePendingFurniDataListener(listener: IFurnitureDataListener): void;
|
||||
init(): Promise<void>;
|
||||
getAllFurnitureData(): IFurnitureData[];
|
||||
getFloorItemData(id: number): IFurnitureData;
|
||||
getFloorItemDataByName(name: string): IFurnitureData;
|
||||
getWallItemData(id: number): IFurnitureData;
|
||||
@ -31,7 +29,7 @@ export interface ISessionDataManager extends INitroManager
|
||||
unignoreUser(name: string): void;
|
||||
isUserIgnored(name: string): boolean;
|
||||
getGroupBadge(groupId: number): string;
|
||||
communication: INitroCommunicationManager;
|
||||
communication: ICommunicationManager;
|
||||
userId: number;
|
||||
userName: string;
|
||||
figure: string;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { INitroManager } from '../../common';
|
||||
import { IMusicController } from './IMusicController';
|
||||
|
||||
export interface ISoundManager extends INitroManager
|
||||
export interface ISoundManager
|
||||
{
|
||||
get musicController(): IMusicController;
|
||||
get traxVolume(): number;
|
||||
init(): Promise<void>;
|
||||
musicController: IMusicController;
|
||||
traxVolume: number;
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
import { IEventDispatcher, INitroManager } from '../common';
|
||||
import { IRoomContentLoader } from '../nitro';
|
||||
import { IRoomInstance } from './IRoomInstance';
|
||||
import { IRoomObject } from './object';
|
||||
|
||||
export interface IRoomManager extends INitroManager
|
||||
export interface IRoomManager
|
||||
{
|
||||
init(): Promise<void>;
|
||||
getRoomInstance(roomId: string): IRoomInstance;
|
||||
createRoomInstance(roomId: string): IRoomInstance;
|
||||
removeRoomInstance(roomId: string): boolean;
|
||||
addUpdateCategory(category: number): void;
|
||||
removeUpdateCategory(category: number): void;
|
||||
createRoomObjectAndInitalize(roomId: string, objectId: number, type: string, category: number): IRoomObject;
|
||||
setContentLoader(loader: IRoomContentLoader): void;
|
||||
update(time: number, update?: boolean): void;
|
||||
rooms: Map<string, IRoomInstance>;
|
||||
events: IEventDispatcher;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
export interface IRoomManagerListener
|
||||
{
|
||||
onRoomEngineInitalized(flag: boolean): void;
|
||||
objectInitialized(roomId: string, objectId: number, category: number): void;
|
||||
initalizeTemporaryObjectsByType(type: string, _arg_2: boolean): void;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { RoomObjectEvent } from '../../../../events';
|
||||
import { IEventDispatcher } from '../../../common';
|
||||
import { IRoomObjectEventHandler } from './IRoomObjectEventHandler';
|
||||
|
||||
export interface IRoomObjectLogicFactory
|
||||
{
|
||||
getLogic(type: string): IRoomObjectEventHandler;
|
||||
registerEventFunction(func: Function): void;
|
||||
removeEventFunction(func: Function): void;
|
||||
registerEventFunction(func: (event: RoomObjectEvent) => void): void;
|
||||
removeEventFunction(func: (event: RoomObjectEvent) => void): void;
|
||||
events: IEventDispatcher;
|
||||
}
|
||||
|
@ -1,25 +1,15 @@
|
||||
import { IDisposable, IEventDispatcher, INitroEvent, NitroLogger } from '../api';
|
||||
import { Disposable } from './Disposable';
|
||||
import { IEventDispatcher, INitroEvent, NitroLogger } from '../api';
|
||||
|
||||
export class EventDispatcher extends Disposable implements IEventDispatcher, IDisposable
|
||||
export class EventDispatcher implements IEventDispatcher
|
||||
{
|
||||
private _listeners: Map<string, Function[]>;
|
||||
private _listeners: Map<string, Function[]> = new Map();
|
||||
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
|
||||
this._listeners = new Map();
|
||||
}
|
||||
|
||||
protected onDispose(): void
|
||||
public dispose(): void
|
||||
{
|
||||
this.removeAllListeners();
|
||||
|
||||
super.onDispose();
|
||||
}
|
||||
|
||||
public addEventListener(type: string, callback: Function): void
|
||||
public addEventListener<T extends INitroEvent>(type: string, callback: (event: T) => void): void
|
||||
{
|
||||
if(!type || !callback) return;
|
||||
|
||||
@ -35,7 +25,7 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
||||
existing.push(callback);
|
||||
}
|
||||
|
||||
public removeEventListener(type: string, callback: any): void
|
||||
public removeEventListener(type: string, callback: Function): void
|
||||
{
|
||||
if(!type || !callback) return;
|
||||
|
||||
@ -55,7 +45,7 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
||||
}
|
||||
}
|
||||
|
||||
public dispatchEvent(event: INitroEvent): boolean
|
||||
public dispatchEvent<T extends INitroEvent>(event: T): boolean
|
||||
{
|
||||
if(!event) return false;
|
||||
|
||||
@ -66,7 +56,7 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
||||
return true;
|
||||
}
|
||||
|
||||
private processEvent(event: INitroEvent): void
|
||||
private processEvent<T extends INitroEvent>(event: T): void
|
||||
{
|
||||
const existing = this._listeners.get(event.type);
|
||||
|
||||
|
4
src/events/NitroEventDispatcher.ts
Normal file
4
src/events/NitroEventDispatcher.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { IEventDispatcher } from '../api';
|
||||
import { EventDispatcher } from '../common';
|
||||
|
||||
export const NitroEventDispatcher: IEventDispatcher = new EventDispatcher();
|
16
src/events/NitroEventType.ts
Normal file
16
src/events/NitroEventType.ts
Normal file
@ -0,0 +1,16 @@
|
||||
export class NitroEventType
|
||||
{
|
||||
public static readonly CONFIG_LOADED = 'CONFIG_LOADED';
|
||||
public static readonly CONFIG_FAILED = 'CONFIG_FAILED';
|
||||
public static readonly LOCALIZATION_LOADED = 'LOCALIZATION_LOADED';
|
||||
public static readonly LOCALIZATION_FAILED = 'LOCALIZATION_FAILED';
|
||||
public static readonly SOCKET_OPENED = 'SOCKET_OPENED';
|
||||
public static readonly SOCKET_CLOSED = 'SOCKET_CLOSED';
|
||||
public static readonly SOCKET_ERROR = 'SOCKET_ERROR';
|
||||
public static readonly SOCKET_CONNECTED = 'SOCKET_CONNECTED';
|
||||
public static readonly AVATAR_ASSET_DOWNLOADED = 'AVATAR_ASSET_DOWNLOADED';
|
||||
public static readonly AVATAR_ASSET_LOADED = 'AVATAR_ASSET_LOADED';
|
||||
public static readonly AVATAR_EFFECT_DOWNLOADED = 'AVATAR_EFFECT_DOWNLOADED';
|
||||
public static readonly AVATAR_EFFECT_LOADED = 'AVATAR_EFFECT_LOADED';
|
||||
public static readonly FURNITURE_DATA_LOADED = 'FURNITURE_DATA_LOADED';
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
export class AvatarRenderEvent
|
||||
{
|
||||
public static AVATAR_RENDER_READY: string = 'AVATAR_RENDER_READY';
|
||||
}
|
@ -1,3 +1,2 @@
|
||||
export * from './AvatarRenderEffectLibraryEvent';
|
||||
export * from './AvatarRenderEvent';
|
||||
export * from './AvatarRenderLibraryEvent';
|
||||
|
@ -1,11 +1,12 @@
|
||||
export * from './avatar';
|
||||
export * from './camera';
|
||||
export * from './communication';
|
||||
export * from './core';
|
||||
export * from './localization';
|
||||
export * from './NitroEventDispatcher';
|
||||
export * from './NitroEventType';
|
||||
export * from './NitroSettingsEvent';
|
||||
export * from './NitroSoundEvent';
|
||||
export * from './NitroToolbarAnimateIconEvent';
|
||||
export * from './NitroToolbarEvent';
|
||||
export * from './avatar';
|
||||
export * from './camera';
|
||||
export * from './communication';
|
||||
export * from './core';
|
||||
export * from './room';
|
||||
export * from './session';
|
||||
|
@ -1,12 +0,0 @@
|
||||
import { NitroEvent } from '../core';
|
||||
|
||||
export class NitroLocalizationEvent extends NitroEvent
|
||||
{
|
||||
public static LOADED: string = 'NLE_LOADED';
|
||||
public static FAILED: string = 'NLE_FAILED';
|
||||
|
||||
constructor(type: string)
|
||||
{
|
||||
super(type);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './NitroLocalizationEvent';
|
@ -1,10 +1,9 @@
|
||||
import { Application } from '@pixi/app';
|
||||
import { IAvatarRenderManager, IConfigurationManager, IEventDispatcher, ILinkEventTracker, INitroCommunicationManager, INitroLocalizationManager, IRoomCameraWidgetManager, IRoomEngine, IRoomManager, IRoomSessionManager, ISessionDataManager, ISoundManager } from '../api';
|
||||
import { IAvatarRenderManager, ICommunicationManager, IConfigurationManager, IEventDispatcher, ILinkEventTracker, ILocalizationManager, IRoomCameraWidgetManager, IRoomEngine, ISessionDataManager, ISoundManager } from '../api';
|
||||
|
||||
export interface INitro
|
||||
{
|
||||
init(): void;
|
||||
dispose(): void;
|
||||
init(): Promise<void>;
|
||||
getConfiguration<T>(key: string, value?: T): T;
|
||||
getLocalization(key: string): string;
|
||||
getLocalizationWithParameter(key: string, parameter: string, replacement: string): string;
|
||||
@ -15,17 +14,13 @@ export interface INitro
|
||||
application: Application;
|
||||
configuration: IConfigurationManager;
|
||||
events: IEventDispatcher;
|
||||
localization: INitroLocalizationManager;
|
||||
communication: INitroCommunicationManager;
|
||||
localization: ILocalizationManager;
|
||||
communication: ICommunicationManager;
|
||||
avatar: IAvatarRenderManager;
|
||||
roomEngine: IRoomEngine;
|
||||
sessionDataManager: ISessionDataManager;
|
||||
roomSessionManager: IRoomSessionManager;
|
||||
roomManager: IRoomManager;
|
||||
cameraManager: IRoomCameraWidgetManager;
|
||||
soundManager: ISoundManager;
|
||||
width: number;
|
||||
height: number;
|
||||
isReady: boolean;
|
||||
isDisposed: boolean;
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
import { Application, IApplicationOptions } from '@pixi/app';
|
||||
import { SCALE_MODES } from '@pixi/constants';
|
||||
import { settings } from '@pixi/settings';
|
||||
import { IAvatarRenderManager, IConfigurationManager, IEventDispatcher, ILinkEventTracker, INitroCommunicationManager, INitroLocalizationManager, IRoomCameraWidgetManager, IRoomEngine, IRoomManager, IRoomSessionManager, ISessionDataManager, ISoundManager, NitroConfiguration, NitroLogger } from '../api';
|
||||
import { AssetManager, IAvatarRenderManager, ICommunicationManager, IConfigurationManager, IEventDispatcher, ILinkEventTracker, ILocalizationManager, IRoomCameraWidgetManager, IRoomEngine, ISessionDataManager, ISoundManager, NitroConfiguration, NitroLogger } from '../api';
|
||||
import { EventDispatcher } from '../common';
|
||||
import { ConfigurationEvent, NitroEvent, RoomEngineEvent } from '../events';
|
||||
import { GetTicker, PixiApplicationProxy } from '../pixi-proxy';
|
||||
import { RoomManager } from '../room';
|
||||
import { INitro } from './INitro';
|
||||
import { NitroVersion } from './NitroVersion';
|
||||
import './Plugins';
|
||||
import { AvatarRenderManager } from './avatar';
|
||||
import { RoomCameraWidgetManager } from './camera';
|
||||
import { NitroCommunicationManager } from './communication';
|
||||
import { CommunicationManager } from './communication';
|
||||
import { ConfigurationManager } from './configuration';
|
||||
import { LegacyExternalInterface } from './externalInterface';
|
||||
import { GameMessageHandler } from './game';
|
||||
import { NitroLocalizationManager } from './localization';
|
||||
import { LocalizationManager } from './localization';
|
||||
import { LandscapeRasterizer, RoomEngine } from './room';
|
||||
import { RoomSessionManager, SessionDataManager } from './session';
|
||||
import { SessionDataManager } from './session';
|
||||
import { SoundManager } from './sound';
|
||||
import { HabboWebTools } from './utils/HabboWebTools';
|
||||
|
||||
@ -36,166 +34,74 @@ export class Nitro implements INitro
|
||||
private static INSTANCE: INitro = null;
|
||||
|
||||
private _application: Application;
|
||||
private _configuration: IConfigurationManager;
|
||||
private _events: IEventDispatcher;
|
||||
private _communication: INitroCommunicationManager;
|
||||
private _localization: INitroLocalizationManager;
|
||||
private _avatar: IAvatarRenderManager;
|
||||
private _roomEngine: IRoomEngine;
|
||||
private _sessionDataManager: ISessionDataManager;
|
||||
private _roomSessionManager: IRoomSessionManager;
|
||||
private _roomManager: IRoomManager;
|
||||
private _cameraManager: IRoomCameraWidgetManager;
|
||||
private _soundManager: ISoundManager;
|
||||
private _linkTrackers: ILinkEventTracker[];
|
||||
|
||||
private _isReady: boolean;
|
||||
private _isDisposed: boolean;
|
||||
private _configuration: IConfigurationManager = new ConfigurationManager();
|
||||
private _events: IEventDispatcher = new EventDispatcher();
|
||||
private _communication: ICommunicationManager = new CommunicationManager();
|
||||
private _localization: ILocalizationManager = new LocalizationManager(this._communication);
|
||||
private _avatar: IAvatarRenderManager = new AvatarRenderManager();
|
||||
private _sessionDataManager: ISessionDataManager = new SessionDataManager(this._communication);
|
||||
private _roomEngine: IRoomEngine = new RoomEngine(this._communication, this._sessionDataManager);
|
||||
private _cameraManager: IRoomCameraWidgetManager = new RoomCameraWidgetManager();
|
||||
private _soundManager: ISoundManager = new SoundManager();
|
||||
private _linkTrackers: ILinkEventTracker[] = [];
|
||||
|
||||
constructor(options?: IApplicationOptions)
|
||||
{
|
||||
if(!Nitro.INSTANCE) Nitro.INSTANCE = this;
|
||||
|
||||
this._application = new PixiApplicationProxy(options);
|
||||
this._configuration = new ConfigurationManager();
|
||||
this._events = new EventDispatcher();
|
||||
this._communication = new NitroCommunicationManager();
|
||||
this._localization = new NitroLocalizationManager(this._communication);
|
||||
this._avatar = new AvatarRenderManager();
|
||||
this._roomEngine = new RoomEngine(this._communication);
|
||||
this._sessionDataManager = new SessionDataManager(this._communication);
|
||||
this._roomSessionManager = new RoomSessionManager(this._communication, this._roomEngine);
|
||||
this._roomManager = new RoomManager(this._roomEngine, this._roomEngine.visualizationFactory, this._roomEngine.logicFactory);
|
||||
this._cameraManager = new RoomCameraWidgetManager();
|
||||
this._soundManager = new SoundManager();
|
||||
this._linkTrackers = [];
|
||||
|
||||
this._isReady = false;
|
||||
this._isDisposed = false;
|
||||
|
||||
this._configuration.events.addEventListener(ConfigurationEvent.LOADED, this.onConfigurationLoadedEvent.bind(this));
|
||||
this._roomEngine.events.addEventListener(RoomEngineEvent.ENGINE_INITIALIZED, this.onRoomEngineReady.bind(this));
|
||||
}
|
||||
|
||||
public static bootstrap(): void
|
||||
{
|
||||
NitroVersion.sayHello();
|
||||
|
||||
if(Nitro.INSTANCE)
|
||||
{
|
||||
Nitro.INSTANCE.dispose();
|
||||
|
||||
Nitro.INSTANCE = null;
|
||||
}
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
|
||||
const instance = new this({
|
||||
new this({
|
||||
autoDensity: false,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
resolution: window.devicePixelRatio,
|
||||
view: canvas
|
||||
});
|
||||
|
||||
canvas.addEventListener('webglcontextlost', () => instance.events.dispatchEvent(new NitroEvent(Nitro.WEBGL_CONTEXT_LOST)));
|
||||
}
|
||||
|
||||
public init(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
if(this._isReady || this._isDisposed) return;
|
||||
|
||||
if(this._avatar) this._avatar.init();
|
||||
|
||||
if(this._soundManager) this._soundManager.init();
|
||||
|
||||
if(this._roomEngine)
|
||||
try
|
||||
{
|
||||
this._roomEngine.sessionDataManager = this._sessionDataManager;
|
||||
this._roomEngine.roomSessionManager = this._roomSessionManager;
|
||||
this._roomEngine.roomManager = this._roomManager;
|
||||
await this._configuration.init();
|
||||
|
||||
if(this._sessionDataManager) this._sessionDataManager.init();
|
||||
if(this._roomSessionManager) this._roomSessionManager.init();
|
||||
this.setDefaultConfiguration();
|
||||
|
||||
this._roomEngine.init();
|
||||
await Promise.all([
|
||||
this._localization.init(),
|
||||
AssetManager._INSTANCE.downloadAssets(NitroConfiguration.getValue<string[]>('preload.assets.urls')?.map(url => NitroConfiguration.interpolate(url))),
|
||||
this._communication.init(),
|
||||
this._avatar.init(),
|
||||
this._soundManager.init(),
|
||||
this._sessionDataManager.init()
|
||||
]);
|
||||
|
||||
await this._roomEngine.init();
|
||||
|
||||
new GameMessageHandler(this._communication.connection);
|
||||
|
||||
if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'authentication', 'authok', []);
|
||||
|
||||
HabboWebTools.sendHeartBeat();
|
||||
|
||||
setInterval(() => HabboWebTools.sendHeartBeat(), 10000);
|
||||
}
|
||||
|
||||
if(!this._communication.connection)
|
||||
catch (err)
|
||||
{
|
||||
throw new Error('No connection found');
|
||||
throw new Error(err);
|
||||
}
|
||||
|
||||
new GameMessageHandler(this._communication.connection);
|
||||
|
||||
this._isReady = true;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
if(this._isDisposed) return;
|
||||
|
||||
if(this._roomManager)
|
||||
{
|
||||
this._roomManager.dispose();
|
||||
|
||||
this._roomManager = null;
|
||||
}
|
||||
|
||||
if(this._roomSessionManager)
|
||||
{
|
||||
this._roomSessionManager.dispose();
|
||||
|
||||
this._roomSessionManager = null;
|
||||
}
|
||||
|
||||
if(this._sessionDataManager)
|
||||
{
|
||||
this._sessionDataManager.dispose();
|
||||
|
||||
this._sessionDataManager = null;
|
||||
}
|
||||
|
||||
if(this._roomEngine)
|
||||
{
|
||||
this._roomEngine.dispose();
|
||||
|
||||
this._roomEngine = null;
|
||||
}
|
||||
|
||||
if(this._avatar)
|
||||
{
|
||||
this._avatar.dispose();
|
||||
|
||||
this._avatar = null;
|
||||
}
|
||||
|
||||
if(this._soundManager)
|
||||
{
|
||||
this._soundManager.dispose();
|
||||
|
||||
this._soundManager = null;
|
||||
}
|
||||
|
||||
if(this._communication)
|
||||
{
|
||||
this._communication.dispose();
|
||||
|
||||
this._communication = null;
|
||||
}
|
||||
|
||||
if(this._application)
|
||||
{
|
||||
this._application.destroy();
|
||||
|
||||
this._application = null;
|
||||
}
|
||||
|
||||
this._isDisposed = true;
|
||||
this._isReady = false;
|
||||
}
|
||||
|
||||
private onConfigurationLoadedEvent(event: ConfigurationEvent): void
|
||||
private setDefaultConfiguration(): void
|
||||
{
|
||||
GetTicker().maxFPS = NitroConfiguration.getValue<number>('system.fps.max', 24);
|
||||
|
||||
@ -208,11 +114,6 @@ export class Nitro implements INitro
|
||||
LandscapeRasterizer.LANDSCAPES_ENABLED = NitroConfiguration.getValue<boolean>('room.landscapes.enabled', true);
|
||||
}
|
||||
|
||||
private onRoomEngineReady(event: RoomEngineEvent): void
|
||||
{
|
||||
this.startSendingHeartBeat();
|
||||
}
|
||||
|
||||
public getConfiguration<T>(key: string, value: T = null): T
|
||||
{
|
||||
return NitroConfiguration.getValue<T>(key, value);
|
||||
@ -270,18 +171,6 @@ export class Nitro implements INitro
|
||||
}
|
||||
}
|
||||
|
||||
private startSendingHeartBeat(): void
|
||||
{
|
||||
this.sendHeartBeat();
|
||||
|
||||
setInterval(this.sendHeartBeat, 10000);
|
||||
}
|
||||
|
||||
private sendHeartBeat(): void
|
||||
{
|
||||
HabboWebTools.sendHeartBeat();
|
||||
}
|
||||
|
||||
public get application(): Application
|
||||
{
|
||||
return this._application;
|
||||
@ -297,12 +186,12 @@ export class Nitro implements INitro
|
||||
return this._events;
|
||||
}
|
||||
|
||||
public get localization(): INitroLocalizationManager
|
||||
public get localization(): ILocalizationManager
|
||||
{
|
||||
return this._localization;
|
||||
}
|
||||
|
||||
public get communication(): INitroCommunicationManager
|
||||
public get communication(): ICommunicationManager
|
||||
{
|
||||
return this._communication;
|
||||
}
|
||||
@ -322,16 +211,6 @@ export class Nitro implements INitro
|
||||
return this._sessionDataManager;
|
||||
}
|
||||
|
||||
public get roomSessionManager(): IRoomSessionManager
|
||||
{
|
||||
return this._roomSessionManager;
|
||||
}
|
||||
|
||||
public get roomManager(): IRoomManager
|
||||
{
|
||||
return this._roomManager;
|
||||
}
|
||||
|
||||
public get cameraManager(): IRoomCameraWidgetManager
|
||||
{
|
||||
return this._cameraManager;
|
||||
@ -352,16 +231,6 @@ export class Nitro implements INitro
|
||||
return this._application.renderer.height;
|
||||
}
|
||||
|
||||
public get isReady(): boolean
|
||||
{
|
||||
return this._isReady;
|
||||
}
|
||||
|
||||
public get isDisposed(): boolean
|
||||
{
|
||||
return this._isDisposed;
|
||||
}
|
||||
|
||||
public static get instance(): INitro
|
||||
{
|
||||
return this.INSTANCE || null;
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { IAssetManager, IAvatarAssetDownloadLibrary } from '../../api';
|
||||
import { EventDispatcher } from '../../common';
|
||||
import { AvatarRenderLibraryEvent } from '../../events';
|
||||
import { AvatarRenderLibraryEvent, NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
|
||||
export class AvatarAssetDownloadLibrary extends EventDispatcher implements IAvatarAssetDownloadLibrary
|
||||
export class AvatarAssetDownloadLibrary implements IAvatarAssetDownloadLibrary
|
||||
{
|
||||
public static DOWNLOAD_COMPLETE: string = 'AADL_DOWNLOAD_COMPLETE';
|
||||
|
||||
@ -10,54 +9,50 @@ export class AvatarAssetDownloadLibrary extends EventDispatcher implements IAvat
|
||||
private static LOADING: number = 1;
|
||||
private static LOADED: number = 2;
|
||||
|
||||
private _state: number;
|
||||
private _state: number = AvatarAssetDownloadLibrary.NOT_LOADED;
|
||||
private _libraryName: string;
|
||||
private _revision: string;
|
||||
private _downloadUrl: string;
|
||||
private _assets: IAssetManager;
|
||||
private _assetManager: IAssetManager;
|
||||
|
||||
constructor(id: string, revision: string, assets: IAssetManager, assetUrl: string)
|
||||
constructor(libraryName: string, revision: string, downloadUrl: string, assetManager: IAssetManager)
|
||||
{
|
||||
super();
|
||||
|
||||
this._state = AvatarAssetDownloadLibrary.NOT_LOADED;
|
||||
this._libraryName = id;
|
||||
this._libraryName = libraryName;
|
||||
this._revision = revision;
|
||||
this._downloadUrl = assetUrl;
|
||||
this._assets = assets;
|
||||
this._downloadUrl = downloadUrl;
|
||||
this._assetManager = assetManager;
|
||||
|
||||
this._downloadUrl = this._downloadUrl.replace(/%libname%/gi, this._libraryName);
|
||||
this._downloadUrl = this._downloadUrl.replace(/%revision%/gi, this._revision);
|
||||
|
||||
const asset = this._assets.getCollection(this._libraryName);
|
||||
|
||||
if(asset) this._state = AvatarAssetDownloadLibrary.LOADED;
|
||||
this.checkIsLoaded();
|
||||
}
|
||||
|
||||
public async downloadAsset(): Promise<void>
|
||||
{
|
||||
if(!this._assets || (this._state === AvatarAssetDownloadLibrary.LOADING) || (this._state === AvatarAssetDownloadLibrary.LOADED)) return;
|
||||
if(!this._assetManager || (this._state === AvatarAssetDownloadLibrary.LOADING) || (this._state === AvatarAssetDownloadLibrary.LOADED)) return;
|
||||
|
||||
const asset = this._assets.getCollection(this._libraryName);
|
||||
|
||||
if(asset)
|
||||
if(!this.checkIsLoaded())
|
||||
{
|
||||
this._state = AvatarAssetDownloadLibrary.LOADED;
|
||||
this._state = AvatarAssetDownloadLibrary.LOADING;
|
||||
|
||||
this.dispatchEvent(new AvatarRenderLibraryEvent(AvatarRenderLibraryEvent.DOWNLOAD_COMPLETE, this));
|
||||
const status = await this._assetManager.downloadAsset(this._downloadUrl);
|
||||
|
||||
return;
|
||||
if(!status) throw new Error('Could not download asset');
|
||||
}
|
||||
|
||||
this._state = AvatarAssetDownloadLibrary.LOADING;
|
||||
if(this.checkIsLoaded()) NitroEventDispatcher.dispatchEvent(new AvatarRenderLibraryEvent(NitroEventType.AVATAR_ASSET_DOWNLOADED, this));
|
||||
}
|
||||
|
||||
const status = await this._assets.downloadAsset(this._downloadUrl);
|
||||
private checkIsLoaded(): boolean
|
||||
{
|
||||
const asset = this._assetManager.getCollection(this._libraryName);
|
||||
|
||||
if(!status) return;
|
||||
if(!asset) return false;
|
||||
|
||||
this._state = AvatarAssetDownloadLibrary.LOADED;
|
||||
|
||||
this.dispatchEvent(new AvatarRenderLibraryEvent(AvatarRenderLibraryEvent.DOWNLOAD_COMPLETE, this));
|
||||
return true;
|
||||
}
|
||||
|
||||
public get libraryName(): string
|
||||
|
@ -1,110 +1,65 @@
|
||||
import { IAssetManager, IAvatarFigureContainer, IAvatarImageListener, INitroEvent, NitroConfiguration, NitroLogger } from '../../api';
|
||||
import { EventDispatcher } from '../../common';
|
||||
import { AvatarRenderEvent, AvatarRenderLibraryEvent, NitroEvent } from '../../events';
|
||||
import { IAssetManager, IAvatarFigureContainer, IAvatarImageListener, NitroConfiguration } from '../../api';
|
||||
import { AvatarRenderLibraryEvent, NitroEvent, NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
import { AvatarAssetDownloadLibrary } from './AvatarAssetDownloadLibrary';
|
||||
import { AvatarStructure } from './AvatarStructure';
|
||||
|
||||
export class AvatarAssetDownloadManager extends EventDispatcher
|
||||
export class AvatarAssetDownloadManager
|
||||
{
|
||||
public static DOWNLOADER_READY: string = 'AADM_DOWNLOADER_READY';
|
||||
public static LIBRARY_LOADED: string = 'AADM_LIBRARY_LOADED';
|
||||
|
||||
private static MAX_DOWNLOADS: number = 2;
|
||||
|
||||
private _assets: IAssetManager;
|
||||
private _structure: AvatarStructure;
|
||||
|
||||
private _missingMandatoryLibs: string[];
|
||||
private _figureMap: Map<string, AvatarAssetDownloadLibrary[]>;
|
||||
private _pendingContainers: [IAvatarFigureContainer, IAvatarImageListener][];
|
||||
private _figureListeners: Map<string, IAvatarImageListener[]>;
|
||||
private _incompleteFigures: Map<string, AvatarAssetDownloadLibrary[]>;
|
||||
private _pendingDownloadQueue: AvatarAssetDownloadLibrary[];
|
||||
private _currentDownloads: AvatarAssetDownloadLibrary[];
|
||||
private _libraryNames: string[];
|
||||
private _isReady: boolean;
|
||||
private _missingMandatoryLibs: string[] = [];
|
||||
private _figureMap: Map<string, AvatarAssetDownloadLibrary[]> = new Map();
|
||||
private _figureListeners: Map<string, IAvatarImageListener[]> = new Map();
|
||||
private _incompleteFigures: Map<string, AvatarAssetDownloadLibrary[]> = new Map();
|
||||
private _currentDownloads: AvatarAssetDownloadLibrary[] = [];
|
||||
private _libraryNames: string[] = [];
|
||||
|
||||
constructor(assets: IAssetManager, structure: AvatarStructure)
|
||||
{
|
||||
super();
|
||||
|
||||
this._assets = assets;
|
||||
this._structure = structure;
|
||||
|
||||
this._missingMandatoryLibs = NitroConfiguration.getValue<string[]>('avatar.mandatory.libraries');
|
||||
this._figureMap = new Map();
|
||||
this._pendingContainers = [];
|
||||
this._figureListeners = new Map();
|
||||
this._incompleteFigures = new Map();
|
||||
this._pendingDownloadQueue = [];
|
||||
this._currentDownloads = [];
|
||||
this._libraryNames = [];
|
||||
this._isReady = false;
|
||||
|
||||
this.onLibraryLoaded = this.onLibraryLoaded.bind(this);
|
||||
this.onAvatarRenderReady = this.onAvatarRenderReady.bind(this);
|
||||
|
||||
this.loadFigureMap();
|
||||
|
||||
this._structure.renderManager.events.addEventListener(AvatarRenderEvent.AVATAR_RENDER_READY, this.onAvatarRenderReady);
|
||||
}
|
||||
|
||||
private loadFigureMap(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
const request = new XMLHttpRequest();
|
||||
this._missingMandatoryLibs = NitroConfiguration.getValue<string[]>('avatar.mandatory.libraries');
|
||||
|
||||
try
|
||||
{
|
||||
request.open('GET', NitroConfiguration.getValue<string>('avatar.figuremap.url'));
|
||||
const url = NitroConfiguration.getValue<string>('avatar.figuremap.url');
|
||||
|
||||
request.send();
|
||||
if(!url || !url.length) throw new Error('Invalid figure map url');
|
||||
|
||||
request.onloadend = e =>
|
||||
{
|
||||
if(request.responseText)
|
||||
{
|
||||
const data = JSON.parse(request.responseText);
|
||||
const response = await fetch(url);
|
||||
|
||||
this.processFigureMap(data.libraries);
|
||||
if(response.status !== 200) throw new Error('Invalid figure map file');
|
||||
|
||||
this.processMissingLibraries();
|
||||
const responseData = await response.json();
|
||||
|
||||
this._isReady = true;
|
||||
this.processFigureMap(responseData.libraries);
|
||||
|
||||
this.dispatchEvent(new NitroEvent(AvatarAssetDownloadManager.DOWNLOADER_READY));
|
||||
}
|
||||
};
|
||||
NitroEventDispatcher.addEventListener(NitroEventType.AVATAR_ASSET_DOWNLOADED, (event: AvatarRenderLibraryEvent) => this.onLibraryLoaded(event));
|
||||
|
||||
request.onerror = e =>
|
||||
{
|
||||
throw new Error('invalid_avatar_figure_map');
|
||||
};
|
||||
}
|
||||
|
||||
catch (e)
|
||||
{
|
||||
NitroLogger.error(e);
|
||||
}
|
||||
await this.processMissingLibraries();
|
||||
}
|
||||
|
||||
private processFigureMap(data: any): void
|
||||
{
|
||||
if(!data) return;
|
||||
|
||||
const downloadUrl = NitroConfiguration.getValue<string>('avatar.asset.url');
|
||||
|
||||
for(const library of data)
|
||||
{
|
||||
if(!library) continue;
|
||||
|
||||
const id = (library.id as string);
|
||||
const libraryName = (library.id as string);
|
||||
const revision = (library.revision || '');
|
||||
|
||||
if(this._libraryNames.indexOf(id) >= 0) continue;
|
||||
if(this._libraryNames.indexOf(libraryName) >= 0) continue;
|
||||
|
||||
this._libraryNames.push(id);
|
||||
this._libraryNames.push(libraryName);
|
||||
|
||||
const downloadLibrary = new AvatarAssetDownloadLibrary(id, revision, this._assets, NitroConfiguration.getValue<string>('avatar.asset.url'));
|
||||
|
||||
downloadLibrary.addEventListener(AvatarRenderLibraryEvent.DOWNLOAD_COMPLETE, this.onLibraryLoaded);
|
||||
const downloadLibrary = new AvatarAssetDownloadLibrary(libraryName, revision, downloadUrl, this._assets);
|
||||
|
||||
for(const part of library.parts)
|
||||
{
|
||||
@ -123,16 +78,20 @@ export class AvatarAssetDownloadManager extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
private onAvatarRenderReady(event: INitroEvent): void
|
||||
private async processMissingLibraries(): Promise<void>
|
||||
{
|
||||
if(!event) return;
|
||||
const promises: Promise<void>[] = [];
|
||||
|
||||
for(const [container, listener] of this._pendingContainers)
|
||||
this._missingMandatoryLibs.forEach(value =>
|
||||
{
|
||||
this.downloadAvatarFigure(container, listener);
|
||||
}
|
||||
const libraries = this._figureMap.get(value);
|
||||
|
||||
this._pendingContainers = [];
|
||||
if(libraries) for(const library of libraries) promises.push(library.downloadAsset());
|
||||
});
|
||||
|
||||
this._missingMandatoryLibs = [];
|
||||
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
private onLibraryLoaded(event: AvatarRenderLibraryEvent): void
|
||||
@ -172,7 +131,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
|
||||
|
||||
this._figureListeners.delete(figure);
|
||||
|
||||
this.dispatchEvent(new NitroEvent(AvatarAssetDownloadManager.LIBRARY_LOADED));
|
||||
NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.AVATAR_ASSET_LOADED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,30 +157,9 @@ export class AvatarAssetDownloadManager extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public processMissingLibraries(): void
|
||||
{
|
||||
const libraries = this._missingMandatoryLibs.slice();
|
||||
|
||||
for(const library of libraries)
|
||||
{
|
||||
if(!library) continue;
|
||||
|
||||
const map = this._figureMap.get(library);
|
||||
|
||||
if(map) for(const avatar of map) avatar && this.downloadLibrary(avatar);
|
||||
}
|
||||
}
|
||||
|
||||
public isAvatarFigureContainerReady(container: IAvatarFigureContainer): boolean
|
||||
{
|
||||
if(!this._isReady || !this._structure.renderManager.isReady)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const pendingLibraries = this.getAvatarFigurePendingLibraries(container);
|
||||
|
||||
return !pendingLibraries.length;
|
||||
return !this.getAvatarFigurePendingLibraries(container).length;
|
||||
}
|
||||
|
||||
private getAvatarFigurePendingLibraries(container: IAvatarFigureContainer): AvatarAssetDownloadLibrary[]
|
||||
@ -271,13 +209,6 @@ export class AvatarAssetDownloadManager extends EventDispatcher
|
||||
|
||||
public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void
|
||||
{
|
||||
if(!this._isReady || !this._structure.renderManager.isReady)
|
||||
{
|
||||
this._pendingContainers.push([container, listener]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const figure = container.getFigureString();
|
||||
const pendingLibraries = this.getAvatarFigurePendingLibraries(container);
|
||||
|
||||
@ -303,7 +234,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
|
||||
{
|
||||
if(!library) continue;
|
||||
|
||||
this.downloadLibrary(library);
|
||||
library.downloadAsset();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -311,27 +242,4 @@ export class AvatarAssetDownloadManager extends EventDispatcher
|
||||
if(listener && !listener.disposed) listener.resetFigure(figure);
|
||||
}
|
||||
}
|
||||
|
||||
private downloadLibrary(library: AvatarAssetDownloadLibrary): void
|
||||
{
|
||||
if(!library || library.isLoaded) return;
|
||||
|
||||
if((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
|
||||
|
||||
this._pendingDownloadQueue.push(library);
|
||||
|
||||
this.processDownloadQueue();
|
||||
}
|
||||
|
||||
private processDownloadQueue(): void
|
||||
{
|
||||
while(this._pendingDownloadQueue.length)
|
||||
{
|
||||
const library = this._pendingDownloadQueue[0];
|
||||
|
||||
library.downloadAsset();
|
||||
|
||||
this._currentDownloads.push(this._pendingDownloadQueue.shift());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { AvatarSetType, GetAssetManager, IAssetManager, IAvatarEffectListener, IAvatarFigureContainer, IAvatarImage, IAvatarImageListener, IAvatarRenderManager, IFigureData, IFigurePartSet, IFigureSetData, IGraphicAsset, INitroEvent, IStructureData, NitroConfiguration, NitroLogger } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { AvatarRenderEvent, NitroEvent } from '../../events';
|
||||
import { AvatarSetType, GetAssetManager, IAssetManager, IAvatarEffectListener, IAvatarFigureContainer, IAvatarImage, IAvatarImageListener, IAvatarRenderManager, IFigureData, IFigurePartSet, IGraphicAsset, IStructureData, NitroConfiguration } from '../../api';
|
||||
import { NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
import { FigureDataContainer } from '../utils';
|
||||
import { AssetAliasCollection } from './alias';
|
||||
import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager';
|
||||
@ -12,241 +11,71 @@ import { HabboAvatarGeometry } from './data/HabboAvatarGeometry';
|
||||
import { HabboAvatarPartSets } from './data/HabboAvatarPartSets';
|
||||
import { EffectAssetDownloadManager } from './EffectAssetDownloadManager';
|
||||
import { PlaceHolderAvatarImage } from './PlaceHolderAvatarImage';
|
||||
import { AvatarStructureDownload } from './structure';
|
||||
|
||||
export class AvatarRenderManager extends NitroManager implements IAvatarRenderManager
|
||||
export class AvatarRenderManager implements IAvatarRenderManager
|
||||
{
|
||||
private static DEFAULT_FIGURE: string = 'hd-99999-99999';
|
||||
|
||||
private _aliasCollection: AssetAliasCollection;
|
||||
private _structure: AvatarStructure = new AvatarStructure(this);
|
||||
private _aliasCollection: AssetAliasCollection = new AssetAliasCollection(this, GetAssetManager());
|
||||
private _avatarAssetDownloadManager: AvatarAssetDownloadManager = new AvatarAssetDownloadManager(GetAssetManager(), this._structure);
|
||||
private _effectAssetDownloadManager: EffectAssetDownloadManager = new EffectAssetDownloadManager(GetAssetManager(), this._structure);
|
||||
|
||||
private _structure: AvatarStructure;
|
||||
private _avatarAssetDownloadManager: AvatarAssetDownloadManager;
|
||||
private _effectAssetDownloadManager: EffectAssetDownloadManager;
|
||||
private _placeHolderFigure: AvatarFigureContainer = new AvatarFigureContainer(AvatarRenderManager.DEFAULT_FIGURE);
|
||||
|
||||
private _placeHolderFigure: AvatarFigureContainer;
|
||||
|
||||
private _figureMapReady: boolean;
|
||||
private _effectMapReady: boolean;
|
||||
private _actionsReady: boolean;
|
||||
private _structureReady: boolean;
|
||||
private _geometryReady: boolean;
|
||||
private _partSetsReady: boolean;
|
||||
private _animationsReady: boolean;
|
||||
private _isReady: boolean;
|
||||
|
||||
constructor()
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
super();
|
||||
this._structure?.initGeometry(HabboAvatarGeometry.geometry);
|
||||
this._structure?.initPartSets(HabboAvatarPartSets.partSets);
|
||||
|
||||
this._structure = null;
|
||||
this._avatarAssetDownloadManager = null;
|
||||
await this.loadActions();
|
||||
|
||||
this._placeHolderFigure = null;
|
||||
|
||||
this._figureMapReady = false;
|
||||
this._effectMapReady = false;
|
||||
this._actionsReady = false;
|
||||
this._geometryReady = false;
|
||||
this._partSetsReady = false;
|
||||
this._animationsReady = false;
|
||||
this._isReady = false;
|
||||
|
||||
this.onAvatarAssetDownloaderReady = this.onAvatarAssetDownloaderReady.bind(this);
|
||||
this.onAvatarAssetDownloaded = this.onAvatarAssetDownloaded.bind(this);
|
||||
this.onEffectAssetDownloaderReady = this.onEffectAssetDownloaderReady.bind(this);
|
||||
this.onEffectAssetDownloaded = this.onEffectAssetDownloaded.bind(this);
|
||||
this.onAvatarStructureDownloadDone = this.onAvatarStructureDownloadDone.bind(this);
|
||||
}
|
||||
|
||||
public onInit(): void
|
||||
{
|
||||
this._structure = new AvatarStructure(this);
|
||||
|
||||
this.loadGeometry();
|
||||
this.loadPartSets();
|
||||
this.loadActions();
|
||||
this.loadAnimations();
|
||||
this.loadFigureData();
|
||||
|
||||
this._aliasCollection = new AssetAliasCollection(this, GetAssetManager());
|
||||
this._structure?.initAnimation(HabboAvatarAnimations.animations);
|
||||
await this.loadFigureData();
|
||||
|
||||
this._aliasCollection.init();
|
||||
|
||||
if(!this._avatarAssetDownloadManager)
|
||||
{
|
||||
this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(GetAssetManager(), this._structure);
|
||||
NitroEventDispatcher.addEventListener(NitroEventType.AVATAR_ASSET_LOADED, () => this._aliasCollection.reset());
|
||||
NitroEventDispatcher.addEventListener(NitroEventType.AVATAR_EFFECT_LOADED, () => this._aliasCollection.reset());
|
||||
|
||||
this._avatarAssetDownloadManager.addEventListener(AvatarAssetDownloadManager.DOWNLOADER_READY, this.onAvatarAssetDownloaderReady);
|
||||
this._avatarAssetDownloadManager.addEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
|
||||
}
|
||||
|
||||
if(!this._effectAssetDownloadManager)
|
||||
{
|
||||
this._effectAssetDownloadManager = new EffectAssetDownloadManager(GetAssetManager(), this._structure);
|
||||
|
||||
this._effectAssetDownloadManager.addEventListener(EffectAssetDownloadManager.DOWNLOADER_READY, this.onEffectAssetDownloaderReady);
|
||||
this._effectAssetDownloadManager.addEventListener(EffectAssetDownloadManager.LIBRARY_LOADED, this.onEffectAssetDownloaded);
|
||||
}
|
||||
|
||||
this.checkReady();
|
||||
await this._avatarAssetDownloadManager.init();
|
||||
await this._effectAssetDownloadManager.init();
|
||||
}
|
||||
|
||||
public onDispose(): void
|
||||
{
|
||||
if(this._avatarAssetDownloadManager)
|
||||
{
|
||||
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.DOWNLOADER_READY, this.onAvatarAssetDownloaderReady);
|
||||
|
||||
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
|
||||
}
|
||||
|
||||
if(this._effectAssetDownloadManager)
|
||||
{
|
||||
this._effectAssetDownloadManager.removeEventListener(EffectAssetDownloadManager.DOWNLOADER_READY, this.onEffectAssetDownloaderReady);
|
||||
|
||||
this._effectAssetDownloadManager.removeEventListener(EffectAssetDownloadManager.LIBRARY_LOADED, this.onEffectAssetDownloaded);
|
||||
}
|
||||
}
|
||||
|
||||
private loadGeometry(): void
|
||||
{
|
||||
if(!this._structure) return;
|
||||
|
||||
this._structure.initGeometry(HabboAvatarGeometry.geometry);
|
||||
|
||||
this._geometryReady = true;
|
||||
|
||||
this.checkReady();
|
||||
}
|
||||
|
||||
private loadPartSets(): void
|
||||
{
|
||||
if(!this._structure) return;
|
||||
|
||||
this._structure.initPartSets(HabboAvatarPartSets.partSets);
|
||||
|
||||
this._partSetsReady = true;
|
||||
|
||||
this.checkReady();
|
||||
}
|
||||
|
||||
private loadActions(): void
|
||||
private async loadActions(): Promise<void>
|
||||
{
|
||||
const defaultActions = NitroConfiguration.getValue<string>('avatar.default.actions');
|
||||
|
||||
if(defaultActions) this._structure.initActions(GetAssetManager(), defaultActions);
|
||||
|
||||
const request = new XMLHttpRequest();
|
||||
const url = NitroConfiguration.getValue<string>('avatar.actions.url');
|
||||
|
||||
try
|
||||
{
|
||||
request.open('GET', NitroConfiguration.getValue<string>('avatar.actions.url'));
|
||||
if(!url || !url.length) throw new Error('Invalid avatar action url');
|
||||
|
||||
request.send();
|
||||
const response = await fetch(url);
|
||||
|
||||
request.onloadend = e =>
|
||||
{
|
||||
if(!this._structure) return;
|
||||
if(response.status !== 200) throw new Error('Invalid avatar action file');
|
||||
|
||||
this._structure.updateActions(JSON.parse(request.responseText));
|
||||
|
||||
this._actionsReady = true;
|
||||
|
||||
this.checkReady();
|
||||
};
|
||||
|
||||
request.onerror = e =>
|
||||
{
|
||||
throw new Error('invalid_avatar_actions');
|
||||
};
|
||||
}
|
||||
|
||||
catch (e)
|
||||
{
|
||||
NitroLogger.error(e);
|
||||
}
|
||||
this._structure.updateActions(await response.json());
|
||||
}
|
||||
|
||||
private loadAnimations(): void
|
||||
{
|
||||
if(!this._structure) return;
|
||||
|
||||
this._structure.initAnimation(HabboAvatarAnimations.animations);
|
||||
|
||||
this._animationsReady = true;
|
||||
|
||||
this.checkReady();
|
||||
}
|
||||
|
||||
private loadFigureData(): void
|
||||
private async loadFigureData(): Promise<void>
|
||||
{
|
||||
const defaultFigureData = NitroConfiguration.getValue<IFigureData>('avatar.default.figuredata');
|
||||
|
||||
if(!defaultFigureData || (typeof defaultFigureData === 'string'))
|
||||
{
|
||||
NitroLogger.error('XML figuredata is no longer supported');
|
||||
if(defaultFigureData) this._structure?.initFigureData(defaultFigureData);
|
||||
|
||||
return;
|
||||
}
|
||||
const url = NitroConfiguration.getValue<string>('avatar.figuredata.url');
|
||||
|
||||
if(this._structure) this._structure.initFigureData(defaultFigureData);
|
||||
if(!url || !url.length) throw new Error('Invalid figure data url');
|
||||
|
||||
const structureDownloader = new AvatarStructureDownload(NitroConfiguration.getValue<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData));
|
||||
const response = await fetch(url);
|
||||
|
||||
structureDownloader.addEventListener(AvatarStructureDownload.AVATAR_STRUCTURE_DONE, this.onAvatarStructureDownloadDone);
|
||||
}
|
||||
if(response.status !== 200) throw new Error('Invalid figure data file');
|
||||
|
||||
private onAvatarStructureDownloadDone(event: INitroEvent): void
|
||||
{
|
||||
this._structureReady = true;
|
||||
this._structure.figureData.appendJSON(await response.json());
|
||||
|
||||
this._structure.init();
|
||||
|
||||
this.checkReady();
|
||||
}
|
||||
|
||||
private onAvatarAssetDownloaderReady(event: INitroEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
|
||||
this._figureMapReady = true;
|
||||
|
||||
this.checkReady();
|
||||
}
|
||||
|
||||
private onAvatarAssetDownloaded(event: INitroEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
|
||||
this._aliasCollection.reset();
|
||||
}
|
||||
|
||||
private onEffectAssetDownloaderReady(event: INitroEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
|
||||
this._effectMapReady = true;
|
||||
|
||||
this.checkReady();
|
||||
}
|
||||
|
||||
private onEffectAssetDownloaded(event: INitroEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
|
||||
this._aliasCollection.reset();
|
||||
}
|
||||
|
||||
private checkReady(): void
|
||||
{
|
||||
if(this._isReady) return;
|
||||
|
||||
if(!this._geometryReady || !this._partSetsReady || !this._actionsReady || !this._animationsReady || !this._figureMapReady || !this._effectMapReady || !this._structureReady) return;
|
||||
|
||||
this._isReady = true;
|
||||
|
||||
if(this.events) this.events.dispatchEvent(new NitroEvent(AvatarRenderEvent.AVATAR_RENDER_READY));
|
||||
}
|
||||
|
||||
public createFigureContainer(figure: string): IAvatarFigureContainer
|
||||
@ -274,8 +103,6 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
|
||||
return new AvatarImage(this._structure, this._aliasCollection, figureContainer, size, this._effectAssetDownloadManager, effectListener);
|
||||
}
|
||||
|
||||
if(!this._placeHolderFigure) this._placeHolderFigure = new AvatarFigureContainer(AvatarRenderManager.DEFAULT_FIGURE);
|
||||
|
||||
this._avatarAssetDownloadManager.downloadAvatarFigure(figureContainer, listener);
|
||||
|
||||
return new PlaceHolderAvatarImage(this._structure, this._aliasCollection, this._placeHolderFigure, size, this._effectAssetDownloadManager);
|
||||
@ -444,11 +271,6 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
|
||||
return GetAssetManager();
|
||||
}
|
||||
|
||||
public get isReady(): boolean
|
||||
{
|
||||
return this._isReady;
|
||||
}
|
||||
|
||||
public get structure(): AvatarStructure
|
||||
{
|
||||
return this._structure;
|
||||
|
@ -40,19 +40,6 @@ export class AvatarStructure extends EventDispatcher
|
||||
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
if(this.disposed) return;
|
||||
|
||||
super.dispose();
|
||||
|
||||
this._renderManager = null;
|
||||
this._figureData = null;
|
||||
this._partSetsData = null;
|
||||
this._animationData = null;
|
||||
this._mandatorySetTypeIds = null;
|
||||
}
|
||||
|
||||
public initGeometry(k: any): void
|
||||
{
|
||||
if(!k) return;
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { IAssetAnimation, IAssetManager, IEffectAssetDownloadLibrary } from '../../api';
|
||||
import { EventDispatcher } from '../../common';
|
||||
import { AvatarRenderEffectLibraryEvent } from '../../events';
|
||||
import { AvatarRenderEffectLibraryEvent, NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
|
||||
export class EffectAssetDownloadLibrary extends EventDispatcher implements IEffectAssetDownloadLibrary
|
||||
export class EffectAssetDownloadLibrary implements IEffectAssetDownloadLibrary
|
||||
{
|
||||
public static DOWNLOAD_COMPLETE: string = 'EADL_DOWNLOAD_COMPLETE';
|
||||
|
||||
@ -10,60 +9,53 @@ export class EffectAssetDownloadLibrary extends EventDispatcher implements IEffe
|
||||
private static LOADING: number = 1;
|
||||
private static LOADED: number = 2;
|
||||
|
||||
private _state: number;
|
||||
private _state: number = EffectAssetDownloadLibrary.NOT_LOADED;
|
||||
private _libraryName: string;
|
||||
private _revision: string;
|
||||
private _downloadUrl: string;
|
||||
private _assets: IAssetManager;
|
||||
private _animation: { [index: string]: IAssetAnimation };
|
||||
private _assetManager: IAssetManager;
|
||||
private _animation: { [index: string]: IAssetAnimation } = null;
|
||||
|
||||
constructor(id: string, revision: string, assets: IAssetManager, assetUrl: string)
|
||||
constructor(libraryName: string, revision: string, downloadUrl: string, assetManager: IAssetManager)
|
||||
{
|
||||
super();
|
||||
|
||||
this._state = EffectAssetDownloadLibrary.NOT_LOADED;
|
||||
this._libraryName = id;
|
||||
this._libraryName = libraryName;
|
||||
this._revision = revision;
|
||||
this._downloadUrl = assetUrl;
|
||||
this._assets = assets;
|
||||
this._animation = null;
|
||||
this._downloadUrl = downloadUrl;
|
||||
this._assetManager = assetManager;
|
||||
|
||||
this._downloadUrl = this._downloadUrl.replace(/%libname%/gi, this._libraryName);
|
||||
this._downloadUrl = this._downloadUrl.replace(/%revision%/gi, this._revision);
|
||||
|
||||
const asset = this._assets.getCollection(this._libraryName);
|
||||
|
||||
if(asset) this._state = EffectAssetDownloadLibrary.LOADED;
|
||||
this.checkIsLoaded();
|
||||
}
|
||||
|
||||
public async downloadAsset(): Promise<void>
|
||||
{
|
||||
if(!this._assets || (this._state === EffectAssetDownloadLibrary.LOADING) || (this._state === EffectAssetDownloadLibrary.LOADED)) return;
|
||||
if(!this._assetManager || (this._state === EffectAssetDownloadLibrary.LOADING) || (this._state === EffectAssetDownloadLibrary.LOADED)) return;
|
||||
|
||||
const asset = this._assets.getCollection(this._libraryName);
|
||||
|
||||
if(asset)
|
||||
if(!this.checkIsLoaded())
|
||||
{
|
||||
this._state = EffectAssetDownloadLibrary.LOADED;
|
||||
this._state = EffectAssetDownloadLibrary.LOADING;
|
||||
|
||||
this.dispatchEvent(new AvatarRenderEffectLibraryEvent(AvatarRenderEffectLibraryEvent.DOWNLOAD_COMPLETE, this));
|
||||
const status = await this._assetManager.downloadAsset(this._downloadUrl);
|
||||
|
||||
return;
|
||||
if(!status) throw new Error('Could not download asset');
|
||||
}
|
||||
|
||||
this._state = EffectAssetDownloadLibrary.LOADING;
|
||||
if(this.checkIsLoaded()) NitroEventDispatcher.dispatchEvent(new AvatarRenderEffectLibraryEvent(NitroEventType.AVATAR_EFFECT_DOWNLOADED, this));
|
||||
}
|
||||
|
||||
const status = await this._assets.downloadAsset(this._downloadUrl);
|
||||
private checkIsLoaded(): boolean
|
||||
{
|
||||
const asset = this._assetManager.getCollection(this._libraryName);
|
||||
|
||||
if(!status) return;
|
||||
if(!asset) return false;
|
||||
|
||||
this._state = EffectAssetDownloadLibrary.LOADED;
|
||||
|
||||
const collection = this._assets.getCollection(this._libraryName);
|
||||
this._animation = asset.data.animations;
|
||||
|
||||
if(collection) this._animation = collection.data.animations;
|
||||
|
||||
this.dispatchEvent(new AvatarRenderEffectLibraryEvent(AvatarRenderEffectLibraryEvent.DOWNLOAD_COMPLETE, this));
|
||||
return true;
|
||||
}
|
||||
|
||||
public get libraryName(): string
|
||||
|
@ -1,111 +1,66 @@
|
||||
import { IAssetManager, IAvatarEffectListener, INitroEvent, NitroConfiguration, NitroLogger } from '../../api';
|
||||
import { EventDispatcher } from '../../common';
|
||||
import { AvatarRenderEffectLibraryEvent, AvatarRenderEvent, NitroEvent } from '../../events';
|
||||
import { IAssetManager, IAvatarEffectListener, NitroConfiguration } from '../../api';
|
||||
import { AvatarRenderEffectLibraryEvent, NitroEvent, NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
import { AvatarStructure } from './AvatarStructure';
|
||||
import { EffectAssetDownloadLibrary } from './EffectAssetDownloadLibrary';
|
||||
|
||||
export class EffectAssetDownloadManager extends EventDispatcher
|
||||
export class EffectAssetDownloadManager
|
||||
{
|
||||
public static DOWNLOADER_READY: string = 'EADM_DOWNLOADER_READY';
|
||||
public static LIBRARY_LOADED: string = 'EADM_LIBRARY_LOADED';
|
||||
|
||||
private static MAX_DOWNLOADS: number = 2;
|
||||
|
||||
private _assets: IAssetManager;
|
||||
private _structure: AvatarStructure;
|
||||
|
||||
private _missingMandatoryLibs: string[];
|
||||
private _effectMap: Map<string, EffectAssetDownloadLibrary[]>;
|
||||
private _initDownloadBuffer: [number, IAvatarEffectListener][];
|
||||
private _effectListeners: Map<string, IAvatarEffectListener[]>;
|
||||
private _incompleteEffects: Map<string, EffectAssetDownloadLibrary[]>;
|
||||
private _pendingDownloadQueue: EffectAssetDownloadLibrary[];
|
||||
private _currentDownloads: EffectAssetDownloadLibrary[];
|
||||
private _libraryNames: string[];
|
||||
private _isReady: boolean;
|
||||
private _missingMandatoryLibs: string[] = [];
|
||||
private _effectMap: Map<string, EffectAssetDownloadLibrary[]> = new Map();
|
||||
private _effectListeners: Map<string, IAvatarEffectListener[]> = new Map();
|
||||
private _incompleteEffects: Map<string, EffectAssetDownloadLibrary[]> = new Map();
|
||||
private _currentDownloads: EffectAssetDownloadLibrary[] = [];
|
||||
private _libraryNames: string[] = [];
|
||||
|
||||
constructor(assets: IAssetManager, structure: AvatarStructure)
|
||||
{
|
||||
super();
|
||||
|
||||
this._assets = assets;
|
||||
this._structure = structure;
|
||||
|
||||
this._missingMandatoryLibs = NitroConfiguration.getValue<string[]>('avatar.mandatory.effect.libraries');
|
||||
this._effectMap = new Map();
|
||||
this._effectListeners = new Map();
|
||||
this._incompleteEffects = new Map();
|
||||
this._initDownloadBuffer = [];
|
||||
this._pendingDownloadQueue = [];
|
||||
this._currentDownloads = [];
|
||||
this._libraryNames = [];
|
||||
this._isReady = false;
|
||||
|
||||
this.onLibraryLoaded = this.onLibraryLoaded.bind(this);
|
||||
this.onAvatarRenderReady = this.onAvatarRenderReady.bind(this);
|
||||
|
||||
this.loadEffectMap();
|
||||
|
||||
this._structure.renderManager.events.addEventListener(AvatarRenderEvent.AVATAR_RENDER_READY, this.onAvatarRenderReady);
|
||||
}
|
||||
|
||||
private loadEffectMap(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
const request = new XMLHttpRequest();
|
||||
this._missingMandatoryLibs = NitroConfiguration.getValue<string[]>('avatar.mandatory.effect.libraries');
|
||||
|
||||
try
|
||||
{
|
||||
request.open('GET', NitroConfiguration.getValue<string>('avatar.effectmap.url'));
|
||||
const url = NitroConfiguration.getValue<string>('avatar.effectmap.url');
|
||||
|
||||
request.send();
|
||||
if(!url || !url.length) throw new Error('Invalid effect map url');
|
||||
|
||||
request.onloadend = e =>
|
||||
{
|
||||
if(request.responseText)
|
||||
{
|
||||
const data = JSON.parse(request.responseText);
|
||||
const response = await fetch(url);
|
||||
|
||||
this.processEffectMap(data.effects);
|
||||
if(response.status !== 200) throw new Error('Invalid effect map file');
|
||||
|
||||
this.processMissingLibraries();
|
||||
const responseData = await response.json();
|
||||
|
||||
this._isReady = true;
|
||||
this.processEffectMap(responseData.effects);
|
||||
|
||||
this.dispatchEvent(new NitroEvent(EffectAssetDownloadManager.DOWNLOADER_READY));
|
||||
}
|
||||
};
|
||||
NitroEventDispatcher.addEventListener(NitroEventType.AVATAR_EFFECT_DOWNLOADED, (event: AvatarRenderEffectLibraryEvent) => this.onLibraryLoaded(event));
|
||||
|
||||
request.onerror = e =>
|
||||
{
|
||||
throw new Error('invalid_avatar_effect_map');
|
||||
};
|
||||
}
|
||||
|
||||
catch (e)
|
||||
{
|
||||
NitroLogger.error(e);
|
||||
}
|
||||
await this.processMissingLibraries();
|
||||
}
|
||||
|
||||
private processEffectMap(data: any): void
|
||||
{
|
||||
if(!data) return;
|
||||
|
||||
const downloadUrl = NitroConfiguration.getValue<string>('avatar.asset.effect.url');
|
||||
|
||||
for(const effect of data)
|
||||
{
|
||||
if(!effect) continue;
|
||||
|
||||
const id = (effect.id as string);
|
||||
const lib = (effect.lib as string);
|
||||
const libraryName = (effect.lib as string);
|
||||
const revision = (effect.revision || '');
|
||||
|
||||
if(this._libraryNames.indexOf(lib) >= 0) continue;
|
||||
if(this._libraryNames.indexOf(libraryName) >= 0) continue;
|
||||
|
||||
this._libraryNames.push(lib);
|
||||
this._libraryNames.push(libraryName);
|
||||
|
||||
const downloadLibrary = new EffectAssetDownloadLibrary(lib, revision, this._assets, NitroConfiguration.getValue<string>('avatar.asset.effect.url'));
|
||||
|
||||
downloadLibrary.addEventListener(AvatarRenderEffectLibraryEvent.DOWNLOAD_COMPLETE, this.onLibraryLoaded);
|
||||
const downloadLibrary = new EffectAssetDownloadLibrary(libraryName, revision, downloadUrl, this._assets);
|
||||
|
||||
let existing = this._effectMap.get(id);
|
||||
|
||||
@ -117,55 +72,20 @@ export class EffectAssetDownloadManager extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public downloadAvatarEffect(id: number, listener: IAvatarEffectListener): void
|
||||
private async processMissingLibraries(): Promise<void>
|
||||
{
|
||||
if(!this._isReady || !this._structure.renderManager.isReady)
|
||||
const promises: Promise<void>[] = [];
|
||||
|
||||
this._missingMandatoryLibs.forEach(value =>
|
||||
{
|
||||
this._initDownloadBuffer.push([id, listener]);
|
||||
const libraries = this._effectMap.get(value);
|
||||
|
||||
return;
|
||||
}
|
||||
if(libraries) for(const library of libraries) promises.push(library.downloadAsset());
|
||||
});
|
||||
|
||||
const pendingLibraries = this.getAvatarEffectPendingLibraries(id);
|
||||
this._missingMandatoryLibs = [];
|
||||
|
||||
if(pendingLibraries && pendingLibraries.length)
|
||||
{
|
||||
if(listener && !listener.disposed)
|
||||
{
|
||||
let listeners = this._effectListeners.get(id.toString());
|
||||
|
||||
if(!listeners) listeners = [];
|
||||
|
||||
listeners.push(listener);
|
||||
|
||||
this._effectListeners.set(id.toString(), listeners);
|
||||
}
|
||||
|
||||
this._incompleteEffects.set(id.toString(), pendingLibraries);
|
||||
|
||||
for(const library of pendingLibraries)
|
||||
{
|
||||
if(!library) continue;
|
||||
|
||||
this.downloadLibrary(library);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(listener && !listener.disposed) listener.resetEffect(id);
|
||||
}
|
||||
}
|
||||
|
||||
private onAvatarRenderReady(event: INitroEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
|
||||
for(const [id, listener] of this._initDownloadBuffer)
|
||||
{
|
||||
this.downloadAvatarEffect(id, listener);
|
||||
}
|
||||
|
||||
this._initDownloadBuffer = [];
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
private onLibraryLoaded(event: AvatarRenderEffectLibraryEvent): void
|
||||
@ -204,7 +124,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
|
||||
|
||||
this._effectListeners.delete(id);
|
||||
|
||||
this.dispatchEvent(new NitroEvent(EffectAssetDownloadManager.LIBRARY_LOADED));
|
||||
NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.AVATAR_EFFECT_LOADED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,30 +145,9 @@ export class EffectAssetDownloadManager extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public processMissingLibraries(): void
|
||||
{
|
||||
const libraries = this._missingMandatoryLibs.slice();
|
||||
|
||||
for(const library of libraries)
|
||||
{
|
||||
if(!library) continue;
|
||||
|
||||
const map = this._effectMap.get(library);
|
||||
|
||||
if(map) for(const effect of map) effect && this.downloadLibrary(effect);
|
||||
}
|
||||
}
|
||||
|
||||
public isAvatarEffectReady(effect: number): boolean
|
||||
{
|
||||
if(!this._isReady || !this._structure.renderManager.isReady)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const pendingLibraries = this.getAvatarEffectPendingLibraries(effect);
|
||||
|
||||
return !pendingLibraries.length;
|
||||
return !this.getAvatarEffectPendingLibraries(effect).length;
|
||||
}
|
||||
|
||||
private getAvatarEffectPendingLibraries(id: number): EffectAssetDownloadLibrary[]
|
||||
@ -272,26 +171,35 @@ export class EffectAssetDownloadManager extends EventDispatcher
|
||||
return pendingLibraries;
|
||||
}
|
||||
|
||||
private downloadLibrary(library: EffectAssetDownloadLibrary): void
|
||||
public downloadAvatarEffect(id: number, listener: IAvatarEffectListener): void
|
||||
{
|
||||
if(!library || library.isLoaded) return;
|
||||
const pendingLibraries = this.getAvatarEffectPendingLibraries(id);
|
||||
|
||||
if((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
|
||||
|
||||
this._pendingDownloadQueue.push(library);
|
||||
|
||||
this.processDownloadQueue();
|
||||
}
|
||||
|
||||
private processDownloadQueue(): void
|
||||
{
|
||||
while(this._pendingDownloadQueue.length)
|
||||
if(pendingLibraries && pendingLibraries.length)
|
||||
{
|
||||
const library = this._pendingDownloadQueue[0];
|
||||
if(listener && !listener.disposed)
|
||||
{
|
||||
let listeners = this._effectListeners.get(id.toString());
|
||||
|
||||
library.downloadAsset();
|
||||
if(!listeners) listeners = [];
|
||||
|
||||
this._currentDownloads.push(this._pendingDownloadQueue.shift());
|
||||
listeners.push(listener);
|
||||
|
||||
this._effectListeners.set(id.toString(), listeners);
|
||||
}
|
||||
|
||||
this._incompleteEffects.set(id.toString(), pendingLibraries);
|
||||
|
||||
for(const library of pendingLibraries)
|
||||
{
|
||||
if(!library) continue;
|
||||
|
||||
library.downloadAsset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(listener && !listener.disposed) listener.resetEffect(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
import { IFigureSetData, NitroLogger } from '../../../api';
|
||||
import { EventDispatcher } from '../../../common';
|
||||
import { NitroEvent } from '../../../events';
|
||||
|
||||
export class AvatarStructureDownload extends EventDispatcher
|
||||
{
|
||||
public static AVATAR_STRUCTURE_DONE: string = 'AVATAR_STRUCTURE_DONE';
|
||||
|
||||
private _dataReceiver: IFigureSetData;
|
||||
|
||||
constructor(downloadUrl: string, dataReceiver: IFigureSetData)
|
||||
{
|
||||
super();
|
||||
|
||||
this._dataReceiver = dataReceiver;
|
||||
|
||||
this.download(downloadUrl);
|
||||
}
|
||||
|
||||
private download(url: string): void
|
||||
{
|
||||
const request = new XMLHttpRequest();
|
||||
|
||||
try
|
||||
{
|
||||
request.open('GET', url);
|
||||
|
||||
request.send();
|
||||
|
||||
request.onloadend = e =>
|
||||
{
|
||||
const response = request.responseText;
|
||||
|
||||
if(!response || !response.length) throw new Error('invalid_figure_data');
|
||||
|
||||
if(this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response));
|
||||
|
||||
this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE));
|
||||
};
|
||||
|
||||
request.onerror = e =>
|
||||
{
|
||||
throw new Error('invalid_avatar_figure_data');
|
||||
};
|
||||
}
|
||||
|
||||
catch (e)
|
||||
{
|
||||
NitroLogger.error(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
export * from './animation';
|
||||
export * from './AvatarAnimationData';
|
||||
export * from './AvatarCanvas';
|
||||
export * from './AvatarStructureDownload';
|
||||
export * from './figure';
|
||||
export * from './FigureSetData';
|
||||
export * from './parts';
|
||||
export * from './PartSetsData';
|
||||
export * from './animation';
|
||||
export * from './figure';
|
||||
export * from './parts';
|
||||
|
@ -1,21 +1,18 @@
|
||||
import { Texture } from '@pixi/core';
|
||||
import { ColorMatrix, ColorMatrixFilter } from '@pixi/filter-color-matrix';
|
||||
import { IEventDispatcher, IRoomCameraWidgetEffect, IRoomCameraWidgetManager, IRoomCameraWidgetSelectedEffect, NitroConfiguration } from '../../api';
|
||||
import { EventDispatcher } from '../../common';
|
||||
import { RoomCameraWidgetManagerEvent } from '../../events';
|
||||
import { IRoomCameraWidgetEffect, IRoomCameraWidgetManager, IRoomCameraWidgetSelectedEffect, NitroConfiguration } from '../../api';
|
||||
import { NitroEventDispatcher, RoomCameraWidgetManagerEvent } from '../../events';
|
||||
import { NitroContainer, NitroSprite, TextureUtils } from '../../pixi-proxy';
|
||||
import { RoomCameraWidgetEffect } from './RoomCameraWidgetEffect';
|
||||
|
||||
export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
|
||||
{
|
||||
private _effects: Map<string, IRoomCameraWidgetEffect>;
|
||||
private _events: IEventDispatcher;
|
||||
private _isLoaded: boolean;
|
||||
|
||||
constructor()
|
||||
{
|
||||
this._effects = new Map();
|
||||
this._events = new EventDispatcher();
|
||||
this._isLoaded = false;
|
||||
}
|
||||
|
||||
@ -47,7 +44,7 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
|
||||
this._effects.set(cameraEffect.name, cameraEffect);
|
||||
}
|
||||
|
||||
this.events.dispatchEvent(new RoomCameraWidgetManagerEvent(RoomCameraWidgetManagerEvent.INITIALIZED));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomCameraWidgetManagerEvent(RoomCameraWidgetManagerEvent.INITIALIZED));
|
||||
}
|
||||
|
||||
public async applyEffects(texture: Texture, selectedEffects: IRoomCameraWidgetSelectedEffect[], isZoomed: boolean): Promise<HTMLImageElement>
|
||||
@ -94,11 +91,6 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
|
||||
return this._effects;
|
||||
}
|
||||
|
||||
public get events(): IEventDispatcher
|
||||
{
|
||||
return this._events;
|
||||
}
|
||||
|
||||
public get isLoaded(): boolean
|
||||
{
|
||||
return this._isLoaded;
|
||||
|
96
src/nitro/communication/CommunicationManager.ts
Normal file
96
src/nitro/communication/CommunicationManager.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import { ICommunicationManager, IConnection, IMessageConfiguration, IMessageEvent, NitroConfiguration } from '../../api';
|
||||
import { NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
import { GetTickerTime } from '../../pixi-proxy';
|
||||
import { NitroMessages } from './NitroMessages';
|
||||
import { SocketConnection } from './SocketConnection';
|
||||
import { AuthenticatedEvent, ClientHelloMessageComposer, ClientPingEvent, InfoRetrieveMessageComposer, PongMessageComposer, SSOTicketMessageComposer } from './messages';
|
||||
|
||||
export class CommunicationManager implements ICommunicationManager
|
||||
{
|
||||
private _connection: IConnection = new SocketConnection();
|
||||
private _messages: IMessageConfiguration = new NitroMessages();
|
||||
|
||||
private _pongInterval: any = null;
|
||||
|
||||
constructor()
|
||||
{
|
||||
this._connection.registerMessages(this._messages);
|
||||
}
|
||||
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
NitroEventDispatcher.addEventListener(NitroEventType.SOCKET_CLOSED, () =>
|
||||
{
|
||||
this.stopPong();
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
NitroEventDispatcher.addEventListener(NitroEventType.SOCKET_OPENED, () =>
|
||||
{
|
||||
if(NitroConfiguration.getValue<boolean>('system.pong.manually', false)) this.startPong();
|
||||
|
||||
this._connection.send(new ClientHelloMessageComposer(null, null, null, null));
|
||||
this._connection.send(new SSOTicketMessageComposer(NitroConfiguration.getValue('sso.ticket', null), GetTickerTime()));
|
||||
});
|
||||
|
||||
NitroEventDispatcher.addEventListener(NitroEventType.SOCKET_ERROR, () =>
|
||||
{
|
||||
reject();
|
||||
});
|
||||
|
||||
this._connection.addMessageEvent(new ClientPingEvent((event: ClientPingEvent) => this.sendPong()));
|
||||
|
||||
this._connection.addMessageEvent(new AuthenticatedEvent((event: AuthenticatedEvent) =>
|
||||
{
|
||||
this._connection.authenticated();
|
||||
|
||||
resolve();
|
||||
|
||||
event.connection.send(new InfoRetrieveMessageComposer());
|
||||
}));
|
||||
|
||||
this._connection.init(NitroConfiguration.getValue<string>('socket.url'));
|
||||
});
|
||||
}
|
||||
|
||||
protected startPong(): void
|
||||
{
|
||||
if(this._pongInterval) this.stopPong();
|
||||
|
||||
this._pongInterval = setInterval(() => this.sendPong(), NitroConfiguration.getValue<number>('system.pong.interval.ms', 20000));
|
||||
}
|
||||
|
||||
protected stopPong(): void
|
||||
{
|
||||
if(!this._pongInterval) return;
|
||||
|
||||
clearInterval(this._pongInterval);
|
||||
|
||||
this._pongInterval = null;
|
||||
}
|
||||
|
||||
protected sendPong(): void
|
||||
{
|
||||
this._connection?.send(new PongMessageComposer());
|
||||
}
|
||||
|
||||
public registerMessageEvent(event: IMessageEvent): IMessageEvent
|
||||
{
|
||||
if(this._connection) this._connection.addMessageEvent(event);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public removeMessageEvent(event: IMessageEvent): void
|
||||
{
|
||||
if(!this._connection) return;
|
||||
|
||||
this._connection.removeMessageEvent(event);
|
||||
}
|
||||
|
||||
public get connection(): IConnection
|
||||
{
|
||||
return this._connection;
|
||||
}
|
||||
}
|
@ -1,191 +0,0 @@
|
||||
import { IConnection, INitroCommunicationDemo, INitroCommunicationManager, NitroConfiguration, NitroLogger } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { NitroCommunicationDemoEvent, SocketConnectionEvent } from '../../events';
|
||||
import { GetTickerTime } from '../../pixi-proxy';
|
||||
import { Nitro } from '../Nitro';
|
||||
import { AuthenticatedEvent, ClientHelloMessageComposer, ClientPingEvent, InfoRetrieveMessageComposer, PongMessageComposer, SSOTicketMessageComposer } from './messages';
|
||||
|
||||
export class NitroCommunicationDemo extends NitroManager implements INitroCommunicationDemo
|
||||
{
|
||||
private _communication: INitroCommunicationManager;
|
||||
|
||||
private _handShaking: boolean;
|
||||
private _didConnect: boolean;
|
||||
|
||||
private _pongInterval: any;
|
||||
|
||||
constructor(communication: INitroCommunicationManager)
|
||||
{
|
||||
super();
|
||||
|
||||
this._communication = communication;
|
||||
|
||||
this._handShaking = false;
|
||||
this._didConnect = false;
|
||||
|
||||
this._pongInterval = null;
|
||||
|
||||
this.onConnectionOpenedEvent = this.onConnectionOpenedEvent.bind(this);
|
||||
this.onConnectionClosedEvent = this.onConnectionClosedEvent.bind(this);
|
||||
this.onConnectionErrorEvent = this.onConnectionErrorEvent.bind(this);
|
||||
this.sendPong = this.sendPong.bind(this);
|
||||
}
|
||||
|
||||
protected onInit(): void
|
||||
{
|
||||
const connection = this._communication.connection;
|
||||
|
||||
if(connection)
|
||||
{
|
||||
connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
||||
connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||
connection.addEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
|
||||
}
|
||||
|
||||
this._communication.registerMessageEvent(new ClientPingEvent(this.onClientPingEvent.bind(this)));
|
||||
this._communication.registerMessageEvent(new AuthenticatedEvent(this.onAuthenticatedEvent.bind(this)));
|
||||
}
|
||||
|
||||
protected onDispose(): void
|
||||
{
|
||||
const connection = this._communication.connection;
|
||||
|
||||
if(connection)
|
||||
{
|
||||
connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
||||
connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||
connection.removeEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
|
||||
}
|
||||
|
||||
this._handShaking = false;
|
||||
|
||||
this.stopPonging();
|
||||
|
||||
super.onDispose();
|
||||
}
|
||||
|
||||
private onConnectionOpenedEvent(event: Event): void
|
||||
{
|
||||
const connection = this._communication.connection;
|
||||
|
||||
if(!connection) return;
|
||||
|
||||
this._didConnect = true;
|
||||
|
||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
|
||||
|
||||
if(NitroConfiguration.getValue<boolean>('system.pong.manually', false)) this.startPonging();
|
||||
|
||||
this.startHandshake(connection);
|
||||
|
||||
connection.send(new ClientHelloMessageComposer(null, null, null, null));
|
||||
|
||||
this.tryAuthentication(connection);
|
||||
}
|
||||
|
||||
private onConnectionClosedEvent(event: CloseEvent): void
|
||||
{
|
||||
const connection = this._communication.connection;
|
||||
|
||||
if(!connection) return;
|
||||
|
||||
this.stopPonging();
|
||||
|
||||
if(this._didConnect) this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, connection);
|
||||
}
|
||||
|
||||
private onConnectionErrorEvent(event: CloseEvent): void
|
||||
{
|
||||
const connection = this._communication.connection;
|
||||
|
||||
if(!connection) return;
|
||||
|
||||
this.stopPonging();
|
||||
|
||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ERROR, connection);
|
||||
}
|
||||
|
||||
private tryAuthentication(connection: IConnection): void
|
||||
{
|
||||
if(!connection || !this.getSSO())
|
||||
{
|
||||
if(!this.getSSO())
|
||||
{
|
||||
NitroLogger.error('Login without an SSO ticket is not supported');
|
||||
}
|
||||
|
||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED, connection);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
connection.send(new SSOTicketMessageComposer(this.getSSO(), GetTickerTime()));
|
||||
}
|
||||
|
||||
private onClientPingEvent(event: ClientPingEvent): void
|
||||
{
|
||||
if(!event || !event.connection) return;
|
||||
|
||||
this.sendPong(event.connection);
|
||||
}
|
||||
|
||||
private onAuthenticatedEvent(event: AuthenticatedEvent): void
|
||||
{
|
||||
if(!event || !event.connection) return;
|
||||
|
||||
this.completeHandshake(event.connection);
|
||||
|
||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, event.connection);
|
||||
|
||||
event.connection.send(new InfoRetrieveMessageComposer());
|
||||
}
|
||||
|
||||
private startHandshake(connection: IConnection): void
|
||||
{
|
||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING, connection);
|
||||
|
||||
this._handShaking = true;
|
||||
}
|
||||
|
||||
private completeHandshake(connection: IConnection): void
|
||||
{
|
||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKED, connection);
|
||||
|
||||
this._handShaking = false;
|
||||
}
|
||||
|
||||
private startPonging(): void
|
||||
{
|
||||
this.stopPonging();
|
||||
|
||||
this._pongInterval = setInterval(this.sendPong, NitroConfiguration.getValue<number>('system.pong.interval.ms', 20000));
|
||||
}
|
||||
|
||||
private stopPonging(): void
|
||||
{
|
||||
if(!this._pongInterval) return;
|
||||
|
||||
clearInterval(this._pongInterval);
|
||||
|
||||
this._pongInterval = null;
|
||||
}
|
||||
|
||||
private sendPong(connection: IConnection = null): void
|
||||
{
|
||||
connection = ((connection || this._communication.connection) || null);
|
||||
|
||||
if(!connection) return;
|
||||
|
||||
connection.send(new PongMessageComposer());
|
||||
}
|
||||
|
||||
private dispatchCommunicationDemoEvent(type: string, connection: IConnection): void
|
||||
{
|
||||
Nitro.instance.events.dispatchEvent(new NitroCommunicationDemoEvent(type, connection));
|
||||
}
|
||||
|
||||
private getSSO(): string
|
||||
{
|
||||
return NitroConfiguration.getValue('sso.ticket', null);
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
import { IConnection, IConnectionStateListener, IMessageConfiguration, IMessageEvent, INitroCommunicationDemo, INitroCommunicationManager, INitroEvent, NitroConfiguration, NitroLogger } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { NitroCommunicationDemoEvent, SocketConnectionEvent } from '../../events';
|
||||
import { Nitro } from '../Nitro';
|
||||
import { NitroCommunicationDemo } from './NitroCommunicationDemo';
|
||||
import { NitroMessages } from './NitroMessages';
|
||||
import { SocketConnection } from './SocketConnection';
|
||||
|
||||
export class NitroCommunicationManager extends NitroManager implements INitroCommunicationManager, IConnectionStateListener
|
||||
{
|
||||
private _connection: IConnection;
|
||||
private _messages: IMessageConfiguration;
|
||||
|
||||
private _demo: INitroCommunicationDemo;
|
||||
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
|
||||
this._connection = null;
|
||||
this._messages = new NitroMessages();
|
||||
|
||||
this._demo = new NitroCommunicationDemo(this);
|
||||
|
||||
this.onConnectionOpenedEvent = this.onConnectionOpenedEvent.bind(this);
|
||||
this.onConnectionClosedEvent = this.onConnectionClosedEvent.bind(this);
|
||||
this.onConnectionErrorEvent = this.onConnectionErrorEvent.bind(this);
|
||||
this.onConnectionAuthenticatedEvent = this.onConnectionAuthenticatedEvent.bind(this);
|
||||
}
|
||||
|
||||
protected onInit(): void
|
||||
{
|
||||
if(this._connection) return;
|
||||
|
||||
Nitro.instance.events.addEventListener(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, this.onConnectionAuthenticatedEvent);
|
||||
|
||||
this._connection = new SocketConnection(this);
|
||||
|
||||
this._connection.registerMessages(this._messages);
|
||||
|
||||
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
||||
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
|
||||
|
||||
if(this._demo) this._demo.init();
|
||||
|
||||
this._connection.init(NitroConfiguration.getValue<string>('socket.url'));
|
||||
}
|
||||
|
||||
protected onDispose(): void
|
||||
{
|
||||
if(this._demo) this._demo.dispose();
|
||||
|
||||
if(this._connection)
|
||||
{
|
||||
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
||||
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
|
||||
}
|
||||
|
||||
Nitro.instance.events.removeEventListener(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, this.onConnectionAuthenticatedEvent);
|
||||
|
||||
super.onDispose();
|
||||
}
|
||||
|
||||
private onConnectionOpenedEvent(event: Event): void
|
||||
{
|
||||
NitroLogger.log('Connection Initialized');
|
||||
}
|
||||
|
||||
private onConnectionClosedEvent(event: CloseEvent): void
|
||||
{
|
||||
NitroLogger.log('Connection Closed');
|
||||
}
|
||||
|
||||
private onConnectionErrorEvent(event: Event): void
|
||||
{
|
||||
NitroLogger.log('Connection Error');
|
||||
}
|
||||
|
||||
private onConnectionAuthenticatedEvent(event: INitroEvent): void
|
||||
{
|
||||
NitroLogger.log('Connection Authenticated');
|
||||
|
||||
if(this._connection) this._connection.authenticated();
|
||||
}
|
||||
|
||||
public connectionInit(socketUrl: string): void
|
||||
{
|
||||
NitroLogger.log('Initializing Connection', socketUrl);
|
||||
}
|
||||
|
||||
public registerMessageEvent(event: IMessageEvent): IMessageEvent
|
||||
{
|
||||
if(this._connection) this._connection.addMessageEvent(event);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public removeMessageEvent(event: IMessageEvent): void
|
||||
{
|
||||
if(!this._connection) return;
|
||||
|
||||
this._connection.removeMessageEvent(event);
|
||||
}
|
||||
|
||||
public get demo(): INitroCommunicationDemo
|
||||
{
|
||||
return this._demo;
|
||||
}
|
||||
|
||||
public get connection(): IConnection
|
||||
{
|
||||
return this._connection;
|
||||
}
|
||||
}
|
@ -1,68 +1,45 @@
|
||||
import { ICodec, IConnection, IConnectionStateListener, IMessageComposer, IMessageConfiguration, IMessageDataWrapper, IMessageEvent, NitroLogger, WebSocketEventEnum } from '../../api';
|
||||
import { EventDispatcher } from '../../common';
|
||||
import { SocketConnectionEvent } from '../../events';
|
||||
import { ICodec, IConnection, IMessageComposer, IMessageConfiguration, IMessageDataWrapper, IMessageEvent, NitroLogger, WebSocketEventEnum } from '../../api';
|
||||
import { NitroEvent, NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
import { EvaWireFormat } from './codec';
|
||||
import { MessageClassManager } from './messages';
|
||||
|
||||
export class SocketConnection extends EventDispatcher implements IConnection
|
||||
export class SocketConnection implements IConnection
|
||||
{
|
||||
private _stateListener: IConnectionStateListener;
|
||||
private _socket: WebSocket;
|
||||
private _messages: MessageClassManager;
|
||||
private _codec: ICodec;
|
||||
private _dataBuffer: ArrayBuffer;
|
||||
private _isReady: boolean;
|
||||
private _socket: WebSocket = null;
|
||||
private _messages: MessageClassManager = new MessageClassManager();
|
||||
private _codec: ICodec = new EvaWireFormat();
|
||||
private _dataBuffer: ArrayBuffer = null;
|
||||
private _isReady: boolean = false;
|
||||
|
||||
private _pendingClientMessages: IMessageComposer<unknown[]>[];
|
||||
private _pendingServerMessages: IMessageDataWrapper[];
|
||||
private _pendingClientMessages: IMessageComposer<unknown[]>[] = [];
|
||||
private _pendingServerMessages: IMessageDataWrapper[] = [];
|
||||
|
||||
private _isAuthenticated: boolean;
|
||||
|
||||
constructor(stateListener: IConnectionStateListener)
|
||||
{
|
||||
super();
|
||||
|
||||
this._stateListener = stateListener;
|
||||
this._socket = null;
|
||||
this._messages = new MessageClassManager();
|
||||
this._codec = new EvaWireFormat();
|
||||
this._dataBuffer = null;
|
||||
this._isReady = false;
|
||||
|
||||
this._pendingClientMessages = [];
|
||||
this._pendingServerMessages = [];
|
||||
|
||||
this._isAuthenticated = false;
|
||||
|
||||
this.onOpen = this.onOpen.bind(this);
|
||||
this.onClose = this.onClose.bind(this);
|
||||
this.onError = this.onError.bind(this);
|
||||
this.onMessage = this.onMessage.bind(this);
|
||||
}
|
||||
private _isAuthenticated: boolean = false;
|
||||
|
||||
public init(socketUrl: string): void
|
||||
{
|
||||
if(this._stateListener)
|
||||
if(!socketUrl || !socketUrl.length) return;
|
||||
|
||||
this._dataBuffer = new ArrayBuffer(0);
|
||||
|
||||
this._socket = new WebSocket(socketUrl);
|
||||
this._socket.binaryType = 'arraybuffer';
|
||||
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_OPENED, event => NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.SOCKET_OPENED)));
|
||||
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_CLOSED, event => NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.SOCKET_CLOSED)));
|
||||
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_ERROR, event => NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.SOCKET_ERROR)));
|
||||
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, (event: MessageEvent) =>
|
||||
{
|
||||
this._stateListener.connectionInit(socketUrl);
|
||||
}
|
||||
this._dataBuffer = this.concatArrayBuffers(this._dataBuffer, event.data);
|
||||
|
||||
this.createSocket(socketUrl);
|
||||
this.processReceivedData();
|
||||
});
|
||||
}
|
||||
|
||||
protected onDispose(): void
|
||||
{
|
||||
super.onDispose();
|
||||
|
||||
this.destroySocket();
|
||||
|
||||
this._stateListener = null;
|
||||
this._messages = null;
|
||||
this._codec = null;
|
||||
this._dataBuffer = null;
|
||||
}
|
||||
|
||||
public onReady(): void
|
||||
public ready(): void
|
||||
{
|
||||
if(this._isReady) return;
|
||||
|
||||
@ -76,67 +53,6 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
||||
this._pendingClientMessages = [];
|
||||
}
|
||||
|
||||
private createSocket(socketUrl: string): void
|
||||
{
|
||||
if(!socketUrl) return;
|
||||
|
||||
this.destroySocket();
|
||||
|
||||
this._dataBuffer = new ArrayBuffer(0);
|
||||
this._socket = new WebSocket(socketUrl);
|
||||
this._socket.binaryType = 'arraybuffer';
|
||||
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen);
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose);
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError);
|
||||
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, this.onMessage);
|
||||
}
|
||||
|
||||
private destroySocket(): void
|
||||
{
|
||||
if(!this._socket) return;
|
||||
|
||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen);
|
||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose);
|
||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError);
|
||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, this.onMessage);
|
||||
|
||||
if(this._socket.readyState === WebSocket.OPEN) this._socket.close();
|
||||
|
||||
this._socket = null;
|
||||
}
|
||||
|
||||
private onOpen(event: Event): void
|
||||
{
|
||||
this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_OPENED, event);
|
||||
}
|
||||
|
||||
private onClose(event: CloseEvent): void
|
||||
{
|
||||
this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_CLOSED, event);
|
||||
}
|
||||
|
||||
private onError(event: Event): void
|
||||
{
|
||||
this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_ERROR, event);
|
||||
}
|
||||
|
||||
private onMessage(event: MessageEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
|
||||
//this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event);
|
||||
|
||||
this._dataBuffer = this.concatArrayBuffers(this._dataBuffer, event.data);
|
||||
|
||||
this.processReceivedData();
|
||||
}
|
||||
|
||||
private dispatchConnectionEvent(type: string, event: Event): void
|
||||
{
|
||||
this.dispatchEvent(new SocketConnectionEvent(type, this, event));
|
||||
}
|
||||
|
||||
public authenticated(): void
|
||||
{
|
||||
this._isAuthenticated = true;
|
||||
@ -144,14 +60,12 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
||||
|
||||
public send(...composers: IMessageComposer<unknown[]>[]): boolean
|
||||
{
|
||||
if(this.disposed || !composers) return false;
|
||||
if(!composers) return false;
|
||||
|
||||
composers = [...composers];
|
||||
|
||||
if(this._isAuthenticated && !this._isReady)
|
||||
{
|
||||
if(!this._pendingClientMessages) this._pendingClientMessages = [];
|
||||
|
||||
this._pendingClientMessages.push(...composers);
|
||||
|
||||
return false;
|
||||
@ -271,7 +185,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
||||
{
|
||||
NitroLogger.packets('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -1,5 +1,4 @@
|
||||
export * from './NitroCommunicationDemo';
|
||||
export * from './NitroCommunicationManager';
|
||||
export * from './CommunicationManager';
|
||||
export * from './NitroMessages';
|
||||
export * from './SocketConnection';
|
||||
export * from './codec';
|
||||
|
@ -1,88 +1,44 @@
|
||||
import { IConfigurationManager, NitroConfiguration } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { ConfigurationEvent } from '../../events/core/ConfigurationEvent';
|
||||
import { NitroEvent, NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
|
||||
export class ConfigurationManager extends NitroManager implements IConfigurationManager
|
||||
export class ConfigurationManager implements IConfigurationManager
|
||||
{
|
||||
private _definitions: Map<string, unknown>;
|
||||
private _config: any;
|
||||
private _pendingUrls: string[];
|
||||
private _missingKeys: string[];
|
||||
|
||||
constructor()
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
super();
|
||||
|
||||
this._definitions = new Map();
|
||||
this._config = [];
|
||||
this._pendingUrls = [];
|
||||
this._missingKeys = [];
|
||||
|
||||
this.onConfigurationLoaded = this.onConfigurationLoaded.bind(this);
|
||||
await this.reloadConfiguration();
|
||||
}
|
||||
|
||||
protected onInit(): void
|
||||
public async reloadConfiguration(): Promise<void>
|
||||
{
|
||||
NitroConfiguration.parseConfiguration(this.getDefaultConfig(), true);
|
||||
|
||||
this._pendingUrls = NitroConfiguration.getValue<string[]>('config.urls').slice();
|
||||
|
||||
this.loadNextConfiguration();
|
||||
}
|
||||
|
||||
private loadNextConfiguration(): void
|
||||
{
|
||||
if(!this._pendingUrls.length)
|
||||
try
|
||||
{
|
||||
this.dispatchConfigurationEvent(ConfigurationEvent.LOADED);
|
||||
NitroConfiguration.resetConfiguration();
|
||||
NitroConfiguration.parseConfiguration(this.getDefaultConfig(), true);
|
||||
|
||||
return;
|
||||
const configurationUrls = NitroConfiguration.getValue<string[]>('config.urls').slice();
|
||||
|
||||
if(!configurationUrls || !configurationUrls.length) throw new Error('Invalid configuration urls');
|
||||
|
||||
for(const url of configurationUrls)
|
||||
{
|
||||
if(!url || !url.length) return;
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
if(response.status !== 200) throw new Error('Invalid configuration file');
|
||||
|
||||
NitroConfiguration.parseConfiguration(await response.json());
|
||||
}
|
||||
|
||||
NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.CONFIG_LOADED));
|
||||
}
|
||||
|
||||
this.loadConfigurationFromUrl(this._pendingUrls[0]);
|
||||
}
|
||||
|
||||
public loadConfigurationFromUrl(url: string): void
|
||||
{
|
||||
if(!url || (url === ''))
|
||||
catch (err)
|
||||
{
|
||||
this.dispatchConfigurationEvent(ConfigurationEvent.FAILED);
|
||||
NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.CONFIG_FAILED));
|
||||
|
||||
return;
|
||||
throw new Error(err);
|
||||
}
|
||||
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => this.onConfigurationLoaded(data, url))
|
||||
.catch(err => this.onConfigurationFailed(err));
|
||||
}
|
||||
|
||||
private onConfigurationLoaded(data: { [index: string]: any }, url: string): void
|
||||
{
|
||||
if(!data) return;
|
||||
|
||||
if(NitroConfiguration.parseConfiguration(data))
|
||||
{
|
||||
const index = this._pendingUrls.indexOf(url);
|
||||
|
||||
if(index >= 0) this._pendingUrls.splice(index, 1);
|
||||
|
||||
this.loadNextConfiguration();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.dispatchConfigurationEvent(ConfigurationEvent.FAILED);
|
||||
}
|
||||
|
||||
private onConfigurationFailed(error: Error): void
|
||||
{
|
||||
this.dispatchConfigurationEvent(ConfigurationEvent.FAILED);
|
||||
}
|
||||
|
||||
private dispatchConfigurationEvent(type: string): void
|
||||
{
|
||||
this.events && this.events.dispatchEvent(new ConfigurationEvent(type));
|
||||
}
|
||||
|
||||
public getDefaultConfig(): { [index: string]: any }
|
||||
|
@ -1,84 +1,53 @@
|
||||
import { INitroCommunicationManager, INitroLocalizationManager, NitroConfiguration } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { NitroLocalizationEvent } from '../../events';
|
||||
import { ICommunicationManager, ILocalizationManager, NitroConfiguration } from '../../api';
|
||||
import { NitroEvent, NitroEventDispatcher, NitroEventType } from '../../events';
|
||||
import { BadgePointLimitsEvent } from '../communication';
|
||||
import { BadgeBaseAndLevel } from './BadgeBaseAndLevel';
|
||||
|
||||
export class NitroLocalizationManager extends NitroManager implements INitroLocalizationManager
|
||||
export class LocalizationManager implements ILocalizationManager
|
||||
{
|
||||
private _communication: INitroCommunicationManager;
|
||||
private _definitions: Map<string, string>;
|
||||
private _parameters: Map<string, Map<string, string>>;
|
||||
private _badgePointLimits: Map<string, number>;
|
||||
private _romanNumerals: string[];
|
||||
private _pendingUrls: string[];
|
||||
private _communication: ICommunicationManager = null;
|
||||
private _definitions: Map<string, string> = new Map();
|
||||
private _parameters: Map<string, Map<string, string>> = new Map();
|
||||
private _badgePointLimits: Map<string, number> = new Map();
|
||||
private _romanNumerals: string[] = [ 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI', 'XVII', 'XVIII', 'XIX', 'XX', 'XXI', 'XXII', 'XXIII', 'XXIV', 'XXV', 'XXVI', 'XXVII', 'XXVIII', 'XXIX', 'XXX' ];
|
||||
|
||||
constructor(communication: INitroCommunicationManager)
|
||||
constructor(communication: ICommunicationManager)
|
||||
{
|
||||
super();
|
||||
|
||||
this._communication = communication;
|
||||
this._definitions = new Map();
|
||||
this._parameters = new Map();
|
||||
this._badgePointLimits = new Map();
|
||||
this._romanNumerals = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI', 'XVII', 'XVIII', 'XIX', 'XX', 'XXI', 'XXII', 'XXIII', 'XXIV', 'XXV', 'XXVI', 'XXVII', 'XXVIII', 'XXIX', 'XXX'];
|
||||
this._pendingUrls = [];
|
||||
}
|
||||
|
||||
protected onInit(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
this._communication.registerMessageEvent(new BadgePointLimitsEvent(this.onBadgePointLimitsEvent.bind(this)));
|
||||
|
||||
let urls: string[] = NitroConfiguration.getValue<string[]>('external.texts.url');
|
||||
|
||||
if(!Array.isArray(urls))
|
||||
try
|
||||
{
|
||||
urls = [NitroConfiguration.getValue<string>('external.texts.url')];
|
||||
const urls = NitroConfiguration.getValue<string[]>('external.texts.url').slice();
|
||||
|
||||
if(!urls || !urls.length) throw new Error('Invalid localization urls');
|
||||
|
||||
for(let url of urls)
|
||||
{
|
||||
if(!url || !url.length) return;
|
||||
|
||||
url = NitroConfiguration.interpolate(url);
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
if(response.status !== 200) throw new Error('Invalid localization file');
|
||||
|
||||
this.parseLocalization(await response.json());
|
||||
}
|
||||
|
||||
NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.LOCALIZATION_LOADED));
|
||||
|
||||
this._communication.registerMessageEvent(new BadgePointLimitsEvent(this.onBadgePointLimitsEvent.bind(this)));
|
||||
}
|
||||
|
||||
for(let i = 0; i < urls.length; i++) urls[i] = NitroConfiguration.interpolate(urls[i]);
|
||||
|
||||
this._pendingUrls = urls;
|
||||
|
||||
this.loadNextLocalization();
|
||||
}
|
||||
|
||||
private loadNextLocalization(): void
|
||||
{
|
||||
if(!this._pendingUrls.length)
|
||||
catch (err)
|
||||
{
|
||||
this.events && this.events.dispatchEvent(new NitroLocalizationEvent(NitroLocalizationEvent.LOADED));
|
||||
NitroEventDispatcher.dispatchEvent(new NitroEvent(NitroEventType.LOCALIZATION_FAILED));
|
||||
|
||||
return;
|
||||
throw new Error(err);
|
||||
}
|
||||
|
||||
this.loadLocalizationFromURL(this._pendingUrls[0]);
|
||||
}
|
||||
|
||||
public loadLocalizationFromURL(url: string): void
|
||||
{
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => this.onLocalizationLoaded(data, url))
|
||||
.catch(err => this.onLocalizationFailed(err));
|
||||
}
|
||||
|
||||
private onLocalizationLoaded(data: { [index: string]: any }, url: string): void
|
||||
{
|
||||
if(!data) return;
|
||||
|
||||
if(!this.parseLocalization(data)) throw new Error(`Invalid json data for file ${url}`);
|
||||
|
||||
const index = this._pendingUrls.indexOf(url);
|
||||
|
||||
if(index >= 0) this._pendingUrls.splice(index, 1);
|
||||
|
||||
this.loadNextLocalization();
|
||||
}
|
||||
|
||||
private onLocalizationFailed(error: Error): void
|
||||
{
|
||||
this.events && this.events.dispatchEvent(new NitroLocalizationEvent(NitroLocalizationEvent.FAILED));
|
||||
}
|
||||
|
||||
private parseLocalization(data: { [index: string]: any }): boolean
|
@ -1,2 +1,2 @@
|
||||
export * from './BadgeBaseAndLevel';
|
||||
export * from './NitroLocalizationManager';
|
||||
export * from './LocalizationManager';
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { BaseTexture, Resource, Texture } from '@pixi/core';
|
||||
import { Spritesheet } from '@pixi/spritesheet';
|
||||
import { FurnitureType, GetAssetManager, GraphicAssetCollection, GraphicAssetGifCollection, IAssetData, IEventDispatcher, IFurnitureData, IFurnitureDataListener, IGraphicAssetCollection, IGraphicAssetGifCollection, IPetColorResult, IRoomContentListener, IRoomContentLoader, IRoomObject, ISessionDataManager, NitroBundle, NitroConfiguration, NitroLogger, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, RoomObjectVisualizationType } from '../../api';
|
||||
import { NitroEvent } from '../../events';
|
||||
import { FurnitureType, GetAssetManager, GraphicAssetCollection, GraphicAssetGifCollection, IAssetData, IEventDispatcher, IFurnitureData, IGraphicAssetCollection, IGraphicAssetGifCollection, IPetColorResult, IRoomContentListener, IRoomContentLoader, IRoomObject, ISessionDataManager, NitroBundle, NitroConfiguration, NitroLogger, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, RoomObjectVisualizationType } from '../../api';
|
||||
import { NitroEventDispatcher } from '../../events';
|
||||
import { RoomContentLoadedEvent } from '../../events/room/RoomContentLoadedEvent';
|
||||
import { PetColorResult } from './PetColorResult';
|
||||
|
||||
export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLoader
|
||||
export class RoomContentLoader implements IRoomContentLoader
|
||||
{
|
||||
private static PLACE_HOLDER: string = 'place_holder';
|
||||
private static PLACE_HOLDER_WALL: string = 'place_holder_wall';
|
||||
@ -15,113 +15,42 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
|
||||
private static TILE_CURSOR: string = 'tile_cursor';
|
||||
private static SELECTION_ARROW: string = 'selection_arrow';
|
||||
|
||||
public static LOADER_READY: string = 'RCL_LOADER_READY';
|
||||
public static MANDATORY_LIBRARIES: string[] = [RoomContentLoader.PLACE_HOLDER, RoomContentLoader.PLACE_HOLDER_WALL, RoomContentLoader.PLACE_HOLDER_PET, RoomContentLoader.ROOM, RoomContentLoader.TILE_CURSOR, RoomContentLoader.SELECTION_ARROW];
|
||||
|
||||
private _stateEvents: IEventDispatcher;
|
||||
private _sessionDataManager: ISessionDataManager;
|
||||
private _waitingForSessionDataManager: boolean;
|
||||
private _iconListener: IRoomContentListener;
|
||||
private _collections: Map<string, IGraphicAssetCollection>;
|
||||
private _gifCollections: Map<string, GraphicAssetGifCollection>;
|
||||
private _images: Map<string, HTMLImageElement>;
|
||||
private _collections: Map<string, IGraphicAssetCollection> = new Map();
|
||||
private _gifCollections: Map<string, GraphicAssetGifCollection> = new Map();
|
||||
private _images: Map<string, HTMLImageElement> = new Map();
|
||||
|
||||
private _events: Map<string, IEventDispatcher>;
|
||||
private _activeObjects: { [index: string]: number };
|
||||
private _activeObjectTypes: Map<number, string>;
|
||||
private _activeObjectTypeIds: Map<string, number>;
|
||||
private _objectTypeAdUrls: Map<string, string>;
|
||||
private _wallItems: { [index: string]: number };
|
||||
private _wallItemTypes: Map<number, string>;
|
||||
private _wallItemTypeIds: Map<string, number>;
|
||||
private _furniRevisions: Map<string, number>;
|
||||
private _pets: { [index: string]: number };
|
||||
private _petColors: Map<number, Map<number, IPetColorResult>>;
|
||||
private _objectAliases: Map<string, string>;
|
||||
private _objectOriginalNames: Map<string, string>;
|
||||
private _activeObjects: { [index: string]: number } = {};
|
||||
private _activeObjectTypes: Map<number, string> = new Map();
|
||||
private _activeObjectTypeIds: Map<string, number> = new Map();
|
||||
private _objectTypeAdUrls: Map<string, string> = new Map();
|
||||
private _wallItems: { [index: string]: number } = {};
|
||||
private _wallItemTypes: Map<number, string> = new Map();
|
||||
private _wallItemTypeIds: Map<string, number> = new Map();
|
||||
private _furniRevisions: Map<string, number> = new Map();
|
||||
private _pets: { [index: string]: number } = {};
|
||||
private _petColors: Map<number, Map<number, IPetColorResult>> = new Map();
|
||||
private _objectAliases: Map<string, string> = new Map();
|
||||
private _objectOriginalNames: Map<string, string> = new Map();
|
||||
|
||||
private _pendingContentTypes: string[];
|
||||
private _dataInitialized: boolean;
|
||||
private _pendingContentTypes: string[] = [];
|
||||
private _dataInitialized: boolean = false;
|
||||
|
||||
constructor()
|
||||
constructor(sessionDataManager: ISessionDataManager)
|
||||
{
|
||||
this._stateEvents = null;
|
||||
this._sessionDataManager = null;
|
||||
this._waitingForSessionDataManager = false;
|
||||
this._iconListener = null;
|
||||
this._collections = new Map();
|
||||
this._gifCollections = new Map();
|
||||
this._images = new Map();
|
||||
|
||||
this._events = new Map();
|
||||
this._activeObjects = {};
|
||||
this._activeObjectTypes = new Map();
|
||||
this._activeObjectTypeIds = new Map();
|
||||
this._objectTypeAdUrls = new Map();
|
||||
this._wallItems = {};
|
||||
this._wallItemTypes = new Map();
|
||||
this._wallItemTypeIds = new Map();
|
||||
this._furniRevisions = new Map();
|
||||
this._pets = {};
|
||||
this._petColors = new Map();
|
||||
this._objectAliases = new Map();
|
||||
this._objectOriginalNames = new Map();
|
||||
|
||||
this._pendingContentTypes = [];
|
||||
this._dataInitialized = false;
|
||||
this._sessionDataManager = sessionDataManager;
|
||||
}
|
||||
|
||||
public initialize(events: IEventDispatcher): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
this._stateEvents = events;
|
||||
|
||||
this.setFurnitureData();
|
||||
this.processFurnitureData(this._sessionDataManager.getAllFurnitureData());
|
||||
|
||||
for(const [index, name] of NitroConfiguration.getValue<string[]>('pet.types').entries()) this._pets[name] = index;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public setSessionDataManager(sessionData: ISessionDataManager): void
|
||||
{
|
||||
this._sessionDataManager = sessionData;
|
||||
|
||||
if(this._waitingForSessionDataManager)
|
||||
{
|
||||
this._waitingForSessionDataManager = false;
|
||||
|
||||
this.setFurnitureData();
|
||||
}
|
||||
}
|
||||
|
||||
public loadFurnitureData(): void
|
||||
{
|
||||
this.setFurnitureData();
|
||||
}
|
||||
|
||||
private setFurnitureData(): void
|
||||
{
|
||||
if(!this._sessionDataManager)
|
||||
{
|
||||
this._waitingForSessionDataManager = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const furnitureData = this._sessionDataManager.getAllFurnitureData(this);
|
||||
|
||||
if(!furnitureData) return;
|
||||
|
||||
this._sessionDataManager.removePendingFurniDataListener(this);
|
||||
|
||||
this.processFurnitureData(furnitureData);
|
||||
|
||||
this._stateEvents.dispatchEvent(new NitroEvent(RoomContentLoader.LOADER_READY));
|
||||
}
|
||||
|
||||
private processFurnitureData(furnitureData: IFurnitureData[]): void
|
||||
{
|
||||
if(!furnitureData) return;
|
||||
@ -480,49 +409,41 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
|
||||
return false;
|
||||
}
|
||||
|
||||
public async downloadAsset(type: string, events: IEventDispatcher): Promise<void>
|
||||
public async downloadAsset(type: string): Promise<void>
|
||||
{
|
||||
const assetUrl: string = this.getAssetUrls(type)?.[0];
|
||||
|
||||
if(!assetUrl || !assetUrl.length) return;
|
||||
|
||||
if((this._pendingContentTypes.indexOf(type) >= 0) || this.getOrRemoveEventDispatcher(type)) return;
|
||||
if((this._pendingContentTypes.indexOf(type) >= 0)) return;
|
||||
|
||||
this._pendingContentTypes.push(type);
|
||||
this._events.set(type, events);
|
||||
|
||||
try
|
||||
{
|
||||
const response = await fetch(assetUrl);
|
||||
|
||||
if(response.status !== 200) throw new Error(`${ type } error`);
|
||||
|
||||
let contentType = 'application/octet-stream';
|
||||
|
||||
if(response.headers.has('Content-Type'))
|
||||
if(response.headers.has('Content-Type')) contentType = response.headers.get('Content-Type');
|
||||
|
||||
if(contentType === 'application/octet-stream')
|
||||
{
|
||||
contentType = response.headers.get('Content-Type');
|
||||
const nitroBundle = new NitroBundle(await response.arrayBuffer());
|
||||
|
||||
await this.processAsset(nitroBundle.baseTexture, (nitroBundle.jsonFile as IAssetData));
|
||||
|
||||
NitroEventDispatcher.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type));
|
||||
}
|
||||
|
||||
switch(contentType)
|
||||
{
|
||||
case 'application/octet-stream': {
|
||||
const nitroBundle = new NitroBundle(await response.arrayBuffer());
|
||||
|
||||
await this.processAsset(nitroBundle.baseTexture, (nitroBundle.jsonFile as IAssetData));
|
||||
|
||||
const events = this._events.get(type);
|
||||
|
||||
if(!events) return;
|
||||
|
||||
events.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error();
|
||||
}
|
||||
throw new Error('Invalid asset');
|
||||
}
|
||||
|
||||
catch (err)
|
||||
{
|
||||
events.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_FAILURE, type));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_FAILURE, type));
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,15 +609,6 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
|
||||
model.setValue(RoomObjectVariable.OBJECT_ROOM_ID, roomId);
|
||||
}
|
||||
|
||||
private getOrRemoveEventDispatcher(type: string, remove: boolean = false): IEventDispatcher
|
||||
{
|
||||
const existing = this._events.get(type);
|
||||
|
||||
if(remove) this._events.delete(type);
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
public setIconListener(listener: IRoomContentListener): void
|
||||
{
|
||||
this._iconListener = listener;
|
||||
|
@ -1,13 +1,14 @@
|
||||
import { RenderTexture, Resource, Texture } from '@pixi/core';
|
||||
import { Container, DisplayObject } from '@pixi/display';
|
||||
import { Matrix, Point, Rectangle } from '@pixi/math';
|
||||
import { IConnection, IDisposable, IFurnitureStackingHeightMap, IGetImageListener, IImageResult, ILegacyWallGeometry, IMessageComposer, INitroCommunicationManager, INitroEvent, IObjectData, IPetColorResult, IPetCustomPart, IRoomContentListener, IRoomContentLoader, IRoomCreator, IRoomEngine, IRoomEngineServices, IRoomGeometry, IRoomInstance, IRoomManager, IRoomManagerListener, IRoomObject, IRoomObjectController, IRoomObjectLogicFactory, IRoomObjectVisualizationFactory, IRoomRenderer, IRoomRendererFactory, IRoomRenderingCanvas, IRoomSessionManager, ISelectedRoomObjectData, ISessionDataManager, ITileObjectMap, IUpdateReceiver, IVector3D, LegacyDataType, MouseEventType, NitroConfiguration, NitroLogger, ObjectDataFactory, RoomControllerLevel, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, ToolbarIconEnum, Vector3d } from '../../api';
|
||||
import { ICommunicationManager, IConnection, IFurnitureStackingHeightMap, IGetImageListener, IImageResult, ILegacyWallGeometry, IMessageComposer, IObjectData, IPetColorResult, IPetCustomPart, IRoomContentListener, IRoomContentLoader, IRoomCreator, IRoomEngine, IRoomEngineServices, IRoomGeometry, IRoomInstance, IRoomManager, IRoomManagerListener, IRoomObject, IRoomObjectController, IRoomObjectLogicFactory, IRoomObjectVisualizationFactory, IRoomRenderer, IRoomRendererFactory, IRoomRenderingCanvas, IRoomSessionManager, ISelectedRoomObjectData, ISessionDataManager, ITileObjectMap, IUpdateReceiver, IVector3D, LegacyDataType, MouseEventType, NitroConfiguration, NitroLogger, ObjectDataFactory, RoomControllerLevel, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, ToolbarIconEnum, Vector3d } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { BadgeImageReadyEvent, NitroToolbarAnimateIconEvent, RoomBackgroundColorEvent, RoomDragEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomObjectEvent, RoomObjectFurnitureActionEvent, RoomObjectMouseEvent, RoomSessionEvent, RoomToObjectOwnAvatarMoveEvent } from '../../events';
|
||||
import { BadgeImageReadyEvent, NitroEventDispatcher, NitroToolbarAnimateIconEvent, RoomBackgroundColorEvent, RoomDragEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomObjectEvent, RoomObjectFurnitureActionEvent, RoomObjectMouseEvent, RoomSessionEvent, RoomToObjectOwnAvatarMoveEvent } from '../../events';
|
||||
import { GetTicker, GetTickerTime, NitroSprite, TextureUtils } from '../../pixi-proxy';
|
||||
import { NumberBank, RoomEnterEffect, RoomGeometry, RoomInstance, RoomObjectUpdateMessage, RoomRendererFactory } from '../../room';
|
||||
import { NumberBank, RoomEnterEffect, RoomGeometry, RoomInstance, RoomManager, RoomObjectUpdateMessage, RoomRendererFactory } from '../../room';
|
||||
import { PetFigureData } from '../avatar';
|
||||
import { RenderRoomMessageComposer, RenderRoomThumbnailMessageComposer } from '../communication';
|
||||
import { RoomSessionManager } from '../session';
|
||||
import { FurniId } from '../utils';
|
||||
import { ImageResult } from './ImageResult';
|
||||
import { RoomContentLoader } from './RoomContentLoader';
|
||||
@ -19,7 +20,7 @@ import { ObjectAvatarCarryObjectUpdateMessage, ObjectAvatarChatUpdateMessage, Ob
|
||||
import { RoomLogic, RoomMapData, RoomObjectVisualizationFactory } from './object';
|
||||
import { RoomCamera, RoomData, RoomFurnitureData, RoomInstanceData, RoomObjectBadgeImageAssetListener, SpriteDataCollector } from './utils';
|
||||
|
||||
export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreator, IRoomEngineServices, IRoomManagerListener, IRoomContentListener, IUpdateReceiver, IDisposable
|
||||
export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreator, IRoomEngineServices, IRoomManagerListener, IRoomContentListener, IUpdateReceiver
|
||||
{
|
||||
public static ROOM_OBJECT_ID: number = -1;
|
||||
public static ROOM_OBJECT_TYPE: string = 'room';
|
||||
@ -36,99 +37,57 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
private static DRAG_THRESHOLD: number = 15;
|
||||
private static TEMPORARY_ROOM: string = 'temporary_room';
|
||||
|
||||
private _communication: INitroCommunicationManager;
|
||||
private _roomRendererFactory: IRoomRendererFactory;
|
||||
private _communication: ICommunicationManager;
|
||||
private _roomRendererFactory: IRoomRendererFactory = new RoomRendererFactory();
|
||||
private _roomManager: IRoomManager;
|
||||
private _visualizationFactory: IRoomObjectVisualizationFactory;
|
||||
private _visualizationFactory: IRoomObjectVisualizationFactory = new RoomObjectVisualizationFactory();
|
||||
private _sessionDataManager: ISessionDataManager;
|
||||
private _roomSessionManager: IRoomSessionManager;
|
||||
private _roomObjectEventHandler: RoomObjectEventHandler;
|
||||
private _roomMessageHandler: RoomMessageHandler;
|
||||
private _roomObjectEventHandler: RoomObjectEventHandler = new RoomObjectEventHandler(this);
|
||||
private _roomMessageHandler: RoomMessageHandler = new RoomMessageHandler(this);
|
||||
private _roomContentLoader: IRoomContentLoader;
|
||||
private _ready: boolean;
|
||||
private _roomContentLoaderReady: boolean;
|
||||
private _imageObjectIdBank: NumberBank;
|
||||
private _imageCallbacks: Map<string, IGetImageListener[]>;
|
||||
private _thumbnailObjectIdBank: NumberBank;
|
||||
private _thumbnailCallbacks: Map<string, IGetImageListener[]>;
|
||||
private _activeRoomId: number;
|
||||
private _activeRoomActiveCanvas: number;
|
||||
private _activeRoomActiveCanvasMouseX: number;
|
||||
private _activeRoomActiveCanvasMouseY: number;
|
||||
private _activeRoomIsDragged: boolean;
|
||||
private _activeRoomWasDragged: boolean;
|
||||
private _activeRoomDragStartX: number;
|
||||
private _activeRoomDragStartY: number;
|
||||
private _activeRoomDragX: number;
|
||||
private _activeRoomDragY: number;
|
||||
private _roomDraggingAlwaysCenters: boolean;
|
||||
private _roomAllowsDragging: boolean;
|
||||
private _roomDatas: Map<number, RoomData>;
|
||||
private _roomInstanceDatas: Map<number, RoomInstanceData>;
|
||||
private _skipFurnitureCreationForNextFrame: boolean;
|
||||
private _mouseCursorUpdate: boolean;
|
||||
private _badgeListenerObjects: Map<string, RoomObjectBadgeImageAssetListener[]>;
|
||||
private _logicFactory: IRoomObjectLogicFactory;
|
||||
private _imageObjectIdBank: NumberBank = new NumberBank(1000);
|
||||
private _imageCallbacks: Map<string, IGetImageListener[]> = new Map();
|
||||
private _thumbnailObjectIdBank: NumberBank = new NumberBank(1000);
|
||||
private _thumbnailCallbacks: Map<string, IGetImageListener[]> = new Map();
|
||||
private _activeRoomId: number = -1;
|
||||
private _activeRoomActiveCanvas: number = -1;
|
||||
private _activeRoomActiveCanvasMouseX: number = 0;
|
||||
private _activeRoomActiveCanvasMouseY: number = 0;
|
||||
private _activeRoomIsDragged: boolean = false;
|
||||
private _activeRoomWasDragged: boolean = false;
|
||||
private _activeRoomDragStartX: number = 0;
|
||||
private _activeRoomDragStartY: number = 0;
|
||||
private _activeRoomDragX: number = 0;
|
||||
private _activeRoomDragY: number = 0;
|
||||
private _roomDraggingAlwaysCenters: boolean = false;
|
||||
private _roomAllowsDragging: boolean = true;
|
||||
private _roomDatas: Map<number, RoomData> = new Map();
|
||||
private _roomInstanceDatas: Map<number, RoomInstanceData> = new Map();
|
||||
private _skipFurnitureCreationForNextFrame: boolean = false;
|
||||
private _mouseCursorUpdate: boolean = false;
|
||||
private _badgeListenerObjects: Map<string, RoomObjectBadgeImageAssetListener[]> = new Map();
|
||||
private _logicFactory: IRoomObjectLogicFactory = new RoomObjectLogicFactory();
|
||||
|
||||
constructor(communication: INitroCommunicationManager)
|
||||
constructor(communication: ICommunicationManager, sessionDataManager: ISessionDataManager)
|
||||
{
|
||||
super();
|
||||
|
||||
this._communication = communication;
|
||||
this._sessionDataManager = null;
|
||||
this._roomSessionManager = null;
|
||||
this._roomManager = null;
|
||||
this._roomObjectEventHandler = new RoomObjectEventHandler(this);
|
||||
this._roomMessageHandler = new RoomMessageHandler(this);
|
||||
this._roomContentLoader = new RoomContentLoader();
|
||||
this._ready = false;
|
||||
this._roomContentLoaderReady = false;
|
||||
this._sessionDataManager = sessionDataManager;
|
||||
this._roomSessionManager = new RoomSessionManager(this._communication, this);
|
||||
this._roomContentLoader = new RoomContentLoader(sessionDataManager);
|
||||
this._roomManager = new RoomManager(this, this._visualizationFactory, this._logicFactory, this._roomContentLoader);
|
||||
|
||||
this._activeRoomId = -1;
|
||||
this._activeRoomActiveCanvas = -1;
|
||||
this._roomInstanceDatas = new Map();
|
||||
this._roomDatas = new Map();
|
||||
|
||||
this._roomRendererFactory = new RoomRendererFactory();
|
||||
this._visualizationFactory = new RoomObjectVisualizationFactory();
|
||||
this._logicFactory = new RoomObjectLogicFactory();
|
||||
|
||||
this._activeRoomActiveCanvasMouseX = 0;
|
||||
this._activeRoomActiveCanvasMouseY = 0;
|
||||
this._activeRoomIsDragged = false;
|
||||
this._activeRoomWasDragged = false;
|
||||
this._activeRoomDragStartX = 0;
|
||||
this._activeRoomDragStartY = 0;
|
||||
this._activeRoomDragX = 0;
|
||||
this._activeRoomDragY = 0;
|
||||
this._skipFurnitureCreationForNextFrame = false;
|
||||
this._mouseCursorUpdate = false;
|
||||
this._imageObjectIdBank = null;
|
||||
this._imageCallbacks = new Map();
|
||||
this._thumbnailCallbacks = new Map();
|
||||
this._roomDraggingAlwaysCenters = false;
|
||||
this._roomAllowsDragging = true;
|
||||
this._badgeListenerObjects = new Map();
|
||||
|
||||
this.runVisibilityUpdate = this.runVisibilityUpdate.bind(this);
|
||||
this.processRoomObjectEvent = this.processRoomObjectEvent.bind(this);
|
||||
this.onRoomSessionEvent = this.onRoomSessionEvent.bind(this);
|
||||
this.onRoomContentLoaderReadyEvent = this.onRoomContentLoaderReadyEvent.bind(this);
|
||||
this.onBadgeImageReadyEvent = this.onBadgeImageReadyEvent.bind(this);
|
||||
}
|
||||
|
||||
public onInit(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
if(this._ready) return;
|
||||
|
||||
this._imageObjectIdBank = new NumberBank(1000);
|
||||
this._thumbnailObjectIdBank = new NumberBank(1000);
|
||||
|
||||
this._logicFactory.registerEventFunction(this.processRoomObjectEvent);
|
||||
this._logicFactory.registerEventFunction(this.processRoomObjectEvent.bind(this));
|
||||
|
||||
if(this._roomManager)
|
||||
{
|
||||
this._roomManager.setContentLoader(this._roomContentLoader);
|
||||
this._roomManager.addUpdateCategory(RoomObjectCategory.FLOOR);
|
||||
this._roomManager.addUpdateCategory(RoomObjectCategory.WALL);
|
||||
this._roomManager.addUpdateCategory(RoomObjectCategory.UNIT);
|
||||
@ -138,51 +97,26 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
this._roomMessageHandler.setConnection(this._communication.connection);
|
||||
|
||||
this._roomContentLoader.initialize(this.events);
|
||||
this._roomContentLoader.setSessionDataManager(this._sessionDataManager);
|
||||
this._roomContentLoader.setIconListener(this);
|
||||
NitroEventDispatcher.addEventListener<RoomSessionEvent>(RoomSessionEvent.STARTED, event => this.onRoomSessionEvent(event));
|
||||
NitroEventDispatcher.addEventListener<RoomSessionEvent>(RoomSessionEvent.ENDED, event => this.onRoomSessionEvent(event));
|
||||
|
||||
if(this._roomSessionManager)
|
||||
await this._roomContentLoader.init(), this._roomContentLoader.setIconListener(this);
|
||||
await this._roomManager.init();
|
||||
await this._roomSessionManager.init();
|
||||
|
||||
for(const roomData of this._roomDatas.values())
|
||||
{
|
||||
this._roomSessionManager.events.addEventListener(RoomSessionEvent.STARTED, this.onRoomSessionEvent);
|
||||
this._roomSessionManager.events.addEventListener(RoomSessionEvent.ENDED, this.onRoomSessionEvent);
|
||||
}
|
||||
if(!roomData) continue;
|
||||
|
||||
this.events.addEventListener(RoomContentLoader.LOADER_READY, this.onRoomContentLoaderReadyEvent);
|
||||
this.createRoomInstance(roomData.roomId, roomData.data);
|
||||
}
|
||||
|
||||
GetTicker().add(this.update, this);
|
||||
|
||||
document.addEventListener('visibilitychange', this.runVisibilityUpdate);
|
||||
}
|
||||
|
||||
public onDispose(): void
|
||||
{
|
||||
if(!this._ready) return;
|
||||
|
||||
for(const [key, value] of this._roomInstanceDatas)
|
||||
document.addEventListener('visibilitychange', event =>
|
||||
{
|
||||
this.removeRoomInstance(key);
|
||||
}
|
||||
|
||||
document.removeEventListener('visibilitychange', this.runVisibilityUpdate);
|
||||
|
||||
GetTicker().remove(this.update, this);
|
||||
|
||||
if(this._roomObjectEventHandler) this._roomObjectEventHandler.dispose();
|
||||
|
||||
if(this._roomMessageHandler) this._roomMessageHandler.dispose();
|
||||
|
||||
if(this._roomContentLoader) this._roomContentLoader.dispose();
|
||||
|
||||
this.events.removeEventListener(RoomContentLoader.LOADER_READY, this.onRoomContentLoaderReadyEvent);
|
||||
|
||||
if(this._roomSessionManager)
|
||||
{
|
||||
this._roomSessionManager.events.removeEventListener(RoomSessionEvent.STARTED, this.onRoomSessionEvent);
|
||||
this._roomSessionManager.events.removeEventListener(RoomSessionEvent.ENDED, this.onRoomSessionEvent);
|
||||
}
|
||||
|
||||
super.onDispose();
|
||||
if(!document.hidden) this.update(1, true);
|
||||
});
|
||||
}
|
||||
|
||||
private onRoomSessionEvent(event: RoomSessionEvent): void
|
||||
@ -204,13 +138,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
}
|
||||
}
|
||||
|
||||
private onRoomContentLoaderReadyEvent(event: INitroEvent): void
|
||||
{
|
||||
this._roomContentLoaderReady = true;
|
||||
|
||||
this._roomManager.init();
|
||||
}
|
||||
|
||||
public setActiveRoomId(roomId: number): void
|
||||
{
|
||||
this._activeRoomId = roomId;
|
||||
@ -244,7 +171,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
existing.dispose();
|
||||
}
|
||||
|
||||
this.events.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.DISPOSED, roomId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.DISPOSED, roomId));
|
||||
}
|
||||
|
||||
public createRoomInstance(roomId: number, roomMap: RoomMapData): void
|
||||
@ -253,32 +180,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
let wallType = '201';
|
||||
let landscapeType = '1';
|
||||
|
||||
if(!this._ready)
|
||||
{
|
||||
let data = this._roomDatas.get(roomId);
|
||||
|
||||
if(data)
|
||||
{
|
||||
this._roomDatas.delete(roomId);
|
||||
|
||||
floorType = data.floorType;
|
||||
wallType = data.wallType;
|
||||
landscapeType = data.landscapeType;
|
||||
}
|
||||
|
||||
data = new RoomData(roomId, roomMap);
|
||||
|
||||
data.floorType = floorType;
|
||||
data.wallType = wallType;
|
||||
data.landscapeType = landscapeType;
|
||||
|
||||
this._roomDatas.set(roomId, data);
|
||||
|
||||
NitroLogger.warn('Room Engine not initilized yet, can not create room. Room data stored for later initialization.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(!roomMap)
|
||||
{
|
||||
NitroLogger.warn('Room property messages');
|
||||
@ -312,12 +213,12 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
this._roomAllowsDragging = true;
|
||||
}
|
||||
|
||||
this.events.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.INITIALIZED, roomId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.INITIALIZED, roomId));
|
||||
}
|
||||
|
||||
private setupRoomInstance(roomId: number, roomMap: RoomMapData, floorType: string, wallType: string, landscapeType: string, worldType: string): IRoomInstance
|
||||
{
|
||||
if(!this._ready || !this._roomManager) return;
|
||||
if(!this._roomManager) return;
|
||||
|
||||
const instance = this._roomManager.createRoomInstance(this.getRoomId(roomId));
|
||||
|
||||
@ -523,7 +424,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
roomCanvas.setScale(scale, point, offsetPoint, override, asDelta);
|
||||
|
||||
this.events.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.ROOM_ZOOMED, roomId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.ROOM_ZOOMED, roomId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,7 +474,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if((renderingCanvas.screenOffsetX === x) && (renderingCanvas.screenOffsetY === y)) return;
|
||||
|
||||
this.events.dispatchEvent(new RoomDragEvent(roomId, -(renderingCanvas.screenOffsetX - x), -(renderingCanvas.screenOffsetY - y)));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomDragEvent(roomId, -(renderingCanvas.screenOffsetX - x), -(renderingCanvas.screenOffsetY - y)));
|
||||
|
||||
renderingCanvas.screenOffsetX = x;
|
||||
renderingCanvas.screenOffsetY = y;
|
||||
@ -714,7 +615,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
roomObject.logic.processUpdateMessage(event);
|
||||
|
||||
this.events.dispatchEvent(new RoomBackgroundColorEvent(roomId, color, light, backgroundOnly));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomBackgroundColorEvent(roomId, color, light, backgroundOnly));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -760,11 +661,11 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if(mode === 0)
|
||||
{
|
||||
this.events.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.NORMAL_MODE, roomId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.NORMAL_MODE, roomId));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.events.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.GAME_MODE, roomId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.GAME_MODE, roomId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,11 +701,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
this.update(1);
|
||||
}
|
||||
|
||||
public runVisibilityUpdate(): void
|
||||
{
|
||||
if(!document.hidden) this.update(1, true);
|
||||
}
|
||||
|
||||
public update(time: number, update: boolean = false): void
|
||||
{
|
||||
if(!this._roomManager) return;
|
||||
@ -912,22 +808,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
}
|
||||
}
|
||||
|
||||
public onRoomEngineInitalized(flag: boolean): void
|
||||
{
|
||||
if(!flag) return;
|
||||
|
||||
this._ready = true;
|
||||
|
||||
this.events.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, 0));
|
||||
|
||||
for(const roomData of this._roomDatas.values())
|
||||
{
|
||||
if(!roomData) continue;
|
||||
|
||||
this.createRoomInstance(roomData.roomId, roomData.data);
|
||||
}
|
||||
}
|
||||
|
||||
private processPendingFurnitureFloor(roomId: number, id: number, data: RoomFurnitureData): boolean
|
||||
{
|
||||
if(!data)
|
||||
@ -975,7 +855,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
if(!this.updateRoomObjectFloorHeight(roomId, id, data.sizeZ)) return false;
|
||||
}
|
||||
|
||||
if(this.events) this.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.ADDED, roomId, id, RoomObjectCategory.FLOOR));
|
||||
if(NitroEventDispatcher) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.ADDED, roomId, id, RoomObjectCategory.FLOOR));
|
||||
|
||||
const selectedRoomObjectData = this.getPlacedRoomObjectData(roomId);
|
||||
|
||||
@ -1030,7 +910,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if(!this.updateRoomObjectWall(roomId, id, data.location, data.direction, data.state, extra)) return false;
|
||||
|
||||
if(this.events) this.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.ADDED, roomId, id, RoomObjectCategory.WALL));
|
||||
if(NitroEventDispatcher) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.ADDED, roomId, id, RoomObjectCategory.WALL));
|
||||
|
||||
const selectedRoomObjectData = this.getPlacedRoomObjectData(roomId);
|
||||
|
||||
@ -1622,8 +1502,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
public getRoomObject(roomId: number, objectId: number, category: number): IRoomObjectController
|
||||
{
|
||||
if(!this._ready) return null;
|
||||
|
||||
let roomIdString = this.getRoomId(roomId);
|
||||
|
||||
if(roomId === 0) roomIdString = RoomEngine.TEMPORARY_ROOM;
|
||||
@ -1749,13 +1627,13 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
{
|
||||
const image = await TextureUtils.generateImage(icon);
|
||||
|
||||
if(this.events)
|
||||
if(NitroEventDispatcher)
|
||||
{
|
||||
const event = new NitroToolbarAnimateIconEvent(image, screenLocation.x, screenLocation.y);
|
||||
|
||||
event.iconName = ToolbarIconEnum.INVENTORY;
|
||||
|
||||
this.events.dispatchEvent(event);
|
||||
NitroEventDispatcher.dispatchEvent(event);
|
||||
}
|
||||
})();
|
||||
}
|
||||
@ -1797,13 +1675,13 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
{
|
||||
const image = await TextureUtils.generateImage(icon);
|
||||
|
||||
if(this.events)
|
||||
if(NitroEventDispatcher)
|
||||
{
|
||||
const event = new NitroToolbarAnimateIconEvent(image, screenLocation.x, screenLocation.y);
|
||||
|
||||
event.iconName = ToolbarIconEnum.INVENTORY;
|
||||
|
||||
this.events.dispatchEvent(event);
|
||||
NitroEventDispatcher.dispatchEvent(event);
|
||||
}
|
||||
})();
|
||||
}
|
||||
@ -1829,7 +1707,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
instance.removeRoomObject(objectId, category);
|
||||
|
||||
if(this.events) this.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REMOVED, roomId, objectId, category));
|
||||
if(NitroEventDispatcher) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REMOVED, roomId, objectId, category));
|
||||
}
|
||||
|
||||
public addFurnitureFloor(roomId: number, id: number, typeId: number, location: IVector3D, direction: IVector3D, state: number, objectData: IObjectData, extra: number = NaN, expires: number = -1, usagePolicy: number = 0, ownerId: number = 0, ownerName: string = '', synchronized: boolean = true, realRoomObject: boolean = true, sizeZ: number = -1): boolean
|
||||
@ -2023,7 +1901,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if(figure) object.processUpdateMessage(new ObjectAvatarFigureUpdateMessage(figure));
|
||||
|
||||
if(this.events) this.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.ADDED, roomId, objectId, RoomObjectCategory.UNIT));
|
||||
if(NitroEventDispatcher) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.ADDED, roomId, objectId, RoomObjectCategory.UNIT));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2046,7 +1924,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if(roomSession && (roomSession.ownRoomIndex === objectId))
|
||||
{
|
||||
this._logicFactory.events.dispatchEvent(new RoomToObjectOwnAvatarMoveEvent(RoomToObjectOwnAvatarMoveEvent.ROAME_MOVE_TO, targetLocation));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomToObjectOwnAvatarMoveEvent(RoomToObjectOwnAvatarMoveEvent.ROAME_MOVE_TO, targetLocation));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -2249,7 +2127,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
object.processUpdateMessage(new ObjectDataUpdateMessage(object.getState(0), data));
|
||||
}
|
||||
|
||||
this.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.CONTENT_UPDATED, id, objectId, category));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.CONTENT_UPDATED, id, objectId, category));
|
||||
}
|
||||
|
||||
if(roomId !== RoomEngine.TEMPORARY_ROOM) this.addObjectToTileMap(id, object);
|
||||
@ -2318,7 +2196,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if(!this._badgeListenerObjects.size)
|
||||
{
|
||||
this._sessionDataManager.events.addEventListener(BadgeImageReadyEvent.IMAGE_READY, this.onBadgeImageReadyEvent);
|
||||
NitroEventDispatcher.addEventListener(BadgeImageReadyEvent.IMAGE_READY, this.onBadgeImageReadyEvent);
|
||||
}
|
||||
|
||||
let listeners = this._badgeListenerObjects.get(badgeId);
|
||||
@ -2360,7 +2238,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if(!this._badgeListenerObjects.size)
|
||||
{
|
||||
this._sessionDataManager.events.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, this.onBadgeImageReadyEvent);
|
||||
NitroEventDispatcher.removeEventListener(BadgeImageReadyEvent.IMAGE_READY, this.onBadgeImageReadyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2399,9 +2277,9 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
if(type === MouseEventType.MOUSE_CLICK)
|
||||
{
|
||||
if(this.events)
|
||||
if(NitroEventDispatcher)
|
||||
{
|
||||
this.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DESELECTED, this._activeRoomId, -1, RoomObjectCategory.MINIMUM));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DESELECTED, this._activeRoomId, -1, RoomObjectCategory.MINIMUM));
|
||||
}
|
||||
|
||||
eventType = RoomObjectMouseEvent.CLICK;
|
||||
@ -2945,7 +2823,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
imageResult.id = -1;
|
||||
|
||||
if(!this._ready || !type) return imageResult;
|
||||
if(!type) return imageResult;
|
||||
|
||||
let roomInstance = this._roomManager.getRoomInstance(RoomEngine.TEMPORARY_ROOM);
|
||||
|
||||
@ -3085,7 +2963,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
imageResult.id = -1;
|
||||
|
||||
if(!this._ready || !type) return imageResult;
|
||||
if(!type) return imageResult;
|
||||
|
||||
let roomInstance = this._roomManager.getRoomInstance(RoomEngine.TEMPORARY_ROOM);
|
||||
|
||||
@ -3307,14 +3185,11 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
|
||||
public getRoomObjects(roomId: number, category: number): IRoomObject[]
|
||||
{
|
||||
if(this._ready)
|
||||
{
|
||||
const _local_3 = this.getRoomId(roomId);
|
||||
const _local_4 = this._roomManager.getRoomInstance(_local_3);
|
||||
const _local_3 = this.getRoomId(roomId);
|
||||
const _local_4 = this._roomManager.getRoomInstance(_local_3);
|
||||
|
||||
|
||||
if(_local_4) return _local_4.getRoomObjectsForCategory(category);
|
||||
}
|
||||
if(_local_4) return _local_4.getRoomObjectsForCategory(category);
|
||||
|
||||
return [];
|
||||
}
|
||||
@ -3434,7 +3309,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
{
|
||||
const roomId = this.getRoomIdFromString(k);
|
||||
|
||||
this.events.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.OBJECTS_INITIALIZED, roomId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineEvent(RoomEngineEvent.OBJECTS_INITIALIZED, roomId));
|
||||
}
|
||||
|
||||
public getRoomId(id: number): string
|
||||
@ -3535,21 +3410,11 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
return this._sessionDataManager;
|
||||
}
|
||||
|
||||
public set sessionDataManager(manager: ISessionDataManager)
|
||||
{
|
||||
this._sessionDataManager = manager;
|
||||
}
|
||||
|
||||
public get roomSessionManager(): IRoomSessionManager
|
||||
{
|
||||
return this._roomSessionManager;
|
||||
}
|
||||
|
||||
public set roomSessionManager(manager: IRoomSessionManager)
|
||||
{
|
||||
this._roomSessionManager = manager;
|
||||
}
|
||||
|
||||
public get roomManager(): IRoomManager
|
||||
{
|
||||
return this._roomManager;
|
||||
@ -3585,11 +3450,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
|
||||
return this._activeRoomId;
|
||||
}
|
||||
|
||||
public get ready(): boolean
|
||||
{
|
||||
return this._ready;
|
||||
}
|
||||
|
||||
public get roomContentLoader(): IRoomContentLoader
|
||||
{
|
||||
return this._roomContentLoader;
|
||||
|
@ -978,7 +978,7 @@ export class RoomMessageHandler extends Disposable
|
||||
// _SafeStr_4231._SafeStr_6766();
|
||||
// return;
|
||||
// case 2:
|
||||
// this._SafeStr_10592.roomSessionManager.events.dispatchEvent(new _SafeStr_2821(this._SafeStr_10593, -1, true));
|
||||
// NitroEventDispatcher.dispatchEvent(new _SafeStr_2821(this._SafeStr_10593, -1, true));
|
||||
// return;
|
||||
// case 3:
|
||||
// arrayIndex = 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IFurnitureStackingHeightMap, ILegacyWallGeometry, IObjectData, IRoomCanvasMouseListener, IRoomEngineServices, IRoomGeometry, IRoomObject, IRoomObjectController, IRoomObjectEventManager, ISelectedRoomObjectData, IVector3D, MouseEventType, NitroConfiguration, NitroLogger, RoomObjectCategory, RoomObjectOperationType, RoomObjectPlacementSource, RoomObjectType, RoomObjectUserType, RoomObjectVariable, Vector3d } from '../../api';
|
||||
import { Disposable } from '../../common';
|
||||
import { RoomEngineDimmerStateEvent, RoomEngineObjectEvent, RoomEngineObjectPlacedEvent, RoomEngineObjectPlacedOnUserEvent, RoomEngineObjectPlaySoundEvent, RoomEngineRoomAdEvent, RoomEngineSamplePlaybackEvent, RoomEngineTriggerWidgetEvent, RoomEngineUseProductEvent, RoomObjectBadgeAssetEvent, RoomObjectDataRequestEvent, RoomObjectDimmerStateUpdateEvent, RoomObjectEvent, RoomObjectFloorHoleEvent, RoomObjectFurnitureActionEvent, RoomObjectHSLColorEnabledEvent, RoomObjectHSLColorEnableEvent, RoomObjectMouseEvent, RoomObjectMoveEvent, RoomObjectPlaySoundIdEvent, RoomObjectRoomAdEvent, RoomObjectSamplePlaybackEvent, RoomObjectSoundMachineEvent, RoomObjectStateChangedEvent, RoomObjectTileMouseEvent, RoomObjectWallMouseEvent, RoomObjectWidgetRequestEvent, RoomSpriteMouseEvent } from '../../events';
|
||||
import { NitroEventDispatcher, RoomEngineDimmerStateEvent, RoomEngineObjectEvent, RoomEngineObjectPlacedEvent, RoomEngineObjectPlacedOnUserEvent, RoomEngineObjectPlaySoundEvent, RoomEngineRoomAdEvent, RoomEngineSamplePlaybackEvent, RoomEngineTriggerWidgetEvent, RoomEngineUseProductEvent, RoomObjectBadgeAssetEvent, RoomObjectDataRequestEvent, RoomObjectDimmerStateUpdateEvent, RoomObjectEvent, RoomObjectFloorHoleEvent, RoomObjectFurnitureActionEvent, RoomObjectHSLColorEnabledEvent, RoomObjectHSLColorEnableEvent, RoomObjectMouseEvent, RoomObjectMoveEvent, RoomObjectPlaySoundIdEvent, RoomObjectRoomAdEvent, RoomObjectSamplePlaybackEvent, RoomObjectSoundMachineEvent, RoomObjectStateChangedEvent, RoomObjectTileMouseEvent, RoomObjectWallMouseEvent, RoomObjectWidgetRequestEvent, RoomSpriteMouseEvent } from '../../events';
|
||||
import { RoomEnterEffect, RoomId, RoomObjectUpdateMessage } from '../../room';
|
||||
import { BotPlaceComposer, FurnitureColorWheelComposer, FurnitureDiceActivateComposer, FurnitureDiceDeactivateComposer, FurnitureFloorUpdateComposer, FurnitureGroupInfoComposer, FurnitureMultiStateComposer, FurnitureOneWayDoorComposer, FurniturePickupComposer, FurniturePlaceComposer, FurniturePostItPlaceComposer, FurnitureRandomStateComposer, FurnitureWallMultiStateComposer, FurnitureWallUpdateComposer, GetItemDataComposer, GetResolutionAchievementsMessageComposer, PetMoveComposer, PetPlaceComposer, RemoveWallItemComposer, RoomUnitLookComposer, RoomUnitWalkComposer, SetItemDataMessageComposer, SetObjectDataMessageComposer } from '../communication';
|
||||
import { Nitro } from '../Nitro';
|
||||
@ -35,7 +35,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
|
||||
this.onRoomEngineObjectEvent = this.onRoomEngineObjectEvent.bind(this);
|
||||
|
||||
this._roomEngine.events.addEventListener(RoomEngineObjectEvent.ADDED, this.onRoomEngineObjectEvent);
|
||||
NitroEventDispatcher.addEventListener(RoomEngineObjectEvent.ADDED, this.onRoomEngineObjectEvent);
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
@ -45,7 +45,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
this._eventIds = null;
|
||||
}
|
||||
|
||||
this._roomEngine.events.removeEventListener(RoomEngineObjectEvent.ADDED, this.onRoomEngineObjectEvent);
|
||||
NitroEventDispatcher.removeEventListener(RoomEngineObjectEvent.ADDED, this.onRoomEngineObjectEvent);
|
||||
|
||||
this._roomEngine = null;
|
||||
}
|
||||
@ -439,9 +439,9 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
{
|
||||
if(category === RoomObjectCategory.FLOOR)
|
||||
{
|
||||
if(this._roomEngine.events)
|
||||
if(NitroEventDispatcher)
|
||||
{
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_ROTATE, roomId, event.objectId, category));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_ROTATE, roomId, event.objectId, category));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -487,7 +487,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
{
|
||||
this.deselectObject(roomId);
|
||||
|
||||
if(this._roomEngine.events) this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DESELECTED, roomId, -1, RoomObjectCategory.MINIMUM));
|
||||
if(NitroEventDispatcher) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DESELECTED, roomId, -1, RoomObjectCategory.MINIMUM));
|
||||
|
||||
this.setSelectedAvatar(roomId, 0, false);
|
||||
}
|
||||
@ -500,9 +500,9 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
const type = event.objectType;
|
||||
const category = this._roomEngine.getRoomObjectCategoryForType(type);
|
||||
|
||||
if(this._roomEngine.events)
|
||||
if(NitroEventDispatcher)
|
||||
{
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DOUBLE_CLICK, roomId, id, category));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DOUBLE_CLICK, roomId, id, category));
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,7 +580,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
{
|
||||
if((event.altKey && !event.ctrlKey && !event.shiftKey) || this.decorateModeMove(event))
|
||||
{
|
||||
if(this._roomEngine.events) this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_MOVE, roomId, event.objectId, category));
|
||||
if(NitroEventDispatcher) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_MOVE, roomId, event.objectId, category));
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -606,7 +606,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
{
|
||||
if((!event.ctrlKey && !event.shiftKey) || this.decorateModeMove(event))
|
||||
{
|
||||
if(this._roomEngine.events) this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, roomId, event.objectId, category));
|
||||
if(NitroEventDispatcher) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, roomId, event.objectId, category));
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -619,9 +619,9 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
const type = event.objectType;
|
||||
const category = this._roomEngine.getRoomObjectCategoryForType(type);
|
||||
|
||||
if(this._roomEngine.events)
|
||||
if(NitroEventDispatcher)
|
||||
{
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.MOUSE_ENTER, roomId, id, category));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.MOUSE_ENTER, roomId, id, category));
|
||||
}
|
||||
}
|
||||
|
||||
@ -641,9 +641,9 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
}
|
||||
}
|
||||
|
||||
if(this._roomEngine.events)
|
||||
if(NitroEventDispatcher)
|
||||
{
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.MOUSE_LEAVE, roomId, id, category));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.MOUSE_LEAVE, roomId, id, category));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -671,7 +671,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectDimmerStateUpdateEvent.DIMMER_STATE:
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineDimmerStateEvent(roomId, event.state, event.presetId, event.effectId, event.color, event.brightness));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineDimmerStateEvent(roomId, event.state, event.presetId, event.effectId, event.color, event.brightness));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -710,124 +710,121 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
const objectId = event.objectId;
|
||||
const objectType = event.objectType;
|
||||
const objectCategory = this._roomEngine.getRoomObjectCategoryForType(objectType);
|
||||
const eventDispatcher = this._roomEngine.events;
|
||||
|
||||
if(!eventDispatcher) return;
|
||||
|
||||
if(RoomId.isRoomPreviewerId(roomId)) return;
|
||||
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectWidgetRequestEvent.OPEN_WIDGET:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, roomId, objectId, objectCategory, ((event.object as IRoomObjectController).logic.widget)));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, roomId, objectId, objectCategory, ((event.object as IRoomObjectController).logic.widget)));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.CLOSE_WIDGET:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.CLOSE_WIDGET, roomId, objectId, objectCategory, ((event.object as IRoomObjectController).logic.widget)));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.CLOSE_WIDGET, roomId, objectId, objectCategory, ((event.object as IRoomObjectController).logic.widget)));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.OPEN_FURNI_CONTEXT_MENU:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, roomId, objectId, objectCategory, ((event.object as IRoomObjectController).logic.contextMenu)));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, roomId, objectId, objectCategory, ((event.object as IRoomObjectController).logic.contextMenu)));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.PLACEHOLDER:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.CREDITFURNI:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.STACK_HEIGHT:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_STACK_HEIGHT, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_STACK_HEIGHT, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.EXTERNAL_IMAGE:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_EXTERNAL_IMAGE, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_EXTERNAL_IMAGE, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.STICKIE:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.PRESENT:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PRESENT, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PRESENT, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.TROPHY:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.TEASER:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_TEASER, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_TEASER, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.ECOTRONBOX:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.DIMMER:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.WIDGET_REMOVE_DIMMER:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REMOVE_DIMMER, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REMOVE_DIMMER, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.CLOTHING_CHANGE:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.JUKEBOX_PLAYLIST_EDITOR:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.MANNEQUIN:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.PET_PRODUCT_MENU:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineUseProductEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineUseProductEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.GUILD_FURNI_CONTEXT_MENU:
|
||||
this._roomEngine.connection.send(new FurnitureGroupInfoComposer(event.objectId, event.object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID)));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.BACKGROUND_COLOR:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.MYSTERYBOX_OPEN_DIALOG:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MYSTERYBOX_OPEN_DIALOG, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MYSTERYBOX_OPEN_DIALOG, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.EFFECTBOX_OPEN_DIALOG:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_EFFECTBOX_OPEN_DIALOG, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_EFFECTBOX_OPEN_DIALOG, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.MYSTERYTROPHY_OPEN_DIALOG:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MYSTERYTROPHY_OPEN_DIALOG, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MYSTERYTROPHY_OPEN_DIALOG, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_OPEN:
|
||||
this._roomEngine.connection.send(new GetResolutionAchievementsMessageComposer(event.objectId, 0));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_ENGRAVING:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.ACHIEVEMENT_RESOLUTION_FAILED:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.FRIEND_FURNITURE_CONFIRM:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_CONFIRM, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_CONFIRM, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.FRIEND_FURNITURE_ENGRAVING:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.BADGE_DISPLAY_ENGRAVING:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.HIGH_SCORE_DISPLAY:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.HIDE_HIGH_SCORE_DISPLAY:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.INERNAL_LINK:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.ROOM_LINK:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, roomId, objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectWidgetRequestEvent.YOUTUBE:
|
||||
eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_YOUTUBE, roomId, objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_YOUTUBE, roomId, objectId, objectCategory));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -857,16 +854,16 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectFurnitureActionEvent.SOUND_MACHINE_INIT:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_INIT, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_INIT, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectFurnitureActionEvent.SOUND_MACHINE_START:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_SWITCHED_ON, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_SWITCHED_ON, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectFurnitureActionEvent.SOUND_MACHINE_STOP:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_SWITCHED_OFF, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_SWITCHED_OFF, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectFurnitureActionEvent.SOUND_MACHINE_DISPOSE:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_DISPOSE, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.SOUND_MACHINE_DISPOSE, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -889,16 +886,16 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectFurnitureActionEvent.JUKEBOX_INIT:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_INIT, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_INIT, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectFurnitureActionEvent.JUKEBOX_START:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_SWITCHED_ON, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_SWITCHED_ON, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectFurnitureActionEvent.JUKEBOX_MACHINE_STOP:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_SWITCHED_OFF, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_SWITCHED_OFF, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
case RoomObjectFurnitureActionEvent.JUKEBOX_DISPOSE:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_DISPOSE, roomId, event.objectId, objectCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectSoundMachineEvent(RoomObjectSoundMachineEvent.JUKEBOX_DISPOSE, roomId, event.objectId, objectCategory));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -927,7 +924,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectRoomAdEvent.ROOM_AD_FURNI_CLICK:
|
||||
this._roomEngine.events.dispatchEvent(event);
|
||||
NitroEventDispatcher.dispatchEvent(event);
|
||||
|
||||
if(event.clickUrl && (event.clickUrl.length > 0))
|
||||
{
|
||||
@ -957,7 +954,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
break;
|
||||
}
|
||||
|
||||
if(eventType) this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(eventType, roomId, event.objectId, this._roomEngine.getRoomObjectCategoryForType(event.objectType)));
|
||||
if(eventType) NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(eventType, roomId, event.objectId, this._roomEngine.getRoomObjectCategoryForType(event.objectType)));
|
||||
}
|
||||
|
||||
private onRoomObjectBadgeAssetEvent(event: RoomObjectBadgeAssetEvent, roomId: number): void
|
||||
@ -991,10 +988,10 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectPlaySoundIdEvent.PLAY_SOUND:
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectPlaySoundEvent(RoomEngineObjectPlaySoundEvent.PLAY_SOUND, roomId, event.objectId, objectCategory, event.soundId, event.pitch));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectPlaySoundEvent(RoomEngineObjectPlaySoundEvent.PLAY_SOUND, roomId, event.objectId, objectCategory, event.soundId, event.pitch));
|
||||
return;
|
||||
case RoomObjectPlaySoundIdEvent.PLAY_SOUND_AT_PITCH:
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectPlaySoundEvent(RoomEngineObjectPlaySoundEvent.PLAY_SOUND_AT_PITCH, roomId, event.objectId, objectCategory, event.soundId, event.pitch));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectPlaySoundEvent(RoomEngineObjectPlaySoundEvent.PLAY_SOUND_AT_PITCH, roomId, event.objectId, objectCategory, event.soundId, event.pitch));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1008,16 +1005,16 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectSamplePlaybackEvent.ROOM_OBJECT_INITIALIZED:
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.ROOM_OBJECT_INITIALIZED, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.ROOM_OBJECT_INITIALIZED, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
break;
|
||||
case RoomObjectSamplePlaybackEvent.ROOM_OBJECT_DISPOSED:
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.ROOM_OBJECT_DISPOSED, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.ROOM_OBJECT_DISPOSED, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
break;
|
||||
case RoomObjectSamplePlaybackEvent.PLAY_SAMPLE:
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.PLAY_SAMPLE, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.PLAY_SAMPLE, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
break;
|
||||
case RoomObjectSamplePlaybackEvent.CHANGE_PITCH:
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.CHANGE_PITCH, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineSamplePlaybackEvent(RoomEngineSamplePlaybackEvent.CHANGE_PITCH, roomId, event.objectId, objectCategory, event.sampleId, event.pitch));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1029,7 +1026,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomObjectHSLColorEnableEvent.ROOM_BACKGROUND_COLOR:
|
||||
this._roomEngine.events.dispatchEvent(new RoomObjectHSLColorEnabledEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, roomId, event.enable, event.hue, event.saturation, event.lightness));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomObjectHSLColorEnabledEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, roomId, event.enable, event.hue, event.saturation, event.lightness));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1064,7 +1061,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
{
|
||||
if(!event || !this._roomEngine) return;
|
||||
|
||||
const eventDispatcher = this._roomEngine.events;
|
||||
const eventDispatcher = NitroEventDispatcher;
|
||||
|
||||
if(!eventDispatcher) return;
|
||||
|
||||
@ -1136,7 +1133,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
{
|
||||
if(!event || !this._roomEngine) return;
|
||||
|
||||
const eventDispatcher = this._roomEngine.events;
|
||||
const eventDispatcher = NitroEventDispatcher;
|
||||
|
||||
if(!eventDispatcher) return;
|
||||
|
||||
@ -1704,11 +1701,11 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
|
||||
this.resetSelectedObjectData(roomId);
|
||||
|
||||
if(this._roomEngine && this._roomEngine.events)
|
||||
if(this._roomEngine && NitroEventDispatcher)
|
||||
{
|
||||
const placedInRoom = (roomObject && (roomObject.id === selectedData.id));
|
||||
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectPlacedEvent(RoomEngineObjectEvent.PLACED, roomId, objectId, category, wallLocation, x, y, z, direction, placedInRoom, isTileEvent, isWallEvent, selectedData.instanceData));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectPlacedEvent(RoomEngineObjectEvent.PLACED, roomId, objectId, category, wallLocation, x, y, z, direction, placedInRoom, isTileEvent, isWallEvent, selectedData.instanceData));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1997,16 +1994,16 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
|
||||
if(!_local_5) return;
|
||||
|
||||
if(!this._roomEngine || !this._roomEngine.events) return;
|
||||
if(!this._roomEngine || !NitroEventDispatcher) return;
|
||||
|
||||
this._roomEngine.events.dispatchEvent(new RoomEngineObjectPlacedOnUserEvent(RoomEngineObjectEvent.PLACED_ON_USER, roomId, objectId, category, _local_4.id, _local_4.category));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectPlacedOnUserEvent(RoomEngineObjectEvent.PLACED_ON_USER, roomId, objectId, category, _local_4.id, _local_4.category));
|
||||
}
|
||||
|
||||
public setSelectedObject(roomId: number, objectId: number, category: number): void
|
||||
{
|
||||
if(!this._roomEngine) return;
|
||||
|
||||
const eventDispatcher = this._roomEngine.events;
|
||||
const eventDispatcher = NitroEventDispatcher;
|
||||
|
||||
if(!eventDispatcher) return;
|
||||
|
||||
@ -2040,7 +2037,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
|
||||
}
|
||||
}
|
||||
|
||||
eventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.SELECTED, roomId, objectId, category));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.SELECTED, roomId, objectId, category));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1,24 +1,15 @@
|
||||
import { IEventDispatcher, IRoomObjectEventHandler, IRoomObjectLogicFactory, NitroLogger, RoomObjectLogicType } from '../../api';
|
||||
import { EventDispatcher } from '../../common';
|
||||
import { RoomObjectEvent } from '../../events';
|
||||
import { RoomObjectLogicBase } from '../../room';
|
||||
import { AvatarLogic, FurnitureAchievementResolutionLogic, FurnitureBadgeDisplayLogic, FurnitureChangeStateWhenStepOnLogic, FurnitureClothingChangeLogic, FurnitureCounterClockLogic, FurnitureCrackableLogic, FurnitureCraftingGizmoLogic, FurnitureCreditLogic, FurnitureCuckooClockLogic, FurnitureCustomStackHeightLogic, FurnitureDiceLogic, FurnitureEcotronBoxLogic, FurnitureEditableInternalLinkLogic, FurnitureEditableRoomLinkLogic, FurnitureEffectBoxLogic, FurnitureExternalImageLogic, FurnitureFireworksLogic, FurnitureFloorHoleLogic, FurnitureGroupForumTerminalLogic, FurnitureGuildCustomizedLogic, FurnitureHabboWheelLogic, FurnitureHighScoreLogic, FurnitureHockeyScoreLogic, FurnitureHweenLovelockLogic, FurnitureIceStormLogic, FurnitureInternalLinkLogic, FurnitureJukeboxLogic, FurnitureLogic, FurnitureLoveLockLogic, FurnitureMannequinLogic, FurnitureMonsterplantSeedLogic, FurnitureMultiHeightLogic, FurnitureMultiStateLogic, FurnitureMysteryBoxLogic, FurnitureMysteryTrophyLogic, FurnitureOneWayDoorLogic, FurniturePetCustomizationLogic, FurniturePlaceholderLogic, FurniturePlanetSystemLogic, FurniturePresentLogic, FurniturePurchaseableClothingLogic, FurniturePushableLogic, FurnitureRandomStateLogic, FurnitureRandomTeleportLogic, FurnitureRentableSpaceLogic, FurnitureRoomBackgroundColorLogic, FurnitureRoomBackgroundLogic, FurnitureRoomBillboardLogic, FurnitureRoomDimmerLogic, FurnitureScoreLogic, FurnitureSongDiskLogic, FurnitureSoundBlockLogic, FurnitureSoundMachineLogic, FurnitureStickieLogic, FurnitureTrophyLogic, FurnitureVoteCounterLogic, FurnitureVoteMajorityLogic, FurnitureWelcomeGiftLogic, FurnitureWindowLogic, FurnitureYoutubeLogic, PetLogic, RoomLogic, SelectionArrowLogic, TileCursorLogic } from './object';
|
||||
|
||||
export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
|
||||
{
|
||||
private _events: IEventDispatcher;
|
||||
|
||||
private _cachedEvents: Map<string, boolean>;
|
||||
private _registeredEvents: Map<string, boolean>;
|
||||
private _functions: Function[];
|
||||
|
||||
constructor()
|
||||
{
|
||||
this._events = new EventDispatcher();
|
||||
|
||||
this._cachedEvents = new Map();
|
||||
this._registeredEvents = new Map();
|
||||
this._functions = [];
|
||||
}
|
||||
private _events: IEventDispatcher = new EventDispatcher();
|
||||
private _cachedEvents: Map<string, boolean> = new Map();
|
||||
private _registeredEvents: Map<string, boolean> = new Map();
|
||||
private _functions: ((event: RoomObjectEvent) => void)[] = [];
|
||||
|
||||
public getLogic(type: string): IRoomObjectEventHandler
|
||||
{
|
||||
@ -63,7 +54,7 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
|
||||
}
|
||||
}
|
||||
|
||||
public registerEventFunction(func: Function): void
|
||||
public registerEventFunction(func: (event: RoomObjectEvent) => void): void
|
||||
{
|
||||
if(!func) return;
|
||||
|
||||
@ -79,7 +70,7 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
|
||||
}
|
||||
}
|
||||
|
||||
public removeEventFunction(func: Function): void
|
||||
public removeEventFunction(func: (event: RoomObjectEvent) => void): void
|
||||
{
|
||||
if(!func) return;
|
||||
|
||||
|
@ -3,13 +3,13 @@ import { Container, DisplayObject } from '@pixi/display';
|
||||
import { Point, Rectangle } from '@pixi/math';
|
||||
import { Sprite } from '@pixi/sprite';
|
||||
import { IGetImageListener, IImageResult, IObjectData, IRoomEngine, IRoomObjectController, IRoomRenderingCanvas, IVector3D, LegacyDataType, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, Vector3d } from '../../../api';
|
||||
import { RoomEngineEvent, RoomEngineObjectEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomEngineEvent, RoomEngineObjectEvent } from '../../../events';
|
||||
import { GetTickerTime, NitroSprite } from '../../../pixi-proxy';
|
||||
import { RoomId } from '../../../room';
|
||||
import { FloorHeightMapMessageParser, RoomEntryTileMessageParser } from '../../communication';
|
||||
import { RoomEngine } from '../RoomEngine';
|
||||
import { ObjectRoomMapUpdateMessage } from '../messages';
|
||||
import { RoomPlaneParser } from '../object/RoomPlaneParser';
|
||||
import { RoomEngine } from '../RoomEngine';
|
||||
import { LegacyWallGeometry } from '../utils/LegacyWallGeometry';
|
||||
|
||||
export class RoomPreviewer
|
||||
@ -54,11 +54,11 @@ export class RoomPreviewer
|
||||
this.onRoomObjectAdded = this.onRoomObjectAdded.bind(this);
|
||||
this.onRoomInitializedonRoomInitialized = this.onRoomInitializedonRoomInitialized.bind(this);
|
||||
|
||||
if(this.isRoomEngineReady && this._roomEngine.events)
|
||||
if(this.isRoomEngineReady && NitroEventDispatcher)
|
||||
{
|
||||
this._roomEngine.events.addEventListener(RoomEngineObjectEvent.ADDED, this.onRoomObjectAdded);
|
||||
this._roomEngine.events.addEventListener(RoomEngineObjectEvent.CONTENT_UPDATED, this.onRoomObjectAdded);
|
||||
this._roomEngine.events.addEventListener(RoomEngineEvent.INITIALIZED, this.onRoomInitializedonRoomInitialized);
|
||||
NitroEventDispatcher.addEventListener(RoomEngineObjectEvent.ADDED, this.onRoomObjectAdded);
|
||||
NitroEventDispatcher.addEventListener(RoomEngineObjectEvent.CONTENT_UPDATED, this.onRoomObjectAdded);
|
||||
NitroEventDispatcher.addEventListener(RoomEngineEvent.INITIALIZED, this.onRoomInitializedonRoomInitialized);
|
||||
}
|
||||
|
||||
this.createRoomForPreview();
|
||||
@ -68,11 +68,11 @@ export class RoomPreviewer
|
||||
{
|
||||
this.reset(true);
|
||||
|
||||
if(this.isRoomEngineReady && this._roomEngine.events)
|
||||
if(this.isRoomEngineReady && NitroEventDispatcher)
|
||||
{
|
||||
this._roomEngine.events.removeEventListener(RoomEngineObjectEvent.ADDED, this.onRoomObjectAdded);
|
||||
this._roomEngine.events.removeEventListener(RoomEngineObjectEvent.CONTENT_UPDATED, this.onRoomObjectAdded);
|
||||
this._roomEngine.events.removeEventListener(RoomEngineEvent.INITIALIZED, this.onRoomInitializedonRoomInitialized);
|
||||
NitroEventDispatcher.removeEventListener(RoomEngineObjectEvent.ADDED, this.onRoomObjectAdded);
|
||||
NitroEventDispatcher.removeEventListener(RoomEngineObjectEvent.CONTENT_UPDATED, this.onRoomObjectAdded);
|
||||
NitroEventDispatcher.removeEventListener(RoomEngineEvent.INITIALIZED, this.onRoomInitializedonRoomInitialized);
|
||||
}
|
||||
|
||||
if(this._backgroundSprite)
|
||||
@ -845,7 +845,7 @@ export class RoomPreviewer
|
||||
|
||||
public get isRoomEngineReady(): boolean
|
||||
{
|
||||
return (this._roomEngine && this._roomEngine.ready);
|
||||
return true;
|
||||
}
|
||||
|
||||
public get roomId(): number
|
||||
|
@ -1,52 +1,30 @@
|
||||
import { INitroCommunicationManager, IRoomEngine, IRoomHandlerListener, IRoomSession, IRoomSessionManager } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { RoomEngineEvent, RoomSessionEvent } from '../../events';
|
||||
import { ICommunicationManager, IRoomEngine, IRoomHandlerListener, IRoomSession, IRoomSessionManager } from '../../api';
|
||||
import { NitroEventDispatcher, RoomSessionEvent } from '../../events';
|
||||
import { BaseHandler, GenericErrorHandler, PetPackageHandler, PollHandler, RoomChatHandler, RoomDataHandler, RoomDimmerPresetsHandler, RoomPermissionsHandler, RoomPresentHandler, RoomSessionHandler, RoomUsersHandler, WordQuizHandler } from './handler';
|
||||
import { RoomSession } from './RoomSession';
|
||||
|
||||
export class RoomSessionManager extends NitroManager implements IRoomSessionManager, IRoomHandlerListener
|
||||
export class RoomSessionManager implements IRoomSessionManager, IRoomHandlerListener
|
||||
{
|
||||
private _communication: INitroCommunicationManager;
|
||||
private _communication: ICommunicationManager;
|
||||
private _roomEngine: IRoomEngine;
|
||||
|
||||
private _handlers: BaseHandler[];
|
||||
private _sessions: Map<string, IRoomSession>;
|
||||
private _pendingSession: IRoomSession;
|
||||
private _handlers: BaseHandler[] = [];
|
||||
private _sessions: Map<string, IRoomSession> = new Map();
|
||||
private _pendingSession: IRoomSession = null;
|
||||
|
||||
private _sessionStarting: boolean;
|
||||
private _viewerSession: IRoomSession;
|
||||
private _sessionStarting: boolean = false;
|
||||
private _viewerSession: IRoomSession = null;
|
||||
|
||||
constructor(communication: INitroCommunicationManager, roomEngine: IRoomEngine)
|
||||
constructor(communication: ICommunicationManager, roomEngine: IRoomEngine)
|
||||
{
|
||||
super();
|
||||
|
||||
this._communication = communication;
|
||||
this._roomEngine = roomEngine;
|
||||
|
||||
this._handlers = [];
|
||||
this._sessions = new Map();
|
||||
this._pendingSession = null;
|
||||
|
||||
this._sessionStarting = false;
|
||||
this._viewerSession = null;
|
||||
|
||||
this.onRoomEngineEvent = this.onRoomEngineEvent.bind(this);
|
||||
}
|
||||
|
||||
protected onInit(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
this.createHandlers();
|
||||
|
||||
this.processPendingSession();
|
||||
|
||||
this._roomEngine.events.addEventListener(RoomEngineEvent.ENGINE_INITIALIZED, this.onRoomEngineEvent);
|
||||
}
|
||||
|
||||
protected onDispose(): void
|
||||
{
|
||||
this._roomEngine.events.removeEventListener(RoomEngineEvent.ENGINE_INITIALIZED, this.onRoomEngineEvent);
|
||||
|
||||
super.onDispose();
|
||||
}
|
||||
|
||||
private createHandlers(): void
|
||||
@ -82,14 +60,9 @@ export class RoomSessionManager extends NitroManager implements IRoomSessionMana
|
||||
}
|
||||
}
|
||||
|
||||
public onRoomEngineEvent(event: RoomEngineEvent): void
|
||||
{
|
||||
this.processPendingSession();
|
||||
}
|
||||
|
||||
private processPendingSession(): void
|
||||
{
|
||||
if(!this._pendingSession || !this._roomEngine.ready) return;
|
||||
if(!this._pendingSession) return;
|
||||
|
||||
this.addSession(this._pendingSession);
|
||||
|
||||
@ -117,13 +90,6 @@ export class RoomSessionManager extends NitroManager implements IRoomSessionMana
|
||||
|
||||
private addSession(roomSession: IRoomSession): boolean
|
||||
{
|
||||
if(!this._roomEngine.ready)
|
||||
{
|
||||
this._pendingSession = roomSession;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
this._sessionStarting = true;
|
||||
|
||||
if(this._sessions.get(this.getRoomId(roomSession.roomId)))
|
||||
@ -135,7 +101,7 @@ export class RoomSessionManager extends NitroManager implements IRoomSessionMana
|
||||
|
||||
this._sessions.set(this.getRoomId(roomSession.roomId), roomSession);
|
||||
|
||||
this.events.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.CREATED, roomSession));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.CREATED, roomSession));
|
||||
|
||||
this._viewerSession = roomSession;
|
||||
|
||||
@ -157,7 +123,7 @@ export class RoomSessionManager extends NitroManager implements IRoomSessionMana
|
||||
return false;
|
||||
}
|
||||
|
||||
this.events.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.STARTED, session));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.STARTED, session));
|
||||
|
||||
this.setHandlers(session);
|
||||
|
||||
@ -172,7 +138,7 @@ export class RoomSessionManager extends NitroManager implements IRoomSessionMana
|
||||
|
||||
this._sessions.delete(this.getRoomId(id));
|
||||
|
||||
this.events.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.ENDED, session, openLandingView));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.ENDED, session, openLandingView));
|
||||
|
||||
session.dispose();
|
||||
}
|
||||
@ -215,7 +181,7 @@ export class RoomSessionManager extends NitroManager implements IRoomSessionMana
|
||||
return 'hard_coded_room_id';
|
||||
}
|
||||
|
||||
public get communication(): INitroCommunicationManager
|
||||
public get communication(): ICommunicationManager
|
||||
{
|
||||
return this._communication;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Resource, Texture } from '@pixi/core';
|
||||
import { GetAssetManager, IFurnitureData, IFurnitureDataListener, IGroupInformationManager, IMessageComposer, INitroCommunicationManager, INitroEvent, IProductData, IProductDataListener, ISessionDataManager, NitroConfiguration, NoobnessLevelEnum, SecurityLevel } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { MysteryBoxKeysUpdateEvent, NitroSettingsEvent, SessionDataPreferencesEvent, UserNameUpdateEvent } from '../../events';
|
||||
import { GetAssetManager, ICommunicationManager, IFurnitureData, IGroupInformationManager, IMessageComposer, IProductData, ISessionDataManager, NitroConfiguration, NoobnessLevelEnum, SecurityLevel } from '../../api';
|
||||
import { MysteryBoxKeysUpdateEvent, NitroEventDispatcher, NitroSettingsEvent, SessionDataPreferencesEvent, UserNameUpdateEvent } from '../../events';
|
||||
import { Nitro } from '../Nitro';
|
||||
import { AccountSafetyLockStatusChangeMessageEvent, AccountSafetyLockStatusChangeParser, AvailabilityStatusMessageEvent, ChangeUserNameResultMessageEvent, EmailStatusResultEvent, FigureUpdateEvent, GetUserTagsComposer, InClientLinkEvent, MysteryBoxKeysEvent, NoobnessLevelMessageEvent, PetRespectComposer, PetScratchFailedMessageEvent, RoomReadyMessageEvent, RoomUnitChatComposer, UserInfoEvent, UserNameChangeMessageEvent, UserPermissionsEvent, UserRespectComposer, UserTagsMessageEvent } from '../communication';
|
||||
import { HabboWebTools } from '../utils/HabboWebTools';
|
||||
@ -11,9 +10,9 @@ import { BadgeImageManager } from './badge/BadgeImageManager';
|
||||
import { FurnitureDataLoader } from './furniture/FurnitureDataLoader';
|
||||
import { ProductDataLoader } from './product/ProductDataLoader';
|
||||
|
||||
export class SessionDataManager extends NitroManager implements ISessionDataManager
|
||||
export class SessionDataManager implements ISessionDataManager
|
||||
{
|
||||
private _communication: INitroCommunicationManager;
|
||||
private _communication: ICommunicationManager;
|
||||
|
||||
private _userId: number;
|
||||
private _name: string;
|
||||
@ -26,88 +25,56 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
private _canChangeName: boolean;
|
||||
private _safetyLocked: boolean;
|
||||
|
||||
private _ignoredUsersManager: IgnoredUsersManager;
|
||||
private _groupInformationManager: IGroupInformationManager;
|
||||
private _ignoredUsersManager: IgnoredUsersManager = new IgnoredUsersManager(this);
|
||||
private _groupInformationManager: IGroupInformationManager = new GroupInformationManager(this);
|
||||
|
||||
private _clubLevel: number;
|
||||
private _securityLevel: number;
|
||||
private _isAmbassador: boolean;
|
||||
private _noobnessLevel: number;
|
||||
private _isEmailVerified: boolean;
|
||||
private _clubLevel: number = 0;
|
||||
private _securityLevel: number = 0;
|
||||
private _isAmbassador: boolean = false;
|
||||
private _noobnessLevel: number = -1;
|
||||
private _isEmailVerified: boolean = false;
|
||||
|
||||
private _systemOpen: boolean;
|
||||
private _systemShutdown: boolean;
|
||||
private _isAuthenticHabbo: boolean;
|
||||
private _isRoomCameraFollowDisabled: boolean;
|
||||
private _uiFlags: number;
|
||||
private _systemOpen: boolean = false;
|
||||
private _systemShutdown: boolean = false;
|
||||
private _isAuthenticHabbo: boolean = false;
|
||||
private _isRoomCameraFollowDisabled: boolean = false;
|
||||
private _uiFlags: number = 0;
|
||||
|
||||
private _floorItems: Map<number, IFurnitureData>;
|
||||
private _wallItems: Map<number, IFurnitureData>;
|
||||
private _products: Map<string, IProductData>;
|
||||
private _furnitureData: FurnitureDataLoader;
|
||||
private _productData: ProductDataLoader;
|
||||
private _floorItems: Map<number, IFurnitureData> = new Map();
|
||||
private _wallItems: Map<number, IFurnitureData> = new Map();
|
||||
private _products: Map<string, IProductData> = new Map();
|
||||
private _furnitureData: FurnitureDataLoader = new FurnitureDataLoader(this._floorItems, this._wallItems);
|
||||
private _productData: ProductDataLoader = new ProductDataLoader(this._products);
|
||||
private _tags: string[] = [];
|
||||
|
||||
private _furnitureReady: boolean;
|
||||
private _productsReady: boolean;
|
||||
private _furnitureListenersNotified: boolean;
|
||||
private _pendingFurnitureListeners: IFurnitureDataListener[];
|
||||
private _pendingProductListeners: IProductDataListener[];
|
||||
private _tags: string[];
|
||||
private _badgeImageManager: BadgeImageManager = new BadgeImageManager(GetAssetManager(), this);
|
||||
|
||||
private _badgeImageManager: BadgeImageManager;
|
||||
|
||||
constructor(communication: INitroCommunicationManager)
|
||||
constructor(communication: ICommunicationManager)
|
||||
{
|
||||
super();
|
||||
|
||||
this._communication = communication;
|
||||
|
||||
this.resetUserInfo();
|
||||
|
||||
this._ignoredUsersManager = new IgnoredUsersManager(this);
|
||||
this._groupInformationManager = new GroupInformationManager(this);
|
||||
|
||||
this._clubLevel = 0;
|
||||
this._securityLevel = 0;
|
||||
this._isAmbassador = false;
|
||||
this._noobnessLevel = -1;
|
||||
this._isEmailVerified = false;
|
||||
|
||||
this._systemOpen = false;
|
||||
this._systemShutdown = false;
|
||||
this._isAuthenticHabbo = false;
|
||||
this._isRoomCameraFollowDisabled = false;
|
||||
this._uiFlags = 0;
|
||||
|
||||
this._floorItems = new Map();
|
||||
this._wallItems = new Map();
|
||||
this._products = new Map();
|
||||
this._furnitureData = null;
|
||||
|
||||
this._furnitureReady = false;
|
||||
this._productsReady = false;
|
||||
this._furnitureListenersNotified = false;
|
||||
this._pendingFurnitureListeners = [];
|
||||
this._pendingProductListeners = [];
|
||||
this._tags = [];
|
||||
|
||||
this._badgeImageManager = null;
|
||||
|
||||
this.onFurnitureDataReadyEvent = this.onFurnitureDataReadyEvent.bind(this);
|
||||
this.onProductDataReadyEvent = this.onProductDataReadyEvent.bind(this);
|
||||
this.onNitroSettingsEvent = this.onNitroSettingsEvent.bind(this);
|
||||
}
|
||||
|
||||
protected onInit(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
this.loadFurnitureData();
|
||||
this.loadProductData();
|
||||
this.loadBadgeImageManager();
|
||||
await this._furnitureData.init();
|
||||
await this._productData.init();
|
||||
|
||||
(this._ignoredUsersManager && this._ignoredUsersManager.init());
|
||||
(this._groupInformationManager && this._groupInformationManager.init());
|
||||
this._badgeImageManager.init();
|
||||
this._ignoredUsersManager.init();
|
||||
this._groupInformationManager.init();
|
||||
|
||||
this._communication.registerMessageEvent(new FigureUpdateEvent((event: FigureUpdateEvent) =>
|
||||
{
|
||||
this._figure = event.getParser().figure;
|
||||
this._gender = event.getParser().gender;
|
||||
|
||||
HabboWebTools.updateFigure(this._figure);
|
||||
}));
|
||||
|
||||
this._communication.registerMessageEvent(new FigureUpdateEvent(this.onUserFigureEvent.bind(this)));
|
||||
this._communication.registerMessageEvent(new UserInfoEvent(this.onUserInfoEvent.bind(this)));
|
||||
this._communication.registerMessageEvent(new UserPermissionsEvent(this.onUserPermissionsEvent.bind(this)));
|
||||
this._communication.registerMessageEvent(new AvailabilityStatusMessageEvent(this.onAvailabilityStatusMessageEvent.bind(this)));
|
||||
@ -122,30 +89,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
this._communication.registerMessageEvent(new AccountSafetyLockStatusChangeMessageEvent(this.onAccountSafetyLockStatusChangeMessageEvent.bind(this)));
|
||||
this._communication.registerMessageEvent(new EmailStatusResultEvent(this.onEmailStatus.bind(this)));
|
||||
|
||||
Nitro.instance.events.addEventListener(NitroSettingsEvent.SETTINGS_UPDATED, this.onNitroSettingsEvent);
|
||||
}
|
||||
|
||||
protected onDispose(): void
|
||||
{
|
||||
this.destroyFurnitureData();
|
||||
|
||||
if(this._ignoredUsersManager)
|
||||
{
|
||||
this._ignoredUsersManager.dispose();
|
||||
|
||||
this._ignoredUsersManager = null;
|
||||
}
|
||||
|
||||
if(this._groupInformationManager)
|
||||
{
|
||||
this._groupInformationManager.dispose();
|
||||
|
||||
this._groupInformationManager = null;
|
||||
}
|
||||
|
||||
Nitro.instance.events.removeEventListener(NitroSettingsEvent.SETTINGS_UPDATED, this.onNitroSettingsEvent);
|
||||
|
||||
super.onDispose();
|
||||
NitroEventDispatcher.addEventListener(NitroSettingsEvent.SETTINGS_UPDATED, this.onNitroSettingsEvent);
|
||||
}
|
||||
|
||||
private resetUserInfo(): void
|
||||
@ -159,92 +103,9 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
this._safetyLocked = false;
|
||||
}
|
||||
|
||||
private loadFurnitureData(): void
|
||||
public getAllFurnitureData(): IFurnitureData[]
|
||||
{
|
||||
this.destroyFurnitureData();
|
||||
|
||||
this._furnitureData = new FurnitureDataLoader(this._floorItems, this._wallItems, Nitro.instance.localization);
|
||||
|
||||
this._furnitureData.addEventListener(FurnitureDataLoader.FURNITURE_DATA_READY, this.onFurnitureDataReadyEvent);
|
||||
|
||||
this._furnitureData.loadFurnitureData(NitroConfiguration.getValue<string>('furnidata.url'));
|
||||
}
|
||||
|
||||
private loadProductData(): void
|
||||
{
|
||||
this.destroyProductData();
|
||||
|
||||
this._productData = new ProductDataLoader(this._products);
|
||||
|
||||
this._productData.addEventListener(ProductDataLoader.PDP_PRODUCT_DATA_READY, this.onProductDataReadyEvent);
|
||||
|
||||
this._productData.loadProductData(NitroConfiguration.getValue<string>('productdata.url'));
|
||||
}
|
||||
|
||||
private loadBadgeImageManager(): void
|
||||
{
|
||||
if(this._badgeImageManager) return;
|
||||
|
||||
this._badgeImageManager = new BadgeImageManager(GetAssetManager(), this);
|
||||
this._badgeImageManager.init();
|
||||
}
|
||||
|
||||
public hasProductData(listener: IProductDataListener): boolean
|
||||
{
|
||||
if(this._productsReady) return true;
|
||||
|
||||
if(listener && (this._pendingProductListeners.indexOf(listener) === -1)) this._pendingProductListeners.push(listener);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public getAllFurnitureData(listener: IFurnitureDataListener): IFurnitureData[]
|
||||
{
|
||||
if(!this._furnitureReady)
|
||||
{
|
||||
if(this._pendingFurnitureListeners.indexOf(listener) === -1) this._pendingFurnitureListeners.push(listener);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const furnitureData: IFurnitureData[] = [];
|
||||
|
||||
for(const data of this._floorItems.values())
|
||||
{
|
||||
if(!data) continue;
|
||||
|
||||
furnitureData.push(data);
|
||||
}
|
||||
|
||||
for(const data of this._wallItems.values())
|
||||
{
|
||||
if(!data) continue;
|
||||
|
||||
furnitureData.push(data);
|
||||
}
|
||||
|
||||
return furnitureData;
|
||||
}
|
||||
|
||||
public removePendingFurniDataListener(listener: IFurnitureDataListener): void
|
||||
{
|
||||
if(!this._pendingFurnitureListeners) return;
|
||||
|
||||
const index = this._pendingFurnitureListeners.indexOf(listener);
|
||||
|
||||
if(index === -1) return;
|
||||
|
||||
this._pendingFurnitureListeners.splice(index, 1);
|
||||
}
|
||||
|
||||
private onUserFigureEvent(event: FigureUpdateEvent): void
|
||||
{
|
||||
if(!event || !event.connection) return;
|
||||
|
||||
this._figure = event.getParser().figure;
|
||||
this._gender = event.getParser().gender;
|
||||
|
||||
HabboWebTools.updateFigure(this._figure);
|
||||
return [ ...Array.from(this._floorItems.values()), ...Array.from(this._wallItems.values()) ];
|
||||
}
|
||||
|
||||
private onUserInfoEvent(event: UserInfoEvent): void
|
||||
@ -268,7 +129,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
this._canChangeName = userInfo.canChangeName;
|
||||
this._safetyLocked = userInfo.safetyLocked;
|
||||
|
||||
(this._ignoredUsersManager && this._ignoredUsersManager.requestIgnoredUsers());
|
||||
this._ignoredUsersManager.requestIgnoredUsers();
|
||||
}
|
||||
|
||||
private onUserPermissionsEvent(event: UserPermissionsEvent): void
|
||||
@ -312,7 +173,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
|
||||
this._canChangeName = false;
|
||||
|
||||
this.events.dispatchEvent(new UserNameUpdateEvent(parser.name));
|
||||
NitroEventDispatcher.dispatchEvent(new UserNameUpdateEvent(parser.name));
|
||||
}
|
||||
|
||||
private onUserNameChangeMessageEvent(event: UserNameChangeMessageEvent): void
|
||||
@ -328,7 +189,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
this._name = parser.newName;
|
||||
this._canChangeName = false;
|
||||
|
||||
this.events.dispatchEvent(new UserNameUpdateEvent(this._name));
|
||||
NitroEventDispatcher.dispatchEvent(new UserNameUpdateEvent(this._name));
|
||||
}
|
||||
|
||||
private onUserTags(event: UserTagsMessageEvent): void
|
||||
@ -353,36 +214,6 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
HabboWebTools.roomVisited(parser.roomId);
|
||||
}
|
||||
|
||||
private onFurnitureDataReadyEvent(event: INitroEvent): void
|
||||
{
|
||||
this._furnitureData.removeEventListener(FurnitureDataLoader.FURNITURE_DATA_READY, this.onFurnitureDataReadyEvent);
|
||||
|
||||
this._furnitureReady = true;
|
||||
|
||||
if(!this._furnitureListenersNotified)
|
||||
{
|
||||
this._furnitureListenersNotified = true;
|
||||
|
||||
if(this._pendingFurnitureListeners && this._pendingFurnitureListeners.length)
|
||||
{
|
||||
for(const listener of this._pendingFurnitureListeners) listener && listener.loadFurnitureData();
|
||||
}
|
||||
}
|
||||
|
||||
this._pendingProductListeners = [];
|
||||
}
|
||||
|
||||
private onProductDataReadyEvent(event: INitroEvent): void
|
||||
{
|
||||
this._productData.removeEventListener(ProductDataLoader.PDP_PRODUCT_DATA_READY, this.onProductDataReadyEvent);
|
||||
|
||||
this._productsReady = true;
|
||||
|
||||
for(const listener of this._pendingProductListeners) listener && listener.loadProductData();
|
||||
|
||||
this._pendingProductListeners = [];
|
||||
}
|
||||
|
||||
private onInClientLinkEvent(event: InClientLinkEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
@ -402,17 +233,14 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
this.events.dispatchEvent(new MysteryBoxKeysUpdateEvent(parser.boxColor, parser.keyColor));
|
||||
NitroEventDispatcher.dispatchEvent(new MysteryBoxKeysUpdateEvent(parser.boxColor, parser.keyColor));
|
||||
}
|
||||
|
||||
private onNoobnessLevelMessageEvent(event: NoobnessLevelMessageEvent): void
|
||||
{
|
||||
this._noobnessLevel = event.getParser().noobnessLevel;
|
||||
|
||||
if(this._noobnessLevel !== NoobnessLevelEnum.OLD_IDENTITY)
|
||||
{
|
||||
NitroConfiguration.setValue<number>('new.identity', 1);
|
||||
}
|
||||
if(this._noobnessLevel !== NoobnessLevelEnum.OLD_IDENTITY) NitroConfiguration.setValue<number>('new.identity', 1);
|
||||
}
|
||||
|
||||
private onAccountSafetyLockStatusChangeMessageEvent(event: AccountSafetyLockStatusChangeMessageEvent): void
|
||||
@ -423,18 +251,12 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
this._safetyLocked = (parser.status == AccountSafetyLockStatusChangeParser.SAFETY_LOCK_STATUS_LOCKED);
|
||||
this._safetyLocked = (parser.status === AccountSafetyLockStatusChangeParser.SAFETY_LOCK_STATUS_LOCKED);
|
||||
}
|
||||
|
||||
private onEmailStatus(event: EmailStatusResultEvent): void
|
||||
{
|
||||
if(!event) return;
|
||||
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
this._isEmailVerified = parser.isVerified;
|
||||
this._isEmailVerified = event?.getParser()?.isVerified ?? false;
|
||||
}
|
||||
|
||||
private onNitroSettingsEvent(event: NitroSettingsEvent): void
|
||||
@ -442,25 +264,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
this._isRoomCameraFollowDisabled = event.cameraFollow;
|
||||
this._uiFlags = event.flags;
|
||||
|
||||
this.events.dispatchEvent(new SessionDataPreferencesEvent(this._uiFlags));
|
||||
}
|
||||
|
||||
private destroyFurnitureData(): void
|
||||
{
|
||||
if(!this._furnitureData) return;
|
||||
|
||||
this._furnitureData.dispose();
|
||||
|
||||
this._furnitureData = null;
|
||||
}
|
||||
|
||||
private destroyProductData(): void
|
||||
{
|
||||
if(!this._productData) return;
|
||||
|
||||
this._productData.dispose();
|
||||
|
||||
this._productData = null;
|
||||
NitroEventDispatcher.dispatchEvent(new SessionDataPreferencesEvent(this._uiFlags));
|
||||
}
|
||||
|
||||
public getFloorItemData(id: number): IFurnitureData
|
||||
@ -482,6 +286,8 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public getWallItemData(id: number): IFurnitureData
|
||||
@ -503,12 +309,12 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public getProductData(type: string): IProductData
|
||||
{
|
||||
if(!this._productsReady) this.loadProductData();
|
||||
|
||||
return this._products.get(type);
|
||||
}
|
||||
|
||||
@ -551,7 +357,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
|
||||
public hasSecurity(level: number): boolean
|
||||
{
|
||||
return this._securityLevel >= level;
|
||||
return (this._securityLevel >= level);
|
||||
}
|
||||
|
||||
public giveRespect(userId: number): void
|
||||
@ -579,22 +385,22 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
|
||||
public ignoreUser(name: string): void
|
||||
{
|
||||
(this._ignoredUsersManager && this._ignoredUsersManager.ignoreUser(name));
|
||||
this._ignoredUsersManager.ignoreUser(name);
|
||||
}
|
||||
|
||||
public unignoreUser(name: string): void
|
||||
{
|
||||
(this._ignoredUsersManager && this._ignoredUsersManager.unignoreUser(name));
|
||||
this._ignoredUsersManager.unignoreUser(name);
|
||||
}
|
||||
|
||||
public isUserIgnored(name: string): boolean
|
||||
{
|
||||
return (this._ignoredUsersManager && this._ignoredUsersManager.isIgnored(name));
|
||||
return this._ignoredUsersManager.isIgnored(name);
|
||||
}
|
||||
|
||||
public getGroupBadge(groupId: number): string
|
||||
{
|
||||
return (this._groupInformationManager && this._groupInformationManager.getGroupBadge(groupId));
|
||||
return this._groupInformationManager.getGroupBadge(groupId);
|
||||
}
|
||||
|
||||
public send(composer: IMessageComposer<unknown[]>): void
|
||||
@ -602,7 +408,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
|
||||
this._communication.connection.send(composer);
|
||||
}
|
||||
|
||||
public get communication(): INitroCommunicationManager
|
||||
public get communication(): ICommunicationManager
|
||||
{
|
||||
return this._communication;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Resource, Texture } from '@pixi/core';
|
||||
import { IAssetManager, IDisposable, IMessageEvent, NitroConfiguration } from '../../../api';
|
||||
import { BadgeImageReadyEvent } from '../../../events';
|
||||
import { BadgeImageReadyEvent, NitroEventDispatcher } from '../../../events';
|
||||
import { NitroContainer, NitroSprite, NitroTexture, TextureUtils } from '../../../pixi-proxy';
|
||||
import { GroupBadgePartsEvent } from '../../communication';
|
||||
import { SessionDataManager } from './../SessionDataManager';
|
||||
@ -116,7 +116,7 @@ export class BadgeImageManager implements IDisposable
|
||||
|
||||
const texture = this._assets.getTexture(url);
|
||||
|
||||
if(texture && this._sessionDataManager) this._sessionDataManager.events.dispatchEvent(new BadgeImageReadyEvent(badgeName, texture.clone()));
|
||||
if(texture && this._sessionDataManager) NitroEventDispatcher.dispatchEvent(new BadgeImageReadyEvent(badgeName, texture.clone()));
|
||||
})
|
||||
.catch(err =>
|
||||
{
|
||||
@ -230,7 +230,7 @@ export class BadgeImageManager implements IDisposable
|
||||
const texture = TextureUtils.generateTexture(container);
|
||||
this._assets.setTexture(groupBadge.code, texture);
|
||||
|
||||
if(this._sessionDataManager) this._sessionDataManager.events.dispatchEvent(new BadgeImageReadyEvent(groupBadge.code, texture));
|
||||
if(this._sessionDataManager) NitroEventDispatcher.dispatchEvent(new BadgeImageReadyEvent(groupBadge.code, texture));
|
||||
}
|
||||
|
||||
private onGroupBadgePartsEvent(event: GroupBadgePartsEvent): void
|
||||
|
@ -1,56 +1,33 @@
|
||||
import { FurnitureType, IFurnitureData, INitroLocalizationManager, NitroLogger } from '../../../api';
|
||||
import { EventDispatcher } from '../../../common';
|
||||
import { NitroEvent } from '../../../events';
|
||||
import { FurnitureType, IFurnitureData, NitroConfiguration } from '../../../api';
|
||||
import { Nitro } from '../../Nitro';
|
||||
import { FurnitureData } from './FurnitureData';
|
||||
|
||||
export class FurnitureDataLoader extends EventDispatcher
|
||||
export class FurnitureDataLoader
|
||||
{
|
||||
public static FURNITURE_DATA_READY: string = 'FDP_FURNITURE_DATA_READY';
|
||||
public static FURNITURE_DATA_ERROR: string = 'FDP_FURNITURE_DATA_ERROR';
|
||||
|
||||
private _floorItems: Map<number, IFurnitureData>;
|
||||
private _wallItems: Map<number, IFurnitureData>;
|
||||
private _localization: INitroLocalizationManager;
|
||||
|
||||
constructor(floorItems: Map<number, IFurnitureData>, wallItems: Map<number, IFurnitureData>, localization: INitroLocalizationManager)
|
||||
constructor(floorItems: Map<number, IFurnitureData>, wallItems: Map<number, IFurnitureData>)
|
||||
{
|
||||
super();
|
||||
|
||||
this._floorItems = floorItems;
|
||||
this._wallItems = wallItems;
|
||||
this._localization = localization;
|
||||
}
|
||||
|
||||
public loadFurnitureData(url: string): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
if(!url) return;
|
||||
const url = NitroConfiguration.getValue<string>('furnidata.url');
|
||||
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => this.onFurnitureDataLoaded(data))
|
||||
.catch(err => this.onFurnitureDataError(err));
|
||||
}
|
||||
if(!url || !url.length) throw new Error('invalid furni data url');
|
||||
|
||||
private onFurnitureDataLoaded(data: { [index: string]: any }): void
|
||||
{
|
||||
if(!data) return;
|
||||
const response = await fetch(url);
|
||||
|
||||
if((typeof data.roomitemtypes == 'undefined') || (typeof data.wallitemtypes == 'undefined')) NitroLogger.warn('Could not find `roomitemtypes` or `wallitemtypes` in furnidata.');
|
||||
if(response.status !== 200) throw new Error('Invalid furni data file');
|
||||
|
||||
if(data.roomitemtypes) this.parseFloorItems(data.roomitemtypes);
|
||||
const responseData = await response.json();
|
||||
|
||||
if(data.wallitemtypes) this.parseWallItems(data.wallitemtypes);
|
||||
if(responseData.roomitemtypes) this.parseFloorItems(responseData.roomitemtypes);
|
||||
|
||||
this.dispatchEvent(new NitroEvent(FurnitureDataLoader.FURNITURE_DATA_READY));
|
||||
}
|
||||
|
||||
private onFurnitureDataError(error: Error): void
|
||||
{
|
||||
if(!error) return;
|
||||
|
||||
NitroLogger.error(error);
|
||||
|
||||
this.dispatchEvent(new NitroEvent(FurnitureDataLoader.FURNITURE_DATA_ERROR));
|
||||
if(responseData.wallitemtypes) this.parseWallItems(responseData.wallitemtypes);
|
||||
}
|
||||
|
||||
private parseFloorItems(data: any): void
|
||||
@ -113,17 +90,15 @@ export class FurnitureDataLoader extends EventDispatcher
|
||||
|
||||
private updateLocalizations(furniture: FurnitureData): void
|
||||
{
|
||||
if(!this._localization) return;
|
||||
|
||||
switch(furniture.type)
|
||||
{
|
||||
case FurnitureType.FLOOR:
|
||||
this._localization.setValue(('roomItem.name.' + furniture.id), furniture.name);
|
||||
this._localization.setValue(('roomItem.desc.' + furniture.id), furniture.description);
|
||||
Nitro.instance.localization.setValue(('roomItem.name.' + furniture.id), furniture.name);
|
||||
Nitro.instance.localization.setValue(('roomItem.desc.' + furniture.id), furniture.description);
|
||||
return;
|
||||
case FurnitureType.WALL:
|
||||
this._localization.setValue(('wallItem.name.' + furniture.id), furniture.name);
|
||||
this._localization.setValue(('wallItem.desc.' + furniture.id), furniture.description);
|
||||
Nitro.instance.localization.setValue(('wallItem.name.' + furniture.id), furniture.name);
|
||||
Nitro.instance.localization.setValue(('wallItem.desc.' + furniture.id), furniture.description);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { GenericErrorEnum, IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionErrorMessageEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionErrorMessageEvent } from '../../../events';
|
||||
import { GenericErrorEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
@ -37,6 +37,6 @@ export class GenericErrorHandler extends BaseHandler
|
||||
|
||||
if(!type || type.length == 0) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionErrorMessageEvent(type, roomSession));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionErrorMessageEvent(type, roomSession));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionPetPackageEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionPetPackageEvent } from '../../../events';
|
||||
import { OpenPetPackageRequestedMessageEvent, OpenPetPackageResultMessageEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
@ -25,7 +25,7 @@ export class PetPackageHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetPackageEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_REQUESTED, session, parser.objectId, parser.figureData, 0, null));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetPackageEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_REQUESTED, session, parser.objectId, parser.figureData, 0, null));
|
||||
}
|
||||
|
||||
private onOpenPetPackageResult(event: OpenPetPackageResultMessageEvent): void
|
||||
@ -40,6 +40,6 @@ export class PetPackageHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetPackageEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_RESULT, session, parser.objectId, null, parser.nameValidationStatus, parser.nameValidationInfo));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetPackageEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_RESULT, session, parser.objectId, null, parser.nameValidationStatus, parser.nameValidationInfo));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionPollEvent, RoomSessionVoteEvent } from '../../../events';
|
||||
import { PollContentsEvent, PollErrorEvent, PollOfferEvent, StartRoomPollEvent, RoomPollResultEvent } from '../../communication';
|
||||
import { NitroEventDispatcher, RoomSessionPollEvent, RoomSessionVoteEvent } from '../../../events';
|
||||
import { PollContentsEvent, PollErrorEvent, PollOfferEvent, RoomPollResultEvent, StartRoomPollEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
export class PollHandler extends BaseHandler
|
||||
@ -36,7 +36,7 @@ export class PollHandler extends BaseHandler
|
||||
pollEvent.questionArray = parser.questionArray;
|
||||
pollEvent.npsPoll = parser.npsPoll;
|
||||
|
||||
this.listener.events.dispatchEvent(pollEvent);
|
||||
NitroEventDispatcher.dispatchEvent(pollEvent);
|
||||
}
|
||||
|
||||
private onPollOfferEvent(event: PollOfferEvent): void
|
||||
@ -56,7 +56,7 @@ export class PollHandler extends BaseHandler
|
||||
pollEvent.summary = parser.headline;
|
||||
pollEvent.summary = parser.summary;
|
||||
|
||||
this.listener.events.dispatchEvent(pollEvent);
|
||||
NitroEventDispatcher.dispatchEvent(pollEvent);
|
||||
}
|
||||
|
||||
private onPollErrorEvent(event: PollErrorEvent): void
|
||||
@ -75,7 +75,7 @@ export class PollHandler extends BaseHandler
|
||||
pollEvent.headline = '???';
|
||||
pollEvent.summary = '???';
|
||||
|
||||
this.listener.events.dispatchEvent(pollEvent);
|
||||
NitroEventDispatcher.dispatchEvent(pollEvent);
|
||||
}
|
||||
|
||||
private onStartRoomPollEvent(event: StartRoomPollEvent): void
|
||||
@ -92,7 +92,7 @@ export class PollHandler extends BaseHandler
|
||||
|
||||
const pollEvent = new RoomSessionVoteEvent(RoomSessionVoteEvent.VOTE_QUESTION, session, parser.question, parser.choices);
|
||||
|
||||
this.listener.events.dispatchEvent(pollEvent);
|
||||
NitroEventDispatcher.dispatchEvent(pollEvent);
|
||||
}
|
||||
|
||||
private onRoomPollResultEvent(event: RoomPollResultEvent): void
|
||||
@ -109,6 +109,6 @@ export class PollHandler extends BaseHandler
|
||||
|
||||
const pollEvent = new RoomSessionVoteEvent(RoomSessionVoteEvent.VOTE_RESULT, session, parser.question, parser.choices, parser.SafeStr_7651, parser.SafeStr_7654);
|
||||
|
||||
this.listener.events.dispatchEvent(pollEvent);
|
||||
NitroEventDispatcher.dispatchEvent(pollEvent);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IConnection, IRoomHandlerListener, SystemChatStyleEnum } from '../../../api';
|
||||
import { RoomSessionChatEvent } from '../../../events';
|
||||
import { FloodControlEvent, PetRespectNoficationEvent, PetSupplementedNotificationEvent, PetSupplementTypeEnum, RemainingMuteEvent, RespectReceivedEvent, RoomUnitChatEvent, RoomUnitChatShoutEvent, RoomUnitChatWhisperEvent, RoomUnitHandItemReceivedEvent } from '../../communication';
|
||||
import { NitroEventDispatcher, RoomSessionChatEvent } from '../../../events';
|
||||
import { FloodControlEvent, PetRespectNoficationEvent, PetSupplementTypeEnum, PetSupplementedNotificationEvent, RemainingMuteEvent, RespectReceivedEvent, RoomUnitChatEvent, RoomUnitChatShoutEvent, RoomUnitChatWhisperEvent, RoomUnitHandItemReceivedEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
export class RoomChatHandler extends BaseHandler
|
||||
@ -39,7 +39,7 @@ export class RoomChatHandler extends BaseHandler
|
||||
|
||||
const chatEvent = new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, parser.roomIndex, parser.message, chatType, parser.bubble);
|
||||
|
||||
this.listener.events.dispatchEvent(chatEvent);
|
||||
NitroEventDispatcher.dispatchEvent(chatEvent);
|
||||
}
|
||||
|
||||
private onRoomUnitHandItemReceivedEvent(event: RoomUnitHandItemReceivedEvent): void
|
||||
@ -54,7 +54,7 @@ export class RoomChatHandler extends BaseHandler
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, parser.giverUserId, '', RoomSessionChatEvent.CHAT_TYPE_HAND_ITEM_RECEIVED, SystemChatStyleEnum.GENERIC, null, parser.handItemType));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, parser.giverUserId, '', RoomSessionChatEvent.CHAT_TYPE_HAND_ITEM_RECEIVED, SystemChatStyleEnum.GENERIC, null, parser.handItemType));
|
||||
}
|
||||
|
||||
private onRespectReceivedEvent(event: RespectReceivedEvent): void
|
||||
@ -73,7 +73,7 @@ export class RoomChatHandler extends BaseHandler
|
||||
|
||||
if(!userData) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, userData.roomIndex, '', RoomSessionChatEvent.CHAT_TYPE_RESPECT, SystemChatStyleEnum.GENERIC));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, userData.roomIndex, '', RoomSessionChatEvent.CHAT_TYPE_RESPECT, SystemChatStyleEnum.GENERIC));
|
||||
}
|
||||
|
||||
private onPetRespectNoficationEvent(event: PetRespectNoficationEvent): void
|
||||
@ -96,7 +96,7 @@ export class RoomChatHandler extends BaseHandler
|
||||
|
||||
if(parser.isTreat) chatType = RoomSessionChatEvent.CHAT_TYPE_PETTREAT;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, petData.roomIndex, '', chatType, SystemChatStyleEnum.GENERIC));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, petData.roomIndex, '', chatType, SystemChatStyleEnum.GENERIC));
|
||||
}
|
||||
|
||||
private onPetSupplementedNotificationEvent(event: PetSupplementedNotificationEvent): void
|
||||
@ -136,7 +136,7 @@ export class RoomChatHandler extends BaseHandler
|
||||
break;
|
||||
}
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, petData.roomIndex, '', chatType, SystemChatStyleEnum.GENERIC, null, userRoomIndex));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, petData.roomIndex, '', chatType, SystemChatStyleEnum.GENERIC, null, userRoomIndex));
|
||||
}
|
||||
|
||||
private onFloodControlEvent(event: FloodControlEvent): void
|
||||
@ -153,7 +153,7 @@ export class RoomChatHandler extends BaseHandler
|
||||
|
||||
const seconds = parser.seconds;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.FLOOD_EVENT, session, -1, seconds.toString(), 0, 0));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.FLOOD_EVENT, session, -1, seconds.toString(), 0, 0));
|
||||
}
|
||||
|
||||
private onRemainingMuteEvent(event: RemainingMuteEvent): void
|
||||
@ -168,6 +168,6 @@ export class RoomChatHandler extends BaseHandler
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, session.ownRoomIndex, '', RoomSessionChatEvent.CHAT_TYPE_MUTE_REMAINING, SystemChatStyleEnum.GENERIC, null, parser.seconds));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, session.ownRoomIndex, '', RoomSessionChatEvent.CHAT_TYPE_MUTE_REMAINING, SystemChatStyleEnum.GENERIC, null, parser.seconds));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionEvent, RoomSessionPropertyUpdateEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionEvent, RoomSessionPropertyUpdateEvent } from '../../../events';
|
||||
import { GetGuestRoomResultEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
@ -34,7 +34,7 @@ export class RoomDataHandler extends BaseHandler
|
||||
roomSession.allowPets = roomData.allowPets;
|
||||
roomSession.moderationSettings = parser.moderation;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPropertyUpdateEvent(RoomSessionPropertyUpdateEvent.RSDUE_ALLOW_PETS, roomSession));
|
||||
this.listener.events.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.ROOM_DATA, roomSession));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPropertyUpdateEvent(RoomSessionPropertyUpdateEvent.RSDUE_ALLOW_PETS, roomSession));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionEvent(RoomSessionEvent.ROOM_DATA, roomSession));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionDimmerPresetsEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionDimmerPresetsEvent } from '../../../events';
|
||||
import { RoomDimmerPresetsEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
@ -39,6 +39,6 @@ export class RoomDimmerPresetsHandler extends BaseHandler
|
||||
i++;
|
||||
}
|
||||
|
||||
this.listener && this.listener.events.dispatchEvent(presetEvent);
|
||||
NitroEventDispatcher.dispatchEvent(presetEvent);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionPresentEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionPresentEvent } from '../../../events';
|
||||
import { PresentOpenedMessageEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
@ -26,9 +26,7 @@ export class RoomPresentHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
if(this.listener && this.listener.events) this.listener.events.dispatchEvent(
|
||||
new RoomSessionPresentEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, session, parser.classId, parser.itemType,
|
||||
parser.productCode, parser.placedItemId, parser.placedItemType, parser.placedInRoom, parser.petFigureString));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPresentEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, session, parser.classId, parser.itemType, parser.productCode, parser.placedItemId, parser.placedItemType, parser.placedInRoom, parser.petFigureString));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionDoorbellEvent, RoomSessionSpectatorModeEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionDoorbellEvent, RoomSessionSpectatorModeEvent } from '../../../events';
|
||||
import { DesktopViewEvent, FlatAccessDeniedMessageEvent, GoToFlatMessageComposer, RoomDoorbellAcceptedEvent, RoomEnterEvent, RoomReadyMessageEvent, YouAreSpectatorMessageEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
@ -65,14 +65,11 @@ export class RoomSessionHandler extends BaseHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.listener.events)
|
||||
{
|
||||
const session = this.listener.getSession(this.roomId);
|
||||
const session = this.listener.getSession(this.roomId);
|
||||
|
||||
if(!session) return;
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, session, username));
|
||||
}
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, session, username));
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,14 +89,11 @@ export class RoomSessionHandler extends BaseHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.listener.events)
|
||||
{
|
||||
const session = this.listener.getSession(this.roomId);
|
||||
const session = this.listener.getSession(this.roomId);
|
||||
|
||||
if(!session) return;
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, session, username));
|
||||
}
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, session, username));
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +106,7 @@ export class RoomSessionHandler extends BaseHandler
|
||||
if(!session) return;
|
||||
|
||||
session.isSpectator = true;
|
||||
this.listener.events.dispatchEvent(new RoomSessionSpectatorModeEvent(RoomSessionSpectatorModeEvent.SPECTATOR_MODE, session));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionSpectatorModeEvent(RoomSessionSpectatorModeEvent.SPECTATOR_MODE, session));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IConnection, IRoomHandlerListener, IRoomUserData } from '../../../api';
|
||||
import { RoomSessionConfirmPetBreedingEvent, RoomSessionConfirmPetBreedingResultEvent, RoomSessionDanceEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionFriendRequestEvent, RoomSessionNestBreedingSuccessEvent, RoomSessionPetBreedingEvent, RoomSessionPetBreedingResultEvent, RoomSessionPetFigureUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetLevelUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserDataUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionConfirmPetBreedingEvent, RoomSessionConfirmPetBreedingResultEvent, RoomSessionDanceEvent, RoomSessionDoorbellEvent, RoomSessionErrorMessageEvent, RoomSessionFavoriteGroupUpdateEvent, RoomSessionFriendRequestEvent, RoomSessionNestBreedingSuccessEvent, RoomSessionPetBreedingEvent, RoomSessionPetBreedingResultEvent, RoomSessionPetFigureUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionPetLevelUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserDataUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../../../events';
|
||||
import { BotErrorEvent, ConfirmBreedingRequestEvent, ConfirmBreedingResultEvent, DoorbellMessageEvent, FavoriteMembershipUpdateMessageEvent, NestBreedingSuccessEvent, NewFriendRequestEvent, PetBreedingMessageEvent, PetBreedingResultEvent, PetFigureUpdateEvent, PetInfoEvent, PetLevelUpdateMessageEvent, PetPlacingErrorEvent, PetStatusUpdateEvent, RoomUnitDanceEvent, RoomUnitEvent, RoomUnitInfoEvent, RoomUnitRemoveEvent, UserCurrentBadgesEvent, UserNameChangeMessageEvent } from '../../communication';
|
||||
import { RoomPetData } from '../RoomPetData';
|
||||
import { RoomUserData } from '../RoomUserData';
|
||||
@ -82,7 +82,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
}
|
||||
}
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionUserDataUpdateEvent(session, usersToAdd));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionUserDataUpdateEvent(session, usersToAdd));
|
||||
}
|
||||
|
||||
private onRoomUnitInfoEvent(event: RoomUnitInfoEvent): void
|
||||
@ -101,7 +101,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
session.userDataManager.updateMotto(parser.unitId, parser.motto);
|
||||
session.userDataManager.updateAchievementScore(parser.unitId, parser.achievementScore);
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionUserFigureUpdateEvent(session, parser.unitId, parser.figure, parser.gender, parser.motto, parser.achievementScore));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionUserFigureUpdateEvent(session, parser.unitId, parser.figure, parser.gender, parser.motto, parser.achievementScore));
|
||||
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionDanceEvent(session, parser.unitId, parser.danceId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionDanceEvent(session, parser.unitId, parser.danceId));
|
||||
}
|
||||
|
||||
private onUserCurrentBadgesEvent(event: UserCurrentBadgesEvent): void
|
||||
@ -145,7 +145,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
session.userDataManager.setUserBadges(parser.userId, parser.badges);
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionUserBadgesEvent(session, parser.userId, parser.badges));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionUserBadgesEvent(session, parser.userId, parser.badges));
|
||||
}
|
||||
|
||||
private onRoomDoorbellEvent(event: DoorbellMessageEvent): void
|
||||
@ -164,7 +164,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.DOORBELL, session, username));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionDoorbellEvent(RoomSessionDoorbellEvent.DOORBELL, session, username));
|
||||
}
|
||||
|
||||
private onUserNameChangeMessageEvent(event: UserNameChangeMessageEvent): void
|
||||
@ -196,7 +196,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
const request = parser.request;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionFriendRequestEvent(session, request.requestId, request.requesterUserId, request.requesterName));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionFriendRequestEvent(session, request.requestId, request.requesterUserId, request.requesterName));
|
||||
}
|
||||
|
||||
private onPetInfoEvent(event: PetInfoEvent): void
|
||||
@ -240,7 +240,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
petData.remainingGrowTime = parser.remainingGrowTime;
|
||||
petData.publiclyBreedable = parser.publiclyBreedable;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetInfoUpdateEvent(session, petData));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetInfoUpdateEvent(session, petData));
|
||||
}
|
||||
|
||||
private onPetStatusUpdateEvent(event: PetStatusUpdateEvent): void
|
||||
@ -257,7 +257,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
session.userDataManager.updatePetBreedingStatus(parser.roomIndex, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission);
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetStatusUpdateEvent(session, parser.petId, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetStatusUpdateEvent(session, parser.petId, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission));
|
||||
}
|
||||
|
||||
private onPetBreedingMessageEvent(event: PetBreedingMessageEvent): void
|
||||
@ -272,7 +272,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetBreedingEvent(session, parser.state, parser.ownPetId, parser.otherPetId));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetBreedingEvent(session, parser.state, parser.ownPetId, parser.otherPetId));
|
||||
}
|
||||
|
||||
private onPetLevelUpdateMessageEvent(event: PetLevelUpdateMessageEvent): void
|
||||
@ -289,7 +289,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
session.userDataManager.updatePetLevel(parser.roomIndex, parser.level);
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetLevelUpdateEvent(session, parser.petId, parser.level));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetLevelUpdateEvent(session, parser.petId, parser.level));
|
||||
}
|
||||
|
||||
private onConfirmBreedingResultEvent(event: ConfirmBreedingResultEvent): void
|
||||
@ -304,7 +304,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionConfirmPetBreedingResultEvent(session, parser.breedingNestStuffId, parser.result));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionConfirmPetBreedingResultEvent(session, parser.breedingNestStuffId, parser.result));
|
||||
}
|
||||
|
||||
private onNestBreedingSuccessEvent(event: NestBreedingSuccessEvent): void
|
||||
@ -319,7 +319,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionNestBreedingSuccessEvent(session, parser.petId, parser.rarityCategory));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionNestBreedingSuccessEvent(session, parser.petId, parser.rarityCategory));
|
||||
}
|
||||
|
||||
private onConfirmBreedingRequestEvent(event: ConfirmBreedingRequestEvent): void
|
||||
@ -334,7 +334,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionConfirmPetBreedingEvent(session, parser.nestId, parser.pet1, parser.pet2, parser.rarityCategories, parser.resultPetType));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionConfirmPetBreedingEvent(session, parser.nestId, parser.pet1, parser.pet2, parser.rarityCategories, parser.resultPetType));
|
||||
}
|
||||
|
||||
private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void
|
||||
@ -353,7 +353,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
session.userDataManager.updateFigure(parser.roomIndex, figure, '', parser.hasSaddle, parser.isRiding);
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetFigureUpdateEvent(session, parser.petId, figure));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetFigureUpdateEvent(session, parser.petId, figure));
|
||||
}
|
||||
|
||||
private onPetBreedingResultEvent(event: PetBreedingResultEvent): void
|
||||
@ -368,7 +368,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetBreedingResultEvent(session, parser.resultData, parser.otherResultData));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionPetBreedingResultEvent(session, parser.resultData, parser.otherResultData));
|
||||
}
|
||||
|
||||
private onPetPlacingError(event: PetPlacingErrorEvent): void
|
||||
@ -411,7 +411,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!type || type.length == 0) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionErrorMessageEvent(type, session));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionErrorMessageEvent(type, session));
|
||||
}
|
||||
|
||||
private onBotError(event: BotErrorEvent): void
|
||||
@ -451,7 +451,7 @@ export class RoomUsersHandler extends BaseHandler
|
||||
|
||||
if(!type || type.length == 0) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionErrorMessageEvent(type, session));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionErrorMessageEvent(type, session));
|
||||
}
|
||||
|
||||
private onFavoriteMembershipUpdateMessageEvent(event: FavoriteMembershipUpdateMessageEvent): void
|
||||
@ -470,6 +470,6 @@ export class RoomUsersHandler extends BaseHandler
|
||||
userData.groupId = parser.groupId;
|
||||
userData.groupName = parser.groupName;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionFavoriteGroupUpdateEvent(session, parser.roomIndex, parser.groupId, parser.status, parser.groupName));
|
||||
NitroEventDispatcher.dispatchEvent(new RoomSessionFavoriteGroupUpdateEvent(session, parser.roomIndex, parser.groupId, parser.status, parser.groupName));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionWordQuizEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomSessionWordQuizEvent } from '../../../events';
|
||||
import { QuestionAnsweredEvent, QuestionEvent, QuestionFinishedEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
@ -34,7 +34,7 @@ export class WordQuizHandler extends BaseHandler
|
||||
quizEvent.questionId = parser.questionId;
|
||||
quizEvent.pollId = parser.pollId;
|
||||
|
||||
this.listener.events.dispatchEvent(quizEvent);
|
||||
NitroEventDispatcher.dispatchEvent(quizEvent);
|
||||
}
|
||||
|
||||
private onQuestionAnsweredEvent(event: QuestionAnsweredEvent): void
|
||||
@ -55,7 +55,7 @@ export class WordQuizHandler extends BaseHandler
|
||||
quizEvent.userId = parser.userId;
|
||||
quizEvent.answerCounts = parser.answerCounts;
|
||||
|
||||
this.listener.events.dispatchEvent(quizEvent);
|
||||
NitroEventDispatcher.dispatchEvent(quizEvent);
|
||||
}
|
||||
|
||||
private onQuestionFinishedEvent(event: QuestionFinishedEvent): void
|
||||
@ -74,6 +74,6 @@ export class WordQuizHandler extends BaseHandler
|
||||
quizEvent.questionId = parser.questionId;
|
||||
quizEvent.answerCounts = parser.answerCounts;
|
||||
|
||||
this.listener.events.dispatchEvent(quizEvent);
|
||||
NitroEventDispatcher.dispatchEvent(quizEvent);
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,28 @@
|
||||
import { IProductData } from '../../../api';
|
||||
import { EventDispatcher } from '../../../common';
|
||||
import { NitroEvent } from '../../../events';
|
||||
import { IProductData, NitroConfiguration } from '../../../api';
|
||||
import { ProductData } from './ProductData';
|
||||
|
||||
export class ProductDataLoader extends EventDispatcher
|
||||
export class ProductDataLoader
|
||||
{
|
||||
public static PDP_PRODUCT_DATA_READY: string = 'PDP_PRODUCT_DATA_READY';
|
||||
public static PDP_PRODUCT_DATA_FAILED: string = 'PDP_PRODUCT_DATA_FAILED';
|
||||
|
||||
private _products: Map<string, IProductData>;
|
||||
|
||||
constructor(products: Map<string, IProductData>)
|
||||
{
|
||||
super();
|
||||
|
||||
this._products = products;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
this._products = null;
|
||||
}
|
||||
const url = NitroConfiguration.getValue<string>('productdata.url');
|
||||
|
||||
public loadProductData(url: string): void
|
||||
{
|
||||
if(!url) return;
|
||||
if(!url || !url.length) throw new Error('invalid product data url');
|
||||
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => this.onProductDataLoadedEvent(data))
|
||||
.catch(err => this.onProductDataError(err));
|
||||
}
|
||||
const response = await fetch(url);
|
||||
|
||||
private onProductDataLoadedEvent(data: { [index: string]: any }): void
|
||||
{
|
||||
if(!data) return;
|
||||
if(response.status !== 200) throw new Error('Invalid product data file');
|
||||
|
||||
this.parseProducts(data.productdata);
|
||||
const responseData = await response.json();
|
||||
|
||||
this.dispatchEvent(new NitroEvent(ProductDataLoader.PDP_PRODUCT_DATA_READY));
|
||||
}
|
||||
|
||||
private onProductDataError(error: Error): void
|
||||
{
|
||||
if(!error) return;
|
||||
|
||||
this.dispatchEvent(new NitroEvent(ProductDataLoader.PDP_PRODUCT_DATA_FAILED));
|
||||
this.parseProducts(responseData.productdata);
|
||||
}
|
||||
|
||||
private parseProducts(data: { [index: string]: any }): void
|
||||
|
@ -1,61 +1,28 @@
|
||||
import { AdvancedMap, IAdvancedMap, IMusicController, INitroEvent, ISoundManager, NitroConfiguration, NitroLogger } from '../../api';
|
||||
import { NitroManager } from '../../common';
|
||||
import { NitroSettingsEvent, NitroSoundEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomEngineSamplePlaybackEvent } from '../../events';
|
||||
import { Nitro } from '../Nitro';
|
||||
import { NitroEventDispatcher, NitroSettingsEvent, NitroSoundEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomEngineSamplePlaybackEvent } from '../../events';
|
||||
import { MusicController } from './music/MusicController';
|
||||
|
||||
export class SoundManager extends NitroManager implements ISoundManager
|
||||
export class SoundManager implements ISoundManager
|
||||
{
|
||||
private _volumeSystem: number;
|
||||
private _volumeFurni: number;
|
||||
private _volumeTrax: number;
|
||||
private _volumeSystem: number = 0.5;
|
||||
private _volumeFurni: number = 0.5;
|
||||
private _volumeTrax: number = 0.5;
|
||||
|
||||
private _internalSamples: IAdvancedMap<string, HTMLAudioElement>;
|
||||
private _furniSamples: IAdvancedMap<number, HTMLAudioElement>;
|
||||
private _furnitureBeingPlayed: IAdvancedMap<number, number>;
|
||||
private _internalSamples: IAdvancedMap<string, HTMLAudioElement> = new AdvancedMap();
|
||||
private _furniSamples: IAdvancedMap<number, HTMLAudioElement> = new AdvancedMap();
|
||||
private _furnitureBeingPlayed: IAdvancedMap<number, number> = new AdvancedMap();
|
||||
|
||||
private _musicController: IMusicController;
|
||||
private _musicController: IMusicController = new MusicController();
|
||||
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
|
||||
this._volumeSystem = 0.5;
|
||||
this._volumeFurni = 0.5;
|
||||
this._volumeTrax = 0.5;
|
||||
|
||||
this._internalSamples = new AdvancedMap();
|
||||
this._furniSamples = new AdvancedMap();
|
||||
this._furnitureBeingPlayed = new AdvancedMap();
|
||||
this._musicController = new MusicController();
|
||||
|
||||
this.onEvent = this.onEvent.bind(this);
|
||||
}
|
||||
|
||||
public onInit(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
this._musicController.init();
|
||||
|
||||
Nitro.instance.roomEngine.events.addEventListener(RoomEngineSamplePlaybackEvent.PLAY_SAMPLE, this.onEvent);
|
||||
Nitro.instance.roomEngine.events.addEventListener(RoomEngineObjectEvent.REMOVED, this.onEvent);
|
||||
Nitro.instance.roomEngine.events.addEventListener(RoomEngineEvent.DISPOSED, this.onEvent);
|
||||
Nitro.instance.events.addEventListener(NitroSettingsEvent.SETTINGS_UPDATED, this.onEvent);
|
||||
Nitro.instance.events.addEventListener(NitroSoundEvent.PLAY_SOUND, this.onEvent);
|
||||
}
|
||||
|
||||
public onDispose(): void
|
||||
{
|
||||
if(this._musicController)
|
||||
{
|
||||
this._musicController.dispose();
|
||||
this._musicController = null;
|
||||
}
|
||||
|
||||
Nitro.instance.roomEngine.events.removeEventListener(RoomEngineSamplePlaybackEvent.PLAY_SAMPLE, this.onEvent);
|
||||
Nitro.instance.roomEngine.events.removeEventListener(RoomEngineObjectEvent.REMOVED, this.onEvent);
|
||||
Nitro.instance.roomEngine.events.removeEventListener(RoomEngineEvent.DISPOSED, this.onEvent);
|
||||
Nitro.instance.events.removeEventListener(NitroSettingsEvent.SETTINGS_UPDATED, this.onEvent);
|
||||
Nitro.instance.events.removeEventListener(NitroSoundEvent.PLAY_SOUND, this.onEvent);
|
||||
NitroEventDispatcher.addEventListener<RoomEngineSamplePlaybackEvent>(RoomEngineSamplePlaybackEvent.PLAY_SAMPLE, event => this.onEvent(event));
|
||||
NitroEventDispatcher.addEventListener<RoomEngineObjectEvent>(RoomEngineObjectEvent.REMOVED, event => this.onEvent(event));
|
||||
NitroEventDispatcher.addEventListener<RoomEngineEvent>(RoomEngineEvent.DISPOSED, event => this.onEvent(event));
|
||||
NitroEventDispatcher.addEventListener<NitroSettingsEvent>(NitroSettingsEvent.SETTINGS_UPDATED, event => this.onEvent(event));
|
||||
NitroEventDispatcher.addEventListener<NitroSoundEvent>(NitroSoundEvent.PLAY_SOUND, event => this.onEvent(event));
|
||||
}
|
||||
|
||||
private onEvent(event: INitroEvent)
|
||||
@ -150,20 +117,11 @@ export class SoundManager extends NitroManager implements ISoundManager
|
||||
|
||||
if(!this._furnitureBeingPlayed.hasKey(objectId)) this._furnitureBeingPlayed.add(objectId, code);
|
||||
|
||||
sample.onended = (event) =>
|
||||
{
|
||||
this.stopFurniSample(objectId);
|
||||
};
|
||||
sample.onended = event => this.stopFurniSample(objectId);
|
||||
|
||||
sample.onpause = (event) =>
|
||||
{
|
||||
this.stopFurniSample(objectId);
|
||||
};
|
||||
sample.onpause = event => this.stopFurniSample(objectId);
|
||||
|
||||
sample.onerror = (event) =>
|
||||
{
|
||||
this.stopFurniSample(objectId);
|
||||
};
|
||||
sample.onerror = event => this.stopFurniSample(objectId);
|
||||
|
||||
this.playSample(sample, this._volumeFurni, pitch);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { IMessageEvent, IPlaylistController, ISongInfo } from '../../../api';
|
||||
import { NitroEventDispatcher } from '../../../events';
|
||||
import { GetJukeboxPlayListMessageComposer, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, NowPlayingMessageEvent } from '../../communication';
|
||||
import { Nitro } from '../../Nitro';
|
||||
import { SongDataEntry } from '../common/SongDataEntry';
|
||||
@ -34,7 +35,7 @@ export class JukeboxPlaylistController implements IPlaylistController
|
||||
{
|
||||
this._messageEvents.forEach(event => Nitro.instance.communication.connection.addMessageEvent(event));
|
||||
//this._events.addEventListener(SoundManagerEvent.TRAX_SONG_COMPLETE, this.onSongFinishedPlayingEvent);
|
||||
Nitro.instance.soundManager.events.addEventListener(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, this.onSongInfoReceivedEvent);
|
||||
NitroEventDispatcher.addEventListener(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, this.onSongInfoReceivedEvent);
|
||||
}
|
||||
|
||||
public get priority(): number
|
||||
@ -62,7 +63,7 @@ export class JukeboxPlaylistController implements IPlaylistController
|
||||
|
||||
this._playPosition = parser.currentPosition;
|
||||
//Dispatch local event NowPlayingEvent
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPE_SONG_CHANGED, MusicPriorities.PRIORITY_ROOM_PLAYLIST, parser.currentSongId, parser.currentPosition));
|
||||
NitroEventDispatcher.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPE_SONG_CHANGED, MusicPriorities.PRIORITY_ROOM_PLAYLIST, parser.currentSongId, parser.currentPosition));
|
||||
}
|
||||
|
||||
private onJukeboxSongDisksMessageEvent(event: JukeboxSongDisksMessageEvent): void
|
||||
@ -89,13 +90,13 @@ export class JukeboxPlaylistController implements IPlaylistController
|
||||
}
|
||||
if(this._missingSongInfo.length == 0)
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new PlayListStatusEvent(PlayListStatusEvent.PLUE_PLAY_LIST_UPDATED));
|
||||
NitroEventDispatcher.dispatchEvent(new PlayListStatusEvent(PlayListStatusEvent.PLUE_PLAY_LIST_UPDATED));
|
||||
}
|
||||
}
|
||||
|
||||
private onJukeboxPlayListFullMessageEvent(event: JukeboxPlayListFullMessageEvent): void
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new PlayListStatusEvent(PlayListStatusEvent.PLUE_PLAY_LIST_FULL));
|
||||
NitroEventDispatcher.dispatchEvent(new PlayListStatusEvent(PlayListStatusEvent.PLUE_PLAY_LIST_FULL));
|
||||
}
|
||||
|
||||
private onSongInfoReceivedEvent(songInfoEvent: SongInfoReceivedEvent): void
|
||||
@ -122,7 +123,7 @@ export class JukeboxPlaylistController implements IPlaylistController
|
||||
}
|
||||
if(this._missingSongInfo.length == 0)
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new PlayListStatusEvent(PlayListStatusEvent.PLUE_PLAY_LIST_UPDATED));
|
||||
NitroEventDispatcher.dispatchEvent(new PlayListStatusEvent(PlayListStatusEvent.PLUE_PLAY_LIST_UPDATED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,9 +184,9 @@ export class JukeboxPlaylistController implements IPlaylistController
|
||||
{
|
||||
this._disposed = true;
|
||||
this.stopPlaying();
|
||||
if(Nitro.instance.soundManager.events)
|
||||
if(Nitro.instance.soundManager)
|
||||
{
|
||||
Nitro.instance.soundManager.events.removeEventListener(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, this.onSongInfoReceivedEvent);
|
||||
NitroEventDispatcher.removeEventListener(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, this.onSongInfoReceivedEvent);
|
||||
}
|
||||
this._messageEvents.forEach(event => Nitro.instance.communication.connection.removeMessageEvent(event));
|
||||
this._messageEvents = null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { AdvancedMap, IAdvancedMap, IMessageEvent, IMusicController, IPlaylistController, ISongInfo } from '../../../api';
|
||||
import { RoomObjectSoundMachineEvent } from '../../../events';
|
||||
import { NitroEventDispatcher, RoomObjectSoundMachineEvent } from '../../../events';
|
||||
import { GetNowPlayingMessageComposer, GetSongInfoMessageComposer, GetUserSongDisksMessageComposer, TraxSongInfoMessageEvent, UserSongDisksInventoryMessageEvent } from '../../communication';
|
||||
import { Nitro } from '../../Nitro';
|
||||
import { SongDataEntry } from '../common/SongDataEntry';
|
||||
@ -67,12 +67,11 @@ export class MusicController implements IMusicController
|
||||
|
||||
this._messageEvents.forEach(event => Nitro.instance.communication.connection.addMessageEvent(event));
|
||||
|
||||
Nitro.instance.roomEngine.events.addEventListener(RoomObjectSoundMachineEvent.JUKEBOX_INIT, this.onJukeboxInit);
|
||||
Nitro.instance.roomEngine.events.addEventListener(RoomObjectSoundMachineEvent.JUKEBOX_DISPOSE, this.onJukeboxDispose);
|
||||
Nitro.instance.roomEngine.events.addEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_INIT, this.onSoundMachineInit);
|
||||
Nitro.instance.roomEngine.events.addEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_DISPOSE, this.onSoundMachineDispose);
|
||||
|
||||
Nitro.instance.soundManager.events.addEventListener(SoundManagerEvent.TRAX_SONG_COMPLETE, this.onTraxSongComplete);
|
||||
NitroEventDispatcher.addEventListener(RoomObjectSoundMachineEvent.JUKEBOX_INIT, this.onJukeboxInit);
|
||||
NitroEventDispatcher.addEventListener(RoomObjectSoundMachineEvent.JUKEBOX_DISPOSE, this.onJukeboxDispose);
|
||||
NitroEventDispatcher.addEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_INIT, this.onSoundMachineInit);
|
||||
NitroEventDispatcher.addEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_DISPOSE, this.onSoundMachineDispose);
|
||||
NitroEventDispatcher.addEventListener(SoundManagerEvent.TRAX_SONG_COMPLETE, this.onTraxSongComplete);
|
||||
}
|
||||
|
||||
public getRoomItemPlaylist(_arg_1?: number): IPlaylistController
|
||||
@ -176,11 +175,11 @@ export class MusicController implements IMusicController
|
||||
|
||||
this._messageEvents.forEach(event => Nitro.instance.communication.connection.removeMessageEvent(event));
|
||||
|
||||
Nitro.instance.roomEngine.events.removeEventListener(RoomObjectSoundMachineEvent.JUKEBOX_INIT, this.onJukeboxInit);
|
||||
Nitro.instance.roomEngine.events.removeEventListener(RoomObjectSoundMachineEvent.JUKEBOX_DISPOSE, this.onJukeboxDispose);
|
||||
Nitro.instance.roomEngine.events.removeEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_INIT, this.onSoundMachineInit);
|
||||
Nitro.instance.roomEngine.events.removeEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_DISPOSE, this.onSoundMachineDispose);
|
||||
Nitro.instance.soundManager.events.removeEventListener(SoundManagerEvent.TRAX_SONG_COMPLETE, this.onTraxSongComplete);
|
||||
NitroEventDispatcher.removeEventListener(RoomObjectSoundMachineEvent.JUKEBOX_INIT, this.onJukeboxInit);
|
||||
NitroEventDispatcher.removeEventListener(RoomObjectSoundMachineEvent.JUKEBOX_DISPOSE, this.onJukeboxDispose);
|
||||
NitroEventDispatcher.removeEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_INIT, this.onSoundMachineInit);
|
||||
NitroEventDispatcher.removeEventListener(RoomObjectSoundMachineEvent.SOUND_MACHINE_DISPOSE, this.onSoundMachineDispose);
|
||||
NitroEventDispatcher.removeEventListener(SoundManagerEvent.TRAX_SONG_COMPLETE, this.onTraxSongComplete);
|
||||
}
|
||||
|
||||
public get samplesIdsInUse(): number[]
|
||||
@ -238,7 +237,7 @@ export class MusicController implements IMusicController
|
||||
this.playSongWithHighestPriority();
|
||||
if(priorityPlaying >= MusicPriorities.PRIORITY_SONG_PLAY)
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPW_USER_STOP_SONG, priorityPlaying, k.id, -1));
|
||||
NitroEventDispatcher.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPW_USER_STOP_SONG, priorityPlaying, k.id, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -268,13 +267,13 @@ export class MusicController implements IMusicController
|
||||
{
|
||||
this.playSongObject(topRequestPriotityIndex, songId);
|
||||
}
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new SongInfoReceivedEvent(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, song.id));
|
||||
NitroEventDispatcher.dispatchEvent(new SongInfoReceivedEvent(SongInfoReceivedEvent.SIR_TRAX_SONG_INFO_RECEIVED, song.id));
|
||||
while(this._diskInventoryMissingData.indexOf(song.id) != -1)
|
||||
{
|
||||
this._diskInventoryMissingData.splice(this._diskInventoryMissingData.indexOf(song.id), 1);
|
||||
if(this._diskInventoryMissingData.length === 0)
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new SongDiskInventoryReceivedEvent(SongDiskInventoryReceivedEvent.SDIR_SONG_DISK_INVENTORY_RECEIVENT_EVENT));
|
||||
NitroEventDispatcher.dispatchEvent(new SongDiskInventoryReceivedEvent(SongDiskInventoryReceivedEvent.SDIR_SONG_DISK_INVENTORY_RECEIVENT_EVENT));
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +300,7 @@ export class MusicController implements IMusicController
|
||||
}
|
||||
if(this._diskInventoryMissingData.length === 0)
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new SongDiskInventoryReceivedEvent(SongDiskInventoryReceivedEvent.SDIR_SONG_DISK_INVENTORY_RECEIVENT_EVENT));
|
||||
NitroEventDispatcher.dispatchEvent(new SongDiskInventoryReceivedEvent(SongDiskInventoryReceivedEvent.SDIR_SONG_DISK_INVENTORY_RECEIVENT_EVENT));
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,7 +429,7 @@ export class MusicController implements IMusicController
|
||||
this._musicPlayer.preloadSamplesForSong(songData.songData).then(() => this._musicPlayer.play(songData.songData, songData.id, startPos, playLength));
|
||||
if(priority > MusicPriorities.PRIORITY_ROOM_PLAYLIST)
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPE_USER_PLAY_SONG, priority, songData.id, -1));
|
||||
NitroEventDispatcher.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPE_USER_PLAY_SONG, priority, songData.id, -1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -441,7 +440,7 @@ export class MusicController implements IMusicController
|
||||
const timeNow = Date.now();
|
||||
if(((k.length >= _local_2) && ((!(this._previousNotifiedSongId == k.id)) || (timeNow > (this._previousNotificationTime + _local_2)))))
|
||||
{
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new NotifyPlayedSongEvent(k.name, k.creator));
|
||||
NitroEventDispatcher.dispatchEvent(new NotifyPlayedSongEvent(k.name, k.creator));
|
||||
this._previousNotifiedSongId = k.id;
|
||||
this._previousNotificationTime = timeNow;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Howl, Howler } from 'howler';
|
||||
import { NitroLogger } from '../../../api';
|
||||
import { Nitro } from '../../Nitro';
|
||||
import { NitroEventDispatcher } from '../../../events';
|
||||
import { SoundManagerEvent } from '../events';
|
||||
import { TraxData } from '../trax/TraxData';
|
||||
|
||||
@ -79,7 +79,7 @@ export class MusicPlayer
|
||||
{
|
||||
const songId = this._currentSongId;
|
||||
this.reset();
|
||||
Nitro.instance.soundManager.events.dispatchEvent(new SoundManagerEvent(SoundManagerEvent.TRAX_SONG_COMPLETE, songId));
|
||||
NitroEventDispatcher.dispatchEvent(new SoundManagerEvent(SoundManagerEvent.TRAX_SONG_COMPLETE, songId));
|
||||
//this.emit('stopped');
|
||||
}
|
||||
|
||||
|
@ -1,79 +1,41 @@
|
||||
import { IGraphicAssetCollection, IRoomContentLoader, IRoomInstance, IRoomInstanceContainer, IRoomManager, IRoomManagerListener, IRoomObject, IRoomObjectController, IRoomObjectLogicFactory, IRoomObjectManager, IRoomObjectVisualizationFactory, NitroLogger } from '../api';
|
||||
import { NitroManager } from '../common';
|
||||
import { RoomContentLoadedEvent } from '../events';
|
||||
import { NitroEventDispatcher, RoomContentLoadedEvent } from '../events';
|
||||
import { RoomContentLoader } from '../nitro/room/RoomContentLoader';
|
||||
import { RoomInstance } from './RoomInstance';
|
||||
import { RoomObjectManager } from './RoomObjectManager';
|
||||
|
||||
export class RoomManager extends NitroManager implements IRoomManager, IRoomInstanceContainer
|
||||
export class RoomManager implements IRoomManager, IRoomInstanceContainer
|
||||
{
|
||||
public static ROOM_MANAGER_ERROR: number = -1;
|
||||
public static ROOM_MANAGER_LOADING: number = 0;
|
||||
public static ROOM_MANAGER_LOADED: number = 1;
|
||||
public static ROOM_MANAGER_INITIALIZING: number = 2;
|
||||
public static ROOM_MANAGER_INITIALIZED: number = 3;
|
||||
private static CONTENT_PROCESSING_TIME_LIMIT_MILLISECONDS: number = 40;
|
||||
|
||||
private _state: number;
|
||||
private _rooms: Map<string, IRoomInstance>;
|
||||
private _contentLoader: IRoomContentLoader;
|
||||
private _updateCategories: number[];
|
||||
private _rooms: Map<string, IRoomInstance> = new Map();
|
||||
private _contentLoader: IRoomContentLoader = null;
|
||||
private _updateCategories: number[] = [];
|
||||
|
||||
private _listener: IRoomManagerListener;
|
||||
private _visualizationFactory: IRoomObjectVisualizationFactory;
|
||||
private _logicFactory: IRoomObjectLogicFactory;
|
||||
|
||||
private _initialLoadList: string[];
|
||||
private _pendingContentTypes: string[];
|
||||
private _skipContentProcessing: boolean;
|
||||
private _pendingContentTypes: string[] = [];
|
||||
private _skipContentProcessing: boolean = false;
|
||||
|
||||
private _disposed: boolean;
|
||||
|
||||
constructor(listener: IRoomManagerListener, visualizationFactory: IRoomObjectVisualizationFactory, logicFactory: IRoomObjectLogicFactory)
|
||||
constructor(listener: IRoomManagerListener, visualizationFactory: IRoomObjectVisualizationFactory, logicFactory: IRoomObjectLogicFactory, contentLoader: IRoomContentLoader)
|
||||
{
|
||||
super();
|
||||
|
||||
this._state = RoomManager.ROOM_MANAGER_LOADED;
|
||||
this._rooms = new Map();
|
||||
this._contentLoader = null;
|
||||
this._updateCategories = [];
|
||||
|
||||
this._listener = listener;
|
||||
this._visualizationFactory = visualizationFactory;
|
||||
this._logicFactory = logicFactory;
|
||||
|
||||
this._initialLoadList = [];
|
||||
this._pendingContentTypes = [];
|
||||
this._skipContentProcessing = false;
|
||||
|
||||
this._disposed = false;
|
||||
this._contentLoader = contentLoader;
|
||||
|
||||
this.onRoomContentLoadedEvent = this.onRoomContentLoadedEvent.bind(this);
|
||||
|
||||
this.events.addEventListener(RoomContentLoadedEvent.RCLE_SUCCESS, this.onRoomContentLoadedEvent);
|
||||
this.events.addEventListener(RoomContentLoadedEvent.RCLE_FAILURE, this.onRoomContentLoadedEvent);
|
||||
this.events.addEventListener(RoomContentLoadedEvent.RCLE_CANCEL, this.onRoomContentLoadedEvent);
|
||||
NitroEventDispatcher.addEventListener(RoomContentLoadedEvent.RCLE_SUCCESS, this.onRoomContentLoadedEvent);
|
||||
NitroEventDispatcher.addEventListener(RoomContentLoadedEvent.RCLE_FAILURE, this.onRoomContentLoadedEvent);
|
||||
NitroEventDispatcher.addEventListener(RoomContentLoadedEvent.RCLE_CANCEL, this.onRoomContentLoadedEvent);
|
||||
}
|
||||
|
||||
public onInit(): void
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
if(this._state >= RoomManager.ROOM_MANAGER_INITIALIZING || !this._contentLoader) return;
|
||||
const promises = RoomContentLoader.MANDATORY_LIBRARIES.map(value => this._contentLoader.downloadAsset(value));
|
||||
|
||||
const mandatoryLibraries = RoomContentLoader.MANDATORY_LIBRARIES;
|
||||
|
||||
for(const library of mandatoryLibraries)
|
||||
{
|
||||
if(!library) continue;
|
||||
|
||||
if(this._initialLoadList.indexOf(library) === -1)
|
||||
{
|
||||
this._contentLoader.downloadAsset(library, this.events);
|
||||
|
||||
this._initialLoadList.push(library);
|
||||
}
|
||||
}
|
||||
|
||||
this._state = RoomManager.ROOM_MANAGER_INITIALIZING;
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
public getRoomInstance(roomId: string): IRoomInstance
|
||||
@ -137,7 +99,7 @@ export class RoomManager extends NitroManager implements IRoomManager, IRoomInst
|
||||
{
|
||||
isLoading = true;
|
||||
|
||||
this._contentLoader.downloadAsset(type, this.events);
|
||||
this._contentLoader.downloadAsset(type);
|
||||
|
||||
assetName = this._contentLoader.getPlaceholderName(type);
|
||||
asset = this._contentLoader.getCollection(assetName);
|
||||
@ -294,13 +256,6 @@ export class RoomManager extends NitroManager implements IRoomManager, IRoomInst
|
||||
}
|
||||
}
|
||||
|
||||
public setContentLoader(loader: IRoomContentLoader): void
|
||||
{
|
||||
if(this._contentLoader) this._contentLoader.dispose();
|
||||
|
||||
this._contentLoader = loader;
|
||||
}
|
||||
|
||||
private processPendingContentTypes(time: number): void
|
||||
{
|
||||
if(this._skipContentProcessing)
|
||||
@ -331,38 +286,6 @@ export class RoomManager extends NitroManager implements IRoomManager, IRoomInst
|
||||
this.reinitializeRoomObjectsByType(type);
|
||||
|
||||
if(this._listener) this._listener.initalizeTemporaryObjectsByType(type, true);
|
||||
|
||||
if(this._initialLoadList.length > 0) this.removeFromInitialLoad(type);
|
||||
}
|
||||
}
|
||||
|
||||
private removeFromInitialLoad(type: string): void
|
||||
{
|
||||
if(!type || this._state === RoomManager.ROOM_MANAGER_ERROR) return;
|
||||
|
||||
if(!this._contentLoader) this._state = RoomManager.ROOM_MANAGER_ERROR;
|
||||
|
||||
if(this._contentLoader.getCollection(type))
|
||||
{
|
||||
const i = this._initialLoadList.indexOf(type);
|
||||
|
||||
if(i >= 0) this._initialLoadList.splice(i, 1);
|
||||
|
||||
if(!this._initialLoadList.length)
|
||||
{
|
||||
this._state = RoomManager.ROOM_MANAGER_INITIALIZED;
|
||||
|
||||
if(this._listener)
|
||||
{
|
||||
this._listener.onRoomEngineInitalized(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._state = RoomManager.ROOM_MANAGER_ERROR;
|
||||
|
||||
if(this._listener) this._listener.onRoomEngineInitalized(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,9 +318,4 @@ export class RoomManager extends NitroManager implements IRoomManager, IRoomInst
|
||||
{
|
||||
return this._rooms;
|
||||
}
|
||||
|
||||
public get disposed(): boolean
|
||||
{
|
||||
return this._disposed;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user