From 4641857a063adc9f26ce53e4c6139911bac82bf2 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 20 Jul 2023 19:05:01 -0400 Subject: [PATCH] Updates --- src/api/common/IUpdateReceiver.ts | 3 +- src/api/nitro/room/IRoomEngine.ts | 1 - src/api/nitro/session/IRoomSession.ts | 4 +- src/api/room/IRoomInstance.ts | 4 +- src/api/room/object/IRoomObject.ts | 4 +- .../object/logic/IRoomObjectEventHandler.ts | 5 +- src/common/NitroManager.ts | 66 ------------------- src/common/index.ts | 1 - src/nitro/room/RoomEngine.ts | 5 +- src/nitro/session/RoomSession.ts | 57 +++++----------- src/nitro/session/UserDataManager.ts | 24 ++----- src/nitro/session/handler/BaseHandler.ts | 7 +- src/room/RoomInstance.ts | 19 ++---- src/room/object/RoomObject.ts | 39 ++++------- src/room/object/logic/RoomObjectLogicBase.ts | 22 ++----- 15 files changed, 58 insertions(+), 203 deletions(-) delete mode 100644 src/common/NitroManager.ts diff --git a/src/api/common/IUpdateReceiver.ts b/src/api/common/IUpdateReceiver.ts index 76c3891b..d67db9b7 100644 --- a/src/api/common/IUpdateReceiver.ts +++ b/src/api/common/IUpdateReceiver.ts @@ -1,6 +1,5 @@ -import { IDisposable } from './IDisposable'; -export interface IUpdateReceiver extends IDisposable +export interface IUpdateReceiver { update(time: number): void; } diff --git a/src/api/nitro/room/IRoomEngine.ts b/src/api/nitro/room/IRoomEngine.ts index 26690932..69a5341f 100644 --- a/src/api/nitro/room/IRoomEngine.ts +++ b/src/api/nitro/room/IRoomEngine.ts @@ -94,7 +94,6 @@ export interface IRoomEngine logicFactory: IRoomObjectLogicFactory; roomContentLoader: IRoomContentLoader; activeRoomId: number; - disposed: boolean; selectedAvatarId: number; isDecorating: boolean; } diff --git a/src/api/nitro/session/IRoomSession.ts b/src/api/nitro/session/IRoomSession.ts index 606afbb4..c9dcf816 100644 --- a/src/api/nitro/session/IRoomSession.ts +++ b/src/api/nitro/session/IRoomSession.ts @@ -1,10 +1,10 @@ -import { IDisposable } from '../../common'; import { IConnection } from '../communication'; import { IRoomModerationSettings } from './IRoomModerationSettings'; import { IUserDataManager } from './IUserDataManager'; -export interface IRoomSession extends IDisposable +export interface IRoomSession { + dispose(): void; openGift(objectId: number): void; setConnection(connection: IConnection): void; setControllerLevel(level: number): void; diff --git a/src/api/room/IRoomInstance.ts b/src/api/room/IRoomInstance.ts index 838096b5..367ccef7 100644 --- a/src/api/room/IRoomInstance.ts +++ b/src/api/room/IRoomInstance.ts @@ -1,11 +1,11 @@ -import { IDisposable } from '../../api'; import { IRoomInstanceContainer } from './IRoomInstanceContainer'; import { IRoomObjectManager } from './IRoomObjectManager'; import { IRoomObject, IRoomObjectModel } from './object'; import { IRoomRendererBase } from './renderer'; -export interface IRoomInstance extends IDisposable +export interface IRoomInstance { + dispose(): void; setRenderer(renderer: IRoomRendererBase): void; getManager(category: number): IRoomObjectManager; getTotalObjectsForManager(category: number): number; diff --git a/src/api/room/object/IRoomObject.ts b/src/api/room/object/IRoomObject.ts index 0dca2521..cecd3595 100644 --- a/src/api/room/object/IRoomObject.ts +++ b/src/api/room/object/IRoomObject.ts @@ -1,11 +1,11 @@ -import { IDisposable } from '../../common'; import { IVector3D } from '../IVector3D'; import { IRoomObjectModel } from './IRoomObjectModel'; import { IRoomObjectMouseHandler } from './logic'; import { IRoomObjectVisualization } from './visualization'; -export interface IRoomObject extends IDisposable +export interface IRoomObject { + dispose(): void; getLocation(): IVector3D; getDirection(): IVector3D; getState(index?: number): number; diff --git a/src/api/room/object/logic/IRoomObjectEventHandler.ts b/src/api/room/object/logic/IRoomObjectEventHandler.ts index 26e17edb..8fab317f 100644 --- a/src/api/room/object/logic/IRoomObjectEventHandler.ts +++ b/src/api/room/object/logic/IRoomObjectEventHandler.ts @@ -1,11 +1,12 @@ -import { IDisposable, IEventDispatcher } from '../../../common'; +import { IEventDispatcher } from '../../../common'; import { IRoomObjectUpdateMessage } from '../../IRoomObjectUpdateMessage'; import { IRoomObjectController } from '../IRoomObjectController'; import { IRoomObjectMouseHandler } from './IRoomObjectMouseHandler'; -export interface IRoomObjectEventHandler extends IRoomObjectMouseHandler, IDisposable +export interface IRoomObjectEventHandler extends IRoomObjectMouseHandler { initialize(data: unknown): void; + dispose(): void; update(totalTimeRunning: number): void; processUpdateMessage(message: IRoomObjectUpdateMessage): void; getEventTypes(): string[]; diff --git a/src/common/NitroManager.ts b/src/common/NitroManager.ts deleted file mode 100644 index 69267e38..00000000 --- a/src/common/NitroManager.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { IEventDispatcher, INitroManager } from '../api'; -import { Disposable } from './Disposable'; -import { EventDispatcher } from './EventDispatcher'; - -export class NitroManager extends Disposable implements INitroManager -{ - private _events: IEventDispatcher; - - private _isLoaded: boolean; - private _isLoading: boolean; - - constructor() - { - super(); - - this._events = new EventDispatcher(); - - this._isLoaded = false; - this._isLoading = false; - } - - public init(): void - { - if(this._isLoaded || this._isLoading || this.isDisposing) return; - - this._isLoading = true; - - this.onInit(); - - this._isLoaded = true; - this._isLoading = false; - } - - protected onInit(): void - { - return; - } - - protected onDispose(): void - { - if(this._events) this._events.dispose(); - - super.onDispose(); - } - - public reload(): void - { - this.dispose(); - this.init(); - } - - public get events(): IEventDispatcher - { - return this._events; - } - - public get isLoaded(): boolean - { - return this._isLoaded; - } - - public get isLoading(): boolean - { - return this._isLoading; - } -} diff --git a/src/common/index.ts b/src/common/index.ts index 9e5ab332..6e5d597e 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -1,3 +1,2 @@ export * from './Disposable'; export * from './EventDispatcher'; -export * from './NitroManager'; diff --git a/src/nitro/room/RoomEngine.ts b/src/nitro/room/RoomEngine.ts index 217afd95..9da343fe 100644 --- a/src/nitro/room/RoomEngine.ts +++ b/src/nitro/room/RoomEngine.ts @@ -1,7 +1,6 @@ import { Matrix, Point, Rectangle, RenderTexture, Resource, Texture } from '@pixi/core'; import { Container, DisplayObject } from '@pixi/display'; 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, 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, RoomManager, RoomObjectUpdateMessage, RoomRendererFactory } from '../../room'; @@ -19,7 +18,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 +export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineServices, IRoomManagerListener, IRoomContentListener, IUpdateReceiver { public static ROOM_OBJECT_ID: number = -1; public static ROOM_OBJECT_TYPE: string = 'room'; @@ -70,8 +69,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato constructor(communication: ICommunicationManager, sessionDataManager: ISessionDataManager) { - super(); - this._communication = communication; this._sessionDataManager = sessionDataManager; this._roomSessionManager = new RoomSessionManager(this._communication, this); diff --git a/src/nitro/session/RoomSession.ts b/src/nitro/session/RoomSession.ts index 76c3acd7..4f61720c 100644 --- a/src/nitro/session/RoomSession.ts +++ b/src/nitro/session/RoomSession.ts @@ -1,52 +1,29 @@ import { IConnection, IRoomSession, RoomControllerLevel, RoomTradingLevelEnum } from '../../api'; -import { Disposable } from '../../common'; import { RoomSessionEvent } from '../../events'; import { BotRemoveComposer, ChangeQueueMessageComposer, CompostPlantMessageComposer, FurnitureMultiStateComposer, GetPetCommandsComposer, HarvestPetMessageComposer, MoodlightSettingsComposer, MoodlightSettingsSaveComposer, MoodlightTogggleStateComposer, NewUserExperienceScriptProceedComposer, OpenPetPackageMessageComposer, OpenPresentComposer, PeerUsersClassificationMessageComposer, PetMountComposer, PetRemoveComposer, PollAnswerComposer, PollRejectComposer, PollStartComposer, RemovePetSaddleComposer, RoomAmbassadorAlertComposer, RoomBanUserComposer, RoomDoorbellAccessComposer, RoomEnterComposer, RoomGiveRightsComposer, RoomKickUserComposer, RoomModerationSettings, RoomMuteUserComposer, RoomTakeRightsComposer, RoomUnitActionComposer, RoomUnitChatComposer, RoomUnitChatShoutComposer, RoomUnitChatWhisperComposer, RoomUnitDanceComposer, RoomUnitPostureComposer, RoomUnitSignComposer, RoomUnitTypingStartComposer, RoomUnitTypingStopComposer, RoomUsersClassificationMessageComposer, SetClothingChangeDataMessageComposer, TogglePetBreedingComposer, TogglePetRidingComposer, UsePetProductComposer, UserMottoComposer, VotePollCounterMessageComposer } from '../communication'; import { UserDataManager } from './UserDataManager'; -export class RoomSession extends Disposable implements IRoomSession +export class RoomSession implements IRoomSession { - private _connection: IConnection; - private _userData: UserDataManager; + private _connection: IConnection = null; + private _userData: UserDataManager = new UserDataManager(); - private _roomId: number; - private _password: string; - private _state: string; - private _tradeMode: number; - private _doorMode: number; - private _allowPets: boolean; - private _controllerLevel: number; - private _ownRoomIndex: number; - private _isGuildRoom: boolean; - private _isRoomOwner: boolean; - private _isDecorating: boolean; - private _isSpectator: boolean; + private _roomId: number = 0; + private _password: string = null; + private _state: string = RoomSessionEvent.CREATED; + private _tradeMode: number = RoomTradingLevelEnum.NO_TRADING; + private _doorMode: number = 0; + private _allowPets: boolean = false; + private _controllerLevel: number = RoomControllerLevel.NONE; + private _ownRoomIndex: number = -1; + private _isGuildRoom: boolean = false; + private _isRoomOwner: boolean = false; + private _isDecorating: boolean = false; + private _isSpectator: boolean = false; - private _moderationSettings: RoomModerationSettings; + private _moderationSettings: RoomModerationSettings = null; - constructor() - { - super(); - - this._connection = null; - this._userData = new UserDataManager(); - - this._roomId = 0; - this._password = null; - this._state = RoomSessionEvent.CREATED; - this._tradeMode = RoomTradingLevelEnum.NO_TRADING; - this._doorMode = 0; - this._controllerLevel = RoomControllerLevel.NONE; - this._ownRoomIndex = -1; - this._isGuildRoom = false; - this._isRoomOwner = false; - this._isDecorating = false; - this._isSpectator = false; - - this._moderationSettings = null; - } - - protected onDispose(): void + public dispose(): void { if(this._userData) { diff --git a/src/nitro/session/UserDataManager.ts b/src/nitro/session/UserDataManager.ts index e2a51d7d..4bef15e6 100644 --- a/src/nitro/session/UserDataManager.ts +++ b/src/nitro/session/UserDataManager.ts @@ -1,32 +1,20 @@ import { IConnection, IRoomUserData } from '../../api'; -import { Disposable } from '../../common'; import { RequestPetInfoComposer, UserCurrentBadgesComposer } from '../communication'; -export class UserDataManager extends Disposable +export class UserDataManager { private static TYPE_USER: number = 1; private static TYPE_PET: number = 2; private static TYPE_BOT: number = 3; private static TYPE_RENTABLE_BOT: number = 4; - private _connection: IConnection; + private _connection: IConnection = null; - private _userDataByType: Map>; - private _userDataByRoomIndex: Map; - private _userBadges: Map; + private _userDataByType: Map> = new Map(); + private _userDataByRoomIndex: Map = new Map(); + private _userBadges: Map = new Map(); - constructor() - { - super(); - - this._connection = null; - - this._userDataByType = new Map(); - this._userDataByRoomIndex = new Map(); - this._userBadges = new Map(); - } - - protected onDispose(): void + public dispose(): void { this._connection = null; } diff --git a/src/nitro/session/handler/BaseHandler.ts b/src/nitro/session/handler/BaseHandler.ts index 72f4d429..febf802a 100644 --- a/src/nitro/session/handler/BaseHandler.ts +++ b/src/nitro/session/handler/BaseHandler.ts @@ -1,7 +1,6 @@ import { IConnection, IRoomHandlerListener } from '../../../api'; -import { Disposable } from '../../../common'; -export class BaseHandler extends Disposable +export class BaseHandler { private _connection: IConnection; private _listener: IRoomHandlerListener; @@ -9,14 +8,12 @@ export class BaseHandler extends Disposable constructor(connection: IConnection, listener: IRoomHandlerListener) { - super(); - this._connection = connection; this._listener = listener; this._roomId = 0; } - protected onDispose(): void + public dispose(): void { this._connection = null; this._listener = null; diff --git a/src/room/RoomInstance.ts b/src/room/RoomInstance.ts index 4cc3c18c..922a7903 100644 --- a/src/room/RoomInstance.ts +++ b/src/room/RoomInstance.ts @@ -1,29 +1,22 @@ import { IRoomInstance, IRoomInstanceContainer, IRoomObject, IRoomObjectController, IRoomObjectManager, IRoomObjectModel, IRoomRendererBase } from '../api'; -import { Disposable } from '../common'; import { RoomObjectModel } from './object'; -export class RoomInstance extends Disposable implements IRoomInstance +export class RoomInstance implements IRoomInstance { private _id: string; private _container: IRoomInstanceContainer; - private _renderer: IRoomRendererBase; - private _managers: Map; - private _updateCategories: number[]; - private _model: IRoomObjectModel; + private _renderer: IRoomRendererBase = null; + private _managers: Map = new Map(); + private _updateCategories: number[] = []; + private _model: IRoomObjectModel = new RoomObjectModel(); constructor(id: string, container: IRoomInstanceContainer) { - super(); - this._id = id; this._container = container; - this._renderer = null; - this._managers = new Map(); - this._updateCategories = []; - this._model = new RoomObjectModel(); } - protected onDispose(): void + public dispose(): void { this.removeAllManagers(); diff --git a/src/room/object/RoomObject.ts b/src/room/object/RoomObject.ts index 4fbbfe5c..15e90355 100644 --- a/src/room/object/RoomObject.ts +++ b/src/room/object/RoomObject.ts @@ -1,46 +1,31 @@ import { IRoomObjectController, IRoomObjectEventHandler, IRoomObjectModel, IRoomObjectMouseHandler, IRoomObjectUpdateMessage, IRoomObjectVisualization, IVector3D, Vector3d } from '../../api'; -import { Disposable } from '../../common'; import { RoomObjectModel } from './RoomObjectModel'; -export class RoomObject extends Disposable implements IRoomObjectController +export class RoomObject implements IRoomObjectController { private static OBJECT_COUNTER: number = 0; private _id: number; private _instanceId: number; private _type: string; - private _model: IRoomObjectModel; + private _model: IRoomObjectModel = new RoomObjectModel(); - private _location: IVector3D; - private _direction: IVector3D; - private _states: number[]; + private _location: IVector3D = new Vector3d(); + private _direction: IVector3D = new Vector3d(); + private _states: number[] = []; - private _visualization: IRoomObjectVisualization; - private _logic: IRoomObjectEventHandler; - private _pendingLogicMessages: IRoomObjectUpdateMessage[]; + private _visualization: IRoomObjectVisualization = null; + private _logic: IRoomObjectEventHandler = null; + private _pendingLogicMessages: IRoomObjectUpdateMessage[] = []; - private _updateCounter: number; - private _isReady: boolean; + private _updateCounter: number = 0; + private _isReady: boolean = false; constructor(id: number, stateCount: number, type: string) { - super(); - this._id = id; this._instanceId = RoomObject.OBJECT_COUNTER++; this._type = type; - this._model = new RoomObjectModel(); - - this._location = new Vector3d(); - this._direction = new Vector3d(); - this._states = []; - - this._visualization = null; - this._logic = null; - this._pendingLogicMessages = []; - - this._updateCounter = 0; - this._isReady = false; let i = (stateCount - 1); @@ -52,7 +37,7 @@ export class RoomObject extends Disposable implements IRoomObjectController } } - protected onDispose(): void + public dispose(): void { this._pendingLogicMessages = []; @@ -60,8 +45,6 @@ export class RoomObject extends Disposable implements IRoomObjectController this.setLogic(null); if(this._model) this._model.dispose(); - - super.onDispose(); } public getLocation(): IVector3D diff --git a/src/room/object/logic/RoomObjectLogicBase.ts b/src/room/object/logic/RoomObjectLogicBase.ts index 054e46a3..9e553294 100644 --- a/src/room/object/logic/RoomObjectLogicBase.ts +++ b/src/room/object/logic/RoomObjectLogicBase.ts @@ -1,30 +1,18 @@ import { IEventDispatcher, IRoomGeometry, IRoomObjectController, IRoomObjectEventHandler, IRoomObjectUpdateMessage } from '../../../api'; -import { Disposable } from '../../../common'; import { RoomSpriteMouseEvent } from '../../../events'; -export class RoomObjectLogicBase extends Disposable implements IRoomObjectEventHandler +export class RoomObjectLogicBase implements IRoomObjectEventHandler { - private _events: IEventDispatcher; - private _object: IRoomObjectController; - - private _time: number; - - constructor() - { - super(); - - this._object = null; - this._events = null; - - this._time = 0; - } + private _events: IEventDispatcher = null; + private _object: IRoomObjectController = null; + private _time: number = 0; public initialize(data: unknown): void { return; } - protected onDispose(): void + public dispose(): void { this._object = null; }