Update logging

This commit is contained in:
Bill 2022-07-18 21:51:53 -04:00
parent c60f05b227
commit 8e828c1f7d
19 changed files with 897 additions and 918 deletions

View File

@ -34,33 +34,33 @@ export class AssetManager extends Disposable implements IAssetManager
public getTexture(name: string): Texture<Resource>
{
if(!name) return null;
if (!name) return null;
const existing = this._textures.get(name);
if(!existing) return null;
if (!existing) return null;
return existing;
}
public setTexture(name: string, texture: Texture<Resource>): void
{
if(!name || !texture) return;
if (!name || !texture) return;
this._textures.set(name, texture);
}
public getAsset(name: string): IGraphicAsset
{
if(!name) return null;
if (!name) return null;
for(const collection of this._collections.values())
for (const collection of this._collections.values())
{
if(!collection) continue;
if (!collection) continue;
const existing = collection.getAsset(name);
if(!existing) continue;
if (!existing) continue;
return existing;
}
@ -70,24 +70,24 @@ export class AssetManager extends Disposable implements IAssetManager
public getCollection(name: string): IGraphicAssetCollection
{
if(!name) return null;
if (!name) return null;
const existing = this._collections.get(name);
if(!existing) return null;
if (!existing) return null;
return existing;
}
public createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection
{
if(!data) return null;
if (!data) return null;
const collection = new GraphicAssetCollection(data, spritesheet);
if(collection)
if (collection)
{
for(const [ name, texture ] of collection.textures.entries()) this.setTexture(name, texture);
for (const [name, texture] of collection.textures.entries()) this.setTexture(name, texture);
this._collections.set(collection.name, collection);
}
@ -97,12 +97,12 @@ export class AssetManager extends Disposable implements IAssetManager
public downloadAsset(assetUrl: string, cb: (status: boolean) => void): void
{
this.downloadAssets([ assetUrl ], cb);
this.downloadAssets([assetUrl], cb);
}
public downloadAssets(assetUrls: string[], cb: (status: boolean) => void): void
{
if(!assetUrls || !assetUrls.length)
if (!assetUrls || !assetUrls.length)
{
cb(true);
@ -111,9 +111,9 @@ export class AssetManager extends Disposable implements IAssetManager
const loader = new Loader();
for(const url of assetUrls)
for (const url of assetUrls)
{
if(!url) continue;
if (!url) continue;
loader
.add({
@ -128,9 +128,9 @@ export class AssetManager extends Disposable implements IAssetManager
const onDownloaded = (status: boolean, url: string) =>
{
if(!status)
if (!status)
{
this._logger.error('Failed to download asset: ' + url);
this._logger.error('Failed to download asset', url);
loader.destroy();
@ -141,7 +141,7 @@ export class AssetManager extends Disposable implements IAssetManager
remaining--;
if(!remaining)
if (!remaining)
{
loader.destroy();
@ -153,11 +153,11 @@ export class AssetManager extends Disposable implements IAssetManager
loader.load((loader, resources) =>
{
for(const key in resources)
for (const key in resources)
{
const resource = resources[key];
if(!resource || resource.error || !resource.xhr)
if (!resource || resource.error || !resource.xhr)
{
onDownloaded(false, resource.url);
@ -166,7 +166,7 @@ export class AssetManager extends Disposable implements IAssetManager
const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream');
if(resourceType === 'application/octet-stream')
if (resourceType === 'application/octet-stream')
{
const nitroBundle = new NitroBundle(resource.data);
@ -178,12 +178,12 @@ export class AssetManager extends Disposable implements IAssetManager
continue;
}
if((resourceType === 'image/png') || (resourceType === 'image/jpeg') || (resourceType === 'image/gif'))
if ((resourceType === 'image/png') || (resourceType === 'image/jpeg') || (resourceType === 'image/gif'))
{
const base64 = ArrayBufferToBase64(resource.data);
const baseTexture = new BaseTexture(`data:${ resourceType };base64,${ base64 }`);
const baseTexture = new BaseTexture(`data:${resourceType};base64,${base64}`);
if(baseTexture.valid)
if (baseTexture.valid)
{
const texture = new Texture(baseTexture);
@ -215,7 +215,7 @@ export class AssetManager extends Disposable implements IAssetManager
{
const spritesheetData = data.spritesheet;
if(!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
if (!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
{
this.createCollection(data, null);
@ -236,7 +236,7 @@ export class AssetManager extends Disposable implements IAssetManager
});
};
if(baseTexture.valid)
if (baseTexture.valid)
{
createAsset();
}

View File

@ -1,8 +1,8 @@
export interface INitroLogger
{
log(message: string): void;
error(message: string, trace?: string): void;
warn(message: string): void;
log(...message: any[]): void;
error(...message: any[]): void;
warn(...message: any[]): void;
description: string | number;
print: boolean;
}
}

View File

@ -2,8 +2,6 @@ import { INitroLogger } from './INitroLogger';
export class NitroLogger implements INitroLogger
{
private static LAST_TIMESTAMP: number = Date.now();
private _name: string;
private _description: string | number;
private _print: boolean;
@ -15,66 +13,55 @@ export class NitroLogger implements INitroLogger
this._print = true;
}
public log(message: string): void
public log(...message: any[]): void
{
this.printMessage(message, 'log');
this.printMessage('log', ...message);
}
public error(message: string, trace?: string): void
public error(...message: any[]): void
{
this.printMessage(trace || message, 'error');
this.printMessage('error', ...message);
}
public warn(message: string): void
public warn(...message: any[]): void
{
this.printMessage(message, 'warn');
this.printMessage('warn', ...message);
}
public printMessage(message: string, modus: string): void
public printMessage(modus: string, ...message: any[]): void
{
if(!this._print) return;
if (!this._print) return;
NitroLogger.log(message, this._name, modus);
NitroLogger.log(this._name, modus, ...message);
}
public static log(message: string, name: string = 'Nitro', modus: string = null): void
public static log(name: string = 'Nitro', modus: string = null, ...message: any[]): void
{
const logString = `[Nitro] [${ name }] ${ message } ${ this.getTimestamp() }`;
const logPrefix = `[Nitro] [${name}]`;
switch(modus)
switch (modus)
{
case 'error':
console.error(logString);
console.error(logPrefix, ...message);
break;
case 'warn':
console.warn(logString);
console.warn(logPrefix, ...message);
break;
case 'log':
default:
console.log(logString);
console.log(logPrefix, ...message);
break;
}
}
public static error(message: string, name: string = 'Nitro'): void
public static error(name: string = 'Nitro', ...message: any[]): void
{
return this.log(message, name, 'error');
return this.log(name, 'error', ...message);
}
public static warn(message: string, name: string = 'Nitro'): void
public static warn(name: string = 'Nitro', ...message: any[]): void
{
return this.log(message, name, 'warn');
}
public static getTimestamp(): string
{
const now = Date.now();
const result = ` +${ now - NitroLogger.LAST_TIMESTAMP || 0 }ms`;
this.LAST_TIMESTAMP = now;
return result;
return this.log(name, 'warn', ...message);
}
public get description(): string | number

View File

@ -1,5 +1,4 @@
import { Nitro } from '../../../nitro/Nitro';
import { NitroLogger } from '../../common/logger/NitroLogger';
import { EventDispatcher } from '../../events/EventDispatcher';
import { EvaWireFormat } from '../codec/evawire/EvaWireFormat';
import { ICodec } from '../codec/ICodec';
@ -54,7 +53,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
public init(socketUrl: string): void
{
if(this._stateListener)
if (this._stateListener)
{
this._stateListener.connectionInit(socketUrl);
}
@ -77,13 +76,13 @@ export class SocketConnection extends EventDispatcher implements IConnection
public onReady(): void
{
if(this._isReady) return;
if (this._isReady) return;
this._isReady = true;
if(this._pendingServerMessages && this._pendingServerMessages.length) this.processWrappers(...this._pendingServerMessages);
if (this._pendingServerMessages && this._pendingServerMessages.length) this.processWrappers(...this._pendingServerMessages);
if(this._pendingClientMessages && this._pendingClientMessages.length) this.send(...this._pendingClientMessages);
if (this._pendingClientMessages && this._pendingClientMessages.length) this.send(...this._pendingClientMessages);
this._pendingServerMessages = [];
this._pendingClientMessages = [];
@ -91,7 +90,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private createSocket(socketUrl: string): void
{
if(!socketUrl) return;
if (!socketUrl) return;
this.destroySocket();
@ -106,14 +105,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
private destroySocket(): void
{
if(!this._socket) return;
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();
if (this._socket.readyState === WebSocket.OPEN) this._socket.close();
this._socket = null;
}
@ -135,7 +134,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private onMessage(event: MessageEvent): void
{
if(!event) return;
if (!event) return;
//this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event);
@ -163,28 +162,28 @@ export class SocketConnection extends EventDispatcher implements IConnection
public send(...composers: IMessageComposer<unknown[]>[]): boolean
{
if(this.disposed || !composers) return false;
if (this.disposed || !composers) return false;
composers = [ ...composers ];
composers = [...composers];
if(this._isAuthenticated && !this._isReady)
if (this._isAuthenticated && !this._isReady)
{
if(!this._pendingClientMessages) this._pendingClientMessages = [];
if (!this._pendingClientMessages) this._pendingClientMessages = [];
this._pendingClientMessages.push(...composers);
return false;
}
for(const composer of composers)
for (const composer of composers)
{
if(!composer) continue;
if (!composer) continue;
const header = this._messages.getComposerId(composer);
if(header === -1)
if (header === -1)
{
NitroLogger.log(`Unknown Composer: ${ composer.constructor.name }`);
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log(`Unknown Composer: ${composer.constructor.name}`);
continue;
}
@ -192,14 +191,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
const message = composer.getMessageArray();
const encoded = this._codec.encode(header, message);
if(!encoded)
if (!encoded)
{
if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) console.log(`Encoding Failed: ${ composer.constructor.name }`);
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('Encoding Failed', composer.constructor.name);
continue;
}
if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) console.log(`OutgoingComposer: [${ header }] ${ composer.constructor.name }`, message);
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('OutgoingComposer', header, composer.constructor.name, message);
this.write(encoded.getBuffer());
}
@ -209,7 +208,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private write(buffer: ArrayBuffer): void
{
if(this._socket.readyState !== WebSocket.OPEN) return;
if (this._socket.readyState !== WebSocket.OPEN) return;
this._socket.send(buffer);
}
@ -223,7 +222,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
catch (err)
{
NitroLogger.log(err);
this.logger.error(err);
}
}
@ -231,11 +230,11 @@ export class SocketConnection extends EventDispatcher implements IConnection
{
const wrappers = this.splitReceivedMessages();
if(!wrappers || !wrappers.length) return;
if (!wrappers || !wrappers.length) return;
if(this._isAuthenticated && !this._isReady)
if (this._isAuthenticated && !this._isReady)
{
if(!this._pendingServerMessages) this._pendingServerMessages = [];
if (!this._pendingServerMessages) this._pendingServerMessages = [];
this._pendingServerMessages.push(...wrappers);
@ -247,20 +246,17 @@ export class SocketConnection extends EventDispatcher implements IConnection
private processWrappers(...wrappers: IMessageDataWrapper[]): void
{
if(!wrappers || !wrappers.length) return;
if (!wrappers || !wrappers.length) return;
for(const wrapper of wrappers)
for (const wrapper of wrappers)
{
if(!wrapper) continue;
if (!wrapper) continue;
const messages = this.getMessagesForWrapper(wrapper);
if(!messages || !messages.length) continue;
if (!messages || !messages.length) continue;
if(Nitro.instance.getConfiguration<boolean>('system.packet.log'))
{
console.log(`IncomingMessage: [${ wrapper.header }] ${ messages[0].constructor.name }`, messages[0].parser);
}
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser);
this.handleMessages(...messages);
}
@ -268,7 +264,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private splitReceivedMessages(): IMessageDataWrapper[]
{
if(!this._dataBuffer || !this._dataBuffer.byteLength) return null;
if (!this._dataBuffer || !this._dataBuffer.byteLength) return null;
return this._codec.decode(this);
}
@ -285,16 +281,13 @@ export class SocketConnection extends EventDispatcher implements IConnection
private getMessagesForWrapper(wrapper: IMessageDataWrapper): IMessageEvent[]
{
if(!wrapper) return null;
if (!wrapper) return null;
const events = this._messages.getEvents(wrapper.header);
if(!events || !events.length)
if (!events || !events.length)
{
if(Nitro.instance.getConfiguration<boolean>('system.packet.log'))
{
console.log(`IncomingMessage: [${ wrapper.header }] UNREGISTERED`, wrapper);
}
if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
return;
}
@ -304,14 +297,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
//@ts-ignore
const parser = new events[0].parserClass();
if(!parser || !parser.flush() || !parser.parse(wrapper)) return null;
if (!parser || !parser.flush() || !parser.parse(wrapper)) return null;
for(const event of events) (event.parser = parser);
for (const event of events) (event.parser = parser);
}
catch (e)
{
NitroLogger.log(`Error parsing message: ${ e }`, events[0].constructor.name);
this.logger.error('Error parsing message', e, events[0].constructor.name);
return null;
}
@ -321,35 +314,35 @@ export class SocketConnection extends EventDispatcher implements IConnection
private handleMessages(...messages: IMessageEvent[]): void
{
messages = [ ...messages ];
messages = [...messages];
for(const message of messages)
for (const message of messages)
{
if(!message) continue;
if (!message) continue;
message.connection = this;
if(message.callBack) message.callBack(message);
if (message.callBack) message.callBack(message);
}
}
public registerMessages(configuration: IMessageConfiguration): void
{
if(!configuration) return;
if (!configuration) return;
this._messages.registerMessages(configuration);
}
public addMessageEvent(event: IMessageEvent): void
{
if(!event || !this._messages) return;
if (!event || !this._messages) return;
this._messages.registerMessageEvent(event);
}
public removeMessageEvent(event: IMessageEvent): void
{
if(!event || !this._messages) return;
if (!event || !this._messages) return;
this._messages.removeMessageEvent(event);
}

View File

@ -28,13 +28,13 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public addEventListener(type: string, callback: Function): void
{
if(!type || !callback) return;
if (!type || !callback) return;
const existing = this._listeners.get(type);
if(!existing)
if (!existing)
{
this._listeners.set(type, [ callback ]);
this._listeners.set(type, [callback]);
return;
}
@ -44,19 +44,19 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public removeEventListener(type: string, callback: any): void
{
if(!type || !callback) return;
if (!type || !callback) return;
const existing = this._listeners.get(type);
if(!existing || !existing.length) return;
if (!existing || !existing.length) return;
for(const [ i, cb ] of existing.entries())
for (const [i, cb] of existing.entries())
{
if(!cb || (cb !== callback)) continue;
if (!cb || (cb !== callback)) continue;
existing.splice(i, 1);
if(!existing.length) this._listeners.delete(type);
if (!existing.length) this._listeners.delete(type);
return;
}
@ -64,9 +64,9 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public dispatchEvent(event: NitroEvent): boolean
{
if(!event) return false;
if (!event) return false;
if(Nitro.instance.getConfiguration<boolean>('system.dispatcher.log')) this._logger.log(`DISPATCHED: ${ event.type }`);
if (Nitro.instance.getConfiguration<boolean>('system.dispatcher.log')) this._logger.log('Dispatched Event', event.type);
this.processEvent(event);
@ -77,18 +77,18 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
{
const existing = this._listeners.get(event.type);
if(!existing || !existing.length) return;
if (!existing || !existing.length) return;
const callbacks = [];
for(const callback of existing)
for (const callback of existing)
{
if(!callback) continue;
if (!callback) continue;
callbacks.push(callback);
}
while(callbacks.length)
while (callbacks.length)
{
const callback = callbacks.shift();
@ -110,4 +110,9 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
{
this._listeners.clear();
}
public get logger(): INitroLogger
{
return this._logger;
}
}

View File

@ -1,3 +1,4 @@
import { INitroLogger } from '../common';
import { IDisposable } from '../common/disposable/IDisposable';
import { NitroEvent } from './NitroEvent';
@ -7,4 +8,5 @@ export interface IEventDispatcher extends IDisposable
removeEventListener(type: string, callback: Function): void;
removeAllListeners(): void;
dispatchEvent(event: NitroEvent): boolean;
logger: INitroLogger;
}

View File

@ -1,5 +1,4 @@
import { IAssetManager } from '../../core/asset/IAssetManager';
import { NitroLogger } from '../../core/common/logger/NitroLogger';
import { EventDispatcher } from '../../core/events/EventDispatcher';
import { NitroEvent } from '../../core/events/NitroEvent';
import { Nitro } from '../Nitro';
@ -22,7 +21,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private _missingMandatoryLibs: string[];
private _figureMap: Map<string, AvatarAssetDownloadLibrary[]>;
private _pendingContainers: [ IAvatarFigureContainer, IAvatarImageListener ][];
private _pendingContainers: [IAvatarFigureContainer, IAvatarImageListener][];
private _figureListeners: Map<string, IAvatarImageListener[]>;
private _incompleteFigures: Map<string, AvatarAssetDownloadLibrary[]>;
private _pendingDownloadQueue: AvatarAssetDownloadLibrary[];
@ -67,7 +66,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
request.onloadend = e =>
{
if(request.responseText)
if (request.responseText)
{
const data = JSON.parse(request.responseText);
@ -89,22 +88,22 @@ export class AvatarAssetDownloadManager extends EventDispatcher
catch (e)
{
NitroLogger.log(e);
this.logger.error(e);
}
}
private processFigureMap(data: any): void
{
if(!data) return;
if (!data) return;
for(const library of data)
for (const library of data)
{
if(!library) continue;
if (!library) continue;
const id = (library.id as string);
const revision = (library.revision || '');
if(this._libraryNames.indexOf(id) >= 0) continue;
if (this._libraryNames.indexOf(id) >= 0) continue;
this._libraryNames.push(id);
@ -112,7 +111,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
downloadLibrary.addEventListener(AvatarRenderLibraryEvent.DOWNLOAD_COMPLETE, this.onLibraryLoaded);
for(const part of library.parts)
for (const part of library.parts)
{
const id = (part.id as string);
const type = (part.type as string);
@ -120,7 +119,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
let existing = this._figureMap.get(partString);
if(!existing) existing = [];
if (!existing) existing = [];
existing.push(downloadLibrary);
@ -131,9 +130,9 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private onAvatarRenderReady(event: NitroEvent): void
{
if(!event) return;
if (!event) return;
for(const [ container, listener ] of this._pendingContainers)
for (const [container, listener] of this._pendingContainers)
{
this.downloadAvatarFigure(container, listener);
}
@ -143,34 +142,34 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private onLibraryLoaded(event: AvatarRenderLibraryEvent): void
{
if(!event || !event.library) return;
if (!event || !event.library) return;
const loadedFigures: string[] = [];
for(const [ figure, libraries ] of this._incompleteFigures.entries())
for (const [figure, libraries] of this._incompleteFigures.entries())
{
let isReady = true;
for(const library of libraries)
for (const library of libraries)
{
if(!library || library.isLoaded) continue;
if (!library || library.isLoaded) continue;
isReady = false;
break;
}
if(isReady)
if (isReady)
{
loadedFigures.push(figure);
const listeners = this._figureListeners.get(figure);
if(listeners)
if (listeners)
{
for(const listener of listeners)
for (const listener of listeners)
{
if(!listener || listener.disposed) continue;
if (!listener || listener.disposed) continue;
listener.resetFigure(figure);
}
@ -182,22 +181,22 @@ export class AvatarAssetDownloadManager extends EventDispatcher
}
}
for(const figure of loadedFigures)
for (const figure of loadedFigures)
{
if(!figure) continue;
if (!figure) continue;
this._incompleteFigures.delete(figure);
}
let index = 0;
while(index < this._currentDownloads.length)
while (index < this._currentDownloads.length)
{
const download = this._currentDownloads[index];
if(download)
if (download)
{
if(download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1);
if (download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1);
}
index++;
@ -208,19 +207,19 @@ export class AvatarAssetDownloadManager extends EventDispatcher
{
const libraries = this._missingMandatoryLibs.slice();
for(const library of libraries)
for (const library of libraries)
{
if(!library) continue;
if (!library) continue;
const map = this._figureMap.get(library);
if(map) for(const avatar of map) avatar && this.downloadLibrary(avatar);
if (map) for (const avatar of map) avatar && this.downloadLibrary(avatar);
}
}
public isAvatarFigureContainerReady(container: IAvatarFigureContainer): boolean
{
if(!this._isReady || !this._structure.renderManager.isReady)
if (!this._isReady || !this._structure.renderManager.isReady)
{
return false;
}
@ -234,38 +233,38 @@ export class AvatarAssetDownloadManager extends EventDispatcher
{
const pendingLibraries: AvatarAssetDownloadLibrary[] = [];
if(!container || !this._structure) return pendingLibraries;
if (!container || !this._structure) return pendingLibraries;
const figureData = this._structure.figureData;
if(!figureData) return pendingLibraries;
if (!figureData) return pendingLibraries;
const setKeys = container.getPartTypeIds();
for(const key of setKeys)
for (const key of setKeys)
{
const set = figureData.getSetType(key);
if(!set) continue;
if (!set) continue;
const figurePartSet = set.getPartSet(container.getPartSetId(key));
if(!figurePartSet) continue;
if (!figurePartSet) continue;
for(const part of figurePartSet.parts)
for (const part of figurePartSet.parts)
{
if(!part) continue;
if (!part) continue;
const name = (part.type + ':' + part.id);
const existing = this._figureMap.get(name);
if(existing === undefined) continue;
if (existing === undefined) continue;
for(const library of existing)
for (const library of existing)
{
if(!library || library.isLoaded) continue;
if (!library || library.isLoaded) continue;
if(pendingLibraries.indexOf(library) >= 0) continue;
if (pendingLibraries.indexOf(library) >= 0) continue;
pendingLibraries.push(library);
}
@ -277,9 +276,9 @@ export class AvatarAssetDownloadManager extends EventDispatcher
public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void
{
if(!this._isReady || !this._structure.renderManager.isReady)
if (!this._isReady || !this._structure.renderManager.isReady)
{
this._pendingContainers.push([ container, listener ]);
this._pendingContainers.push([container, listener]);
return;
}
@ -287,13 +286,13 @@ export class AvatarAssetDownloadManager extends EventDispatcher
const figure = container.getFigureString();
const pendingLibraries = this.getAvatarFigurePendingLibraries(container);
if(pendingLibraries && pendingLibraries.length)
if (pendingLibraries && pendingLibraries.length)
{
if(listener && !listener.disposed)
if (listener && !listener.disposed)
{
let listeners = this._figureListeners.get(figure);
if(!listeners)
if (!listeners)
{
listeners = [];
@ -305,24 +304,24 @@ export class AvatarAssetDownloadManager extends EventDispatcher
this._incompleteFigures.set(figure, pendingLibraries);
for(const library of pendingLibraries)
for (const library of pendingLibraries)
{
if(!library) continue;
if (!library) continue;
this.downloadLibrary(library);
}
}
else
{
if(listener && !listener.disposed) listener.resetFigure(figure);
if (listener && !listener.disposed) listener.resetFigure(figure);
}
}
private downloadLibrary(library: AvatarAssetDownloadLibrary): void
{
if(!library || library.isLoaded) return;
if (!library || library.isLoaded) return;
if((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
if ((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
this._pendingDownloadQueue.push(library);
@ -331,7 +330,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private processDownloadQueue(): void
{
while(this._pendingDownloadQueue.length)
while (this._pendingDownloadQueue.length)
{
const library = this._pendingDownloadQueue[0];

View File

@ -1,4 +1,3 @@
import { NitroLogger } from '../../core';
import { IAssetManager } from '../../core/asset/IAssetManager';
import { NitroManager } from '../../core/common/NitroManager';
import { NitroEvent } from '../../core/events/NitroEvent';
@ -87,7 +86,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
this._aliasCollection.init();
if(!this._avatarAssetDownloadManager)
if (!this._avatarAssetDownloadManager)
{
this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(Nitro.instance.core.asset, this._structure);
@ -95,7 +94,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
this._avatarAssetDownloadManager.addEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
}
if(!this._effectAssetDownloadManager)
if (!this._effectAssetDownloadManager)
{
this._effectAssetDownloadManager = new EffectAssetDownloadManager(Nitro.instance.core.asset, this._structure);
@ -108,14 +107,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public onDispose(): void
{
if(this._avatarAssetDownloadManager)
if (this._avatarAssetDownloadManager)
{
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.DOWNLOADER_READY, this.onAvatarAssetDownloaderReady);
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
}
if(this._effectAssetDownloadManager)
if (this._effectAssetDownloadManager)
{
this._effectAssetDownloadManager.removeEventListener(EffectAssetDownloadManager.DOWNLOADER_READY, this.onEffectAssetDownloaderReady);
@ -125,7 +124,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadGeometry(): void
{
if(!this._structure) return;
if (!this._structure) return;
this._structure.initGeometry(HabboAvatarGeometry.geometry);
@ -136,7 +135,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadPartSets(): void
{
if(!this._structure) return;
if (!this._structure) return;
this._structure.initPartSets(HabboAvatarPartSets.partSets);
@ -149,7 +148,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{
const defaultActions = Nitro.instance.getConfiguration<string>('avatar.default.actions');
if(defaultActions) this._structure.initActions(Nitro.instance.core.asset, defaultActions);
if (defaultActions) this._structure.initActions(Nitro.instance.core.asset, defaultActions);
const request = new XMLHttpRequest();
@ -161,7 +160,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
request.onloadend = e =>
{
if(!this._structure) return;
if (!this._structure) return;
this._structure.updateActions(JSON.parse(request.responseText));
@ -184,7 +183,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadAnimations(): void
{
if(!this._structure) return;
if (!this._structure) return;
this._structure.initAnimation(HabboAvatarAnimations.animations);
@ -197,14 +196,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{
const defaultFigureData = Nitro.instance.getConfiguration<IFigureData>('avatar.default.figuredata');
if(!defaultFigureData || (typeof defaultFigureData === 'string'))
if (!defaultFigureData || (typeof defaultFigureData === 'string'))
{
NitroLogger.log('XML figuredata is no longer supported.');
this.logger.error('XML figuredata is no longer supported');
return;
}
if(this._structure) this._structure.initFigureData(defaultFigureData);
if (this._structure) this._structure.initFigureData(defaultFigureData);
const structureDownloader = new AvatarStructureDownload(Nitro.instance.getConfiguration<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData));
@ -222,7 +221,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaderReady(event: NitroEvent): void
{
if(!event) return;
if (!event) return;
this._figureMapReady = true;
@ -231,14 +230,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaded(event: NitroEvent): void
{
if(!event) return;
if (!event) return;
this._aliasCollection.reset();
}
private onEffectAssetDownloaderReady(event: NitroEvent): void
{
if(!event) return;
if (!event) return;
this._effectMapReady = true;
@ -247,20 +246,20 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onEffectAssetDownloaded(event: NitroEvent): void
{
if(!event) return;
if (!event) return;
this._aliasCollection.reset();
}
private checkReady(): void
{
if(this._isReady) return;
if (this._isReady) return;
if(!this._geometryReady || !this._partSetsReady || !this._actionsReady || !this._animationsReady || !this._figureMapReady || !this._effectMapReady || !this._structureReady) 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));
if (this.events) this.events.dispatchEvent(new NitroEvent(AvatarRenderEvent.AVATAR_RENDER_READY));
}
public createFigureContainer(figure: string): IAvatarFigureContainer
@ -270,25 +269,25 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public isFigureContainerReady(container: IAvatarFigureContainer): boolean
{
if(!this._avatarAssetDownloadManager) return false;
if (!this._avatarAssetDownloadManager) return false;
return this._avatarAssetDownloadManager.isAvatarFigureContainerReady(container);
}
public createAvatarImage(figure: string, size: string, gender: string, listener: IAvatarImageListener = null, effectListener: IAvatarEffectListener = null): IAvatarImage
{
if(!this._structure || !this._avatarAssetDownloadManager) return null;
if (!this._structure || !this._avatarAssetDownloadManager) return null;
const figureContainer = new AvatarFigureContainer(figure);
if(gender) this.validateAvatarFigure(figureContainer, gender);
if (gender) this.validateAvatarFigure(figureContainer, gender);
if(this._avatarAssetDownloadManager.isAvatarFigureContainerReady(figureContainer))
if (this._avatarAssetDownloadManager.isAvatarFigureContainerReady(figureContainer))
{
return new AvatarImage(this._structure, this._aliasCollection, figureContainer, size, this._effectAssetDownloadManager, effectListener);
}
if(!this._placeHolderFigure) this._placeHolderFigure = new AvatarFigureContainer(AvatarRenderManager.DEFAULT_FIGURE);
if (!this._placeHolderFigure) this._placeHolderFigure = new AvatarFigureContainer(AvatarRenderManager.DEFAULT_FIGURE);
this._avatarAssetDownloadManager.downloadAvatarFigure(figureContainer, listener);
@ -297,7 +296,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void
{
if(!this._avatarAssetDownloadManager) return;
if (!this._avatarAssetDownloadManager) return;
this._avatarAssetDownloadManager.downloadAvatarFigure(container, listener);
}
@ -308,17 +307,17 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const typeIds = this._structure.getMandatorySetTypeIds(gender, 2);
if(typeIds)
if (typeIds)
{
const figureData = this._structure.figureData;
for(const id of typeIds)
for (const id of typeIds)
{
if(!container.hasPartType(id))
if (!container.hasPartType(id))
{
const figurePartSet = this._structure.getDefaultPartSet(id, gender);
if(figurePartSet)
if (figurePartSet)
{
container.updatePart(id, figurePartSet.id, [0]);
@ -329,15 +328,15 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{
const setType = figureData.getSetType(id);
if(setType)
if (setType)
{
const figurePartSet = setType.getPartSet(container.getPartSetId(id));
if(!figurePartSet)
if (!figurePartSet)
{
const partSet = this._structure.getDefaultPartSet(id, gender);
if(partSet)
if (partSet)
{
container.updatePart(id, partSet.id, [0]);
@ -354,49 +353,49 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[] = null): number
{
if(!this._structure) return 0;
if (!this._structure) return 0;
const figureData = this._structure.figureData;
const parts = Array.from(container.getPartTypeIds());
let clubLevel = 0;
for(const part of parts)
for (const part of parts)
{
const set = figureData.getSetType(part);
if(!set) continue;
if (!set) continue;
const setId = container.getPartSetId(part);
const partSet = set.getPartSet(setId);
if(partSet)
if (partSet)
{
clubLevel = Math.max(partSet.clubLevel, clubLevel);
const palette = figureData.getPalette(set.paletteID);
const colors = container.getPartColorIds(part);
for(const colorId of colors)
for (const colorId of colors)
{
const color = palette.getColor(colorId);
if(!color) continue;
if (!color) continue;
clubLevel = Math.max(color.clubLevel, clubLevel);
}
}
}
if(!searchParts) searchParts = this._structure.getBodyPartsUnordered(AvatarSetType.FULL);
if (!searchParts) searchParts = this._structure.getBodyPartsUnordered(AvatarSetType.FULL);
for(const part of searchParts)
for (const part of searchParts)
{
const set = figureData.getSetType(part);
if(!set) continue;
if (!set) continue;
if(parts.indexOf(part) === -1) clubLevel = Math.max(set.optionalFromClubLevel(gender), clubLevel);
if (parts.indexOf(part) === -1) clubLevel = Math.max(set.optionalFromClubLevel(gender), clubLevel);
}
return clubLevel;
@ -418,7 +417,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const partSets: IFigurePartSet[] = this.resolveFigureSets(_arg_3);
for(const partSet of partSets)
for (const partSet of partSets)
{
container.savePartData(partSet.type, partSet.id, container.getColourIds(partSet.type));
}
@ -431,11 +430,11 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const structure = this.structureData;
const partSets: IFigurePartSet[] = [];
for(const _local_4 of k)
for (const _local_4 of k)
{
const partSet = structure.getFigurePartSet(_local_4);
if(partSet) partSets.push(partSet);
if (partSet) partSets.push(partSet);
}
return partSets;
@ -443,7 +442,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[]
{
if(!this._structure) return null;
if (!this._structure) return null;
return this._structure.getMandatorySetTypeIds(k, _arg_2);
}
@ -470,7 +469,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public get structureData(): IStructureData
{
if(this._structure) return this._structure.figureData;
if (this._structure) return this._structure.figureData;
return null;
}

View File

@ -1,5 +1,4 @@
import { IAssetManager } from '../../core/asset/IAssetManager';
import { NitroLogger } from '../../core/common/logger/NitroLogger';
import { EventDispatcher } from '../../core/events/EventDispatcher';
import { NitroEvent } from '../../core/events/NitroEvent';
import { Nitro } from '../Nitro';
@ -21,7 +20,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
private _missingMandatoryLibs: string[];
private _effectMap: Map<string, EffectAssetDownloadLibrary[]>;
private _initDownloadBuffer: [ number, IAvatarEffectListener][];
private _initDownloadBuffer: [number, IAvatarEffectListener][];
private _effectListeners: Map<string, IAvatarEffectListener[]>;
private _incompleteEffects: Map<string, EffectAssetDownloadLibrary[]>;
private _pendingDownloadQueue: EffectAssetDownloadLibrary[];
@ -66,7 +65,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
request.onloadend = e =>
{
if(request.responseText)
if (request.responseText)
{
const data = JSON.parse(request.responseText);
@ -88,23 +87,23 @@ export class EffectAssetDownloadManager extends EventDispatcher
catch (e)
{
NitroLogger.log(e);
this.logger.error(e);
}
}
private processEffectMap(data: any): void
{
if(!data) return;
if (!data) return;
for(const effect of data)
for (const effect of data)
{
if(!effect) continue;
if (!effect) continue;
const id = (effect.id as string);
const lib = (effect.lib as string);
const revision = (effect.revision || '');
if(this._libraryNames.indexOf(lib) >= 0) continue;
if (this._libraryNames.indexOf(lib) >= 0) continue;
this._libraryNames.push(lib);
@ -114,7 +113,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
let existing = this._effectMap.get(id);
if(!existing) existing = [];
if (!existing) existing = [];
existing.push(downloadLibrary);
@ -124,22 +123,22 @@ export class EffectAssetDownloadManager extends EventDispatcher
public downloadAvatarEffect(id: number, listener: IAvatarEffectListener): void
{
if(!this._isReady || !this._structure.renderManager.isReady)
if (!this._isReady || !this._structure.renderManager.isReady)
{
this._initDownloadBuffer.push([ id, listener ]);
this._initDownloadBuffer.push([id, listener]);
return;
}
const pendingLibraries = this.getAvatarEffectPendingLibraries(id);
if(pendingLibraries && pendingLibraries.length)
if (pendingLibraries && pendingLibraries.length)
{
if(listener && !listener.disposed)
if (listener && !listener.disposed)
{
let listeners = this._effectListeners.get(id.toString());
if(!listeners) listeners = [];
if (!listeners) listeners = [];
listeners.push(listener);
@ -148,24 +147,24 @@ export class EffectAssetDownloadManager extends EventDispatcher
this._incompleteEffects.set(id.toString(), pendingLibraries);
for(const library of pendingLibraries)
for (const library of pendingLibraries)
{
if(!library) continue;
if (!library) continue;
this.downloadLibrary(library);
}
}
else
{
if(listener && !listener.disposed) listener.resetEffect(id);
if (listener && !listener.disposed) listener.resetEffect(id);
}
}
private onAvatarRenderReady(event: NitroEvent): void
{
if(!event) return;
if (!event) return;
for(const [ id, listener ] of this._initDownloadBuffer)
for (const [id, listener] of this._initDownloadBuffer)
{
this.downloadAvatarEffect(id, listener);
}
@ -175,34 +174,34 @@ export class EffectAssetDownloadManager extends EventDispatcher
private onLibraryLoaded(event: AvatarRenderEffectLibraryEvent): void
{
if(!event || !event.library) return;
if (!event || !event.library) return;
const loadedEffects: string[] = [];
this._structure.registerAnimation(event.library.animation);
for(const [ id, libraries ] of this._incompleteEffects.entries())
for (const [id, libraries] of this._incompleteEffects.entries())
{
let isReady = true;
for(const library of libraries)
for (const library of libraries)
{
if(!library || library.isLoaded) continue;
if (!library || library.isLoaded) continue;
isReady = false;
break;
}
if(isReady)
if (isReady)
{
loadedEffects.push(id);
const listeners = this._effectListeners.get(id);
for(const listener of listeners)
for (const listener of listeners)
{
if(!listener || listener.disposed) continue;
if (!listener || listener.disposed) continue;
listener.resetEffect(parseInt(id));
}
@ -213,17 +212,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
}
}
for(const id of loadedEffects) this._incompleteEffects.delete(id);
for (const id of loadedEffects) this._incompleteEffects.delete(id);
let index = 0;
while(index < this._currentDownloads.length)
while (index < this._currentDownloads.length)
{
const download = this._currentDownloads[index];
if(download)
if (download)
{
if(download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1);
if (download.libraryName === event.library.libraryName) this._currentDownloads.splice(index, 1);
}
index++;
@ -234,19 +233,19 @@ export class EffectAssetDownloadManager extends EventDispatcher
{
const libraries = this._missingMandatoryLibs.slice();
for(const library of libraries)
for (const library of libraries)
{
if(!library) continue;
if (!library) continue;
const map = this._effectMap.get(library);
if(map) for(const effect of map) effect && this.downloadLibrary(effect);
if (map) for (const effect of map) effect && this.downloadLibrary(effect);
}
}
public isAvatarEffectReady(effect: number): boolean
{
if(!this._isReady || !this._structure.renderManager.isReady)
if (!this._isReady || !this._structure.renderManager.isReady)
{
return false;
}
@ -260,17 +259,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
{
const pendingLibraries: EffectAssetDownloadLibrary[] = [];
if(!this._structure) return pendingLibraries;
if (!this._structure) return pendingLibraries;
const libraries = this._effectMap.get(id.toString());
if(libraries)
if (libraries)
{
for(const library of libraries)
for (const library of libraries)
{
if(!library || library.isLoaded) continue;
if (!library || library.isLoaded) continue;
if(pendingLibraries.indexOf(library) === -1) pendingLibraries.push(library);
if (pendingLibraries.indexOf(library) === -1) pendingLibraries.push(library);
}
}
@ -279,9 +278,9 @@ export class EffectAssetDownloadManager extends EventDispatcher
private downloadLibrary(library: EffectAssetDownloadLibrary): void
{
if(!library || library.isLoaded) return;
if (!library || library.isLoaded) return;
if((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
if ((this._pendingDownloadQueue.indexOf(library) >= 0) || (this._currentDownloads.indexOf(library) >= 0)) return;
this._pendingDownloadQueue.push(library);
@ -290,7 +289,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
private processDownloadQueue(): void
{
while(this._pendingDownloadQueue.length)
while (this._pendingDownloadQueue.length)
{
const library = this._pendingDownloadQueue[0];

View File

@ -1,4 +1,3 @@
import { NitroLogger } from '../../../core/common/logger/NitroLogger';
import { EventDispatcher } from '../../../core/events/EventDispatcher';
import { NitroEvent } from '../../../core/events/NitroEvent';
import { IFigureSetData } from './IFigureSetData';
@ -32,9 +31,9 @@ export class AvatarStructureDownload extends EventDispatcher
{
const response = request.responseText;
if(!response || !response.length) throw new Error('invalid_figure_data');
if (!response || !response.length) throw new Error('invalid_figure_data');
if(this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response));
if (this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response));
this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE));
};
@ -47,7 +46,7 @@ export class AvatarStructureDownload extends EventDispatcher
catch (e)
{
NitroLogger.log(e);
this.logger.error(e);
}
}
}

View File

@ -1,4 +1,3 @@
import { NitroLogger } from '../../../core/common/logger/NitroLogger';
import { NitroManager } from '../../../core/common/NitroManager';
import { IConnection } from '../../../core/communication/connections/IConnection';
import { SocketConnectionEvent } from '../../../core/communication/events/SocketConnectionEvent';
@ -42,7 +41,7 @@ export class NitroCommunicationDemo extends NitroManager
{
const connection = this._communication.connection;
if(connection)
if (connection)
{
connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
@ -57,7 +56,7 @@ export class NitroCommunicationDemo extends NitroManager
{
const connection = this._communication.connection;
if(connection)
if (connection)
{
connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
@ -75,13 +74,13 @@ export class NitroCommunicationDemo extends NitroManager
{
const connection = this._communication.connection;
if(!connection) return;
if (!connection) return;
this._didConnect = true;
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
if(Nitro.instance.getConfiguration<boolean>('system.pong.manually', false)) this.startPonging();
if (Nitro.instance.getConfiguration<boolean>('system.pong.manually', false)) this.startPonging();
this.startHandshake(connection);
@ -94,18 +93,18 @@ export class NitroCommunicationDemo extends NitroManager
{
const connection = this._communication.connection;
if(!connection) return;
if (!connection) return;
this.stopPonging();
if(this._didConnect) this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, connection);
if (this._didConnect) this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, connection);
}
private onConnectionErrorEvent(event: CloseEvent): void
{
const connection = this._communication.connection;
if(!connection) return;
if (!connection) return;
this.stopPonging();
@ -114,11 +113,11 @@ export class NitroCommunicationDemo extends NitroManager
private tryAuthentication(connection: IConnection): void
{
if(!connection || !this.getSSO())
if (!connection || !this.getSSO())
{
if(!this.getSSO())
if (!this.getSSO())
{
NitroLogger.log('Login without an SSO ticket is not supported');
this.logger.error('Login without an SSO ticket is not supported');
}
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED, connection);
@ -131,14 +130,14 @@ export class NitroCommunicationDemo extends NitroManager
private onClientPingEvent(event: ClientPingEvent): void
{
if(!event || !event.connection) return;
if (!event || !event.connection) return;
this.sendPong(event.connection);
}
private onAuthenticatedEvent(event: AuthenticatedEvent): void
{
if(!event || !event.connection) return;
if (!event || !event.connection) return;
this.completeHandshake(event.connection);
@ -170,7 +169,7 @@ export class NitroCommunicationDemo extends NitroManager
private stopPonging(): void
{
if(!this._pongInterval) return;
if (!this._pongInterval) return;
clearInterval(this._pongInterval);
@ -181,7 +180,7 @@ export class NitroCommunicationDemo extends NitroManager
{
connection = ((connection || this._communication.connection) || null);
if(!connection) return;
if (!connection) return;
connection.send(new PongMessageComposer());
}

View File

@ -35,7 +35,7 @@ export class RoomContentLoader implements IFurnitureDataListener
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 ];
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 _logger: INitroLogger;
private _stateEvents: IEventDispatcher;
@ -98,7 +98,7 @@ export class RoomContentLoader implements IFurnitureDataListener
this.setFurnitureData();
for(const [ index, name ] of Nitro.instance.getConfiguration<string[]>('pet.types').entries()) this._pets[name] = index;
for (const [index, name] of Nitro.instance.getConfiguration<string[]>('pet.types').entries()) this._pets[name] = index;
}
public dispose(): void
@ -110,7 +110,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
this._sessionDataManager = sessionData;
if(this._waitingForSessionDataManager)
if (this._waitingForSessionDataManager)
{
this._waitingForSessionDataManager = false;
@ -125,7 +125,7 @@ export class RoomContentLoader implements IFurnitureDataListener
private setFurnitureData(): void
{
if(!this._sessionDataManager)
if (!this._sessionDataManager)
{
this._waitingForSessionDataManager = true;
@ -134,7 +134,7 @@ export class RoomContentLoader implements IFurnitureDataListener
const furnitureData = this._sessionDataManager.getAllFurnitureData(this);
if(!furnitureData) return;
if (!furnitureData) return;
this._sessionDataManager.removePendingFurniDataListener(this);
@ -145,42 +145,42 @@ export class RoomContentLoader implements IFurnitureDataListener
private processFurnitureData(furnitureData: IFurnitureData[]): void
{
if(!furnitureData) return;
if (!furnitureData) return;
for(const furniture of furnitureData)
for (const furniture of furnitureData)
{
if(!furniture) continue;
if (!furniture) continue;
const id = furniture.id;
let className = furniture.className;
if(furniture.hasIndexedColor) className = ((className + '*') + furniture.colorIndex);
if (furniture.hasIndexedColor) className = ((className + '*') + furniture.colorIndex);
const revision = furniture.revision;
const adUrl = furniture.adUrl;
if(adUrl && adUrl.length > 0) this._objectTypeAdUrls.set(className, adUrl);
if (adUrl && adUrl.length > 0) this._objectTypeAdUrls.set(className, adUrl);
let name = furniture.className;
if(furniture.type === FurnitureType.FLOOR)
if (furniture.type === FurnitureType.FLOOR)
{
this._activeObjectTypes.set(id, className);
this._activeObjectTypeIds.set(className, id);
if(!this._activeObjects[name]) this._activeObjects[name] = 1;
if (!this._activeObjects[name]) this._activeObjects[name] = 1;
}
else if(furniture.type === FurnitureType.WALL)
else if (furniture.type === FurnitureType.WALL)
{
if(name === 'post.it')
if (name === 'post.it')
{
className = 'post_it';
name = 'post_it';
}
if(name === 'post.it.vd')
if (name === 'post.it.vd')
{
className = 'post_it_vd';
name = 'post_id_vd';
@ -189,12 +189,12 @@ export class RoomContentLoader implements IFurnitureDataListener
this._wallItemTypes.set(id, className);
this._wallItemTypeIds.set(className, id);
if(!this._wallItems[name]) this._wallItems[name] = 1;
if (!this._wallItems[name]) this._wallItems[name] = 1;
}
const existingRevision = this._furniRevisions.get(name);
if(revision > existingRevision)
if (revision > existingRevision)
{
this._furniRevisions.delete(name);
this._furniRevisions.set(name, revision);
@ -213,7 +213,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
let type = this._wallItemTypes.get(typeId);
if((type === 'poster') && (extra !== null)) type = (type + extra);
if ((type === 'poster') && (extra !== null)) type = (type + extra);
return this.removeColorIndex(type);
}
@ -222,7 +222,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const type = this._activeObjectTypes.get(typeId);
if(!type) return -1;
if (!type) return -1;
return this.getColorIndexFromName(type);
}
@ -231,29 +231,29 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const type = this._wallItemTypes.get(typeId);
if(!type) return -1;
if (!type) return -1;
return this.getColorIndexFromName(type);
}
private getColorIndexFromName(name: string): number
{
if(!name) return -1;
if (!name) return -1;
const index = name.indexOf('*');
if(index === -1) return 0;
if (index === -1) return 0;
return parseInt(name.substr(index + 1));
}
private removeColorIndex(name: string): string
{
if(!name) return null;
if (!name) return null;
const index = name.indexOf('*');
if(index === -1) return name;
if (index === -1) return name;
return name.substr(0, index);
}
@ -262,7 +262,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const value = this._objectTypeAdUrls.get(type);
if(!value) return '';
if (!value) return '';
return value;
}
@ -271,7 +271,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const colorResults = this._petColors.get(petIndex);
if(!colorResults) return null;
if (!colorResults) return null;
return colorResults.get(paletteIndex);
}
@ -281,11 +281,11 @@ export class RoomContentLoader implements IFurnitureDataListener
const colorResults = this._petColors.get(petIndex);
const results: PetColorResult[] = [];
if(colorResults)
if (colorResults)
{
for(const result of colorResults.values())
for (const result of colorResults.values())
{
if(result.tag === tagName) results.push(result);
if (result.tag === tagName) results.push(result);
}
}
@ -294,15 +294,15 @@ export class RoomContentLoader implements IFurnitureDataListener
public getCollection(name: string): IGraphicAssetCollection
{
if(!name) return null;
if (!name) return null;
const existing = this._collections.get(name);
if(!existing)
if (!existing)
{
const globalCollection = Nitro.instance.core.asset.getCollection(name);
if(globalCollection)
if (globalCollection)
{
this._collections.set(name, globalCollection);
@ -317,18 +317,18 @@ export class RoomContentLoader implements IFurnitureDataListener
public getGifCollection(name: string): GraphicAssetGifCollection
{
if(!name) return null;
if (!name) return null;
return this._gifCollections.get(name) || null;
}
public getImage(name: string): HTMLImageElement
{
if(!name) return null;
if (!name) return null;
const existing = this._images.get(name);
if(!existing) return null;
if (!existing) return null;
const image = new Image();
@ -341,14 +341,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const collection = this.getCollection(collectionName);
if(!collection) return false;
if (!collection) return false;
return collection.addAsset(assetName, texture, override, 0, 0, false, false);
}
public createGifCollection(collectionName: string, textures: Texture<Resource>[], durations: number[]): GraphicAssetGifCollection
{
if(!collectionName || !textures || !durations) return null;
if (!collectionName || !textures || !durations) return null;
const collection = new GraphicAssetGifCollection(collectionName, textures, durations);
@ -359,7 +359,7 @@ export class RoomContentLoader implements IFurnitureDataListener
private createCollection(data: IAssetData, spritesheet: Spritesheet): GraphicAssetCollection
{
if(!data || !spritesheet) return null;
if (!data || !spritesheet) return null;
const collection = new GraphicAssetCollection(data, spritesheet);
@ -367,12 +367,12 @@ export class RoomContentLoader implements IFurnitureDataListener
const petIndex = this._pets[collection.name];
if(petIndex !== undefined)
if (petIndex !== undefined)
{
const keys = collection.getPaletteNames();
const palettes: Map<number, PetColorResult> = new Map();
for(const key of keys)
for (const key of keys)
{
const palette = collection.getPalette(key);
const paletteData = data.palettes[key];
@ -395,14 +395,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const category = this.getCategoryForType(type);
switch(category)
switch (category)
{
case RoomObjectCategory.FLOOR:
return RoomContentLoader.PLACE_HOLDER;
case RoomObjectCategory.WALL:
return RoomContentLoader.PLACE_HOLDER_WALL;
default:
if(this._pets[type] !== undefined) return RoomContentLoader.PLACE_HOLDER_PET;
if (this._pets[type] !== undefined) return RoomContentLoader.PLACE_HOLDER_PET;
return RoomContentLoader.PLACE_HOLDER_DEFAULT;
}
@ -410,27 +410,27 @@ export class RoomContentLoader implements IFurnitureDataListener
public getCategoryForType(type: string): number
{
if(!type) return RoomObjectCategory.MINIMUM;
if (!type) return RoomObjectCategory.MINIMUM;
if(this._activeObjects[type] !== undefined) return RoomObjectCategory.FLOOR;
if (this._activeObjects[type] !== undefined) return RoomObjectCategory.FLOOR;
if(this._wallItems[type] !== undefined) return RoomObjectCategory.WALL;
if (this._wallItems[type] !== undefined) return RoomObjectCategory.WALL;
if(this._pets[type] !== undefined) return RoomObjectCategory.UNIT;
if (this._pets[type] !== undefined) return RoomObjectCategory.UNIT;
if(type.indexOf('poster') === 0) return RoomObjectCategory.WALL;
if (type.indexOf('poster') === 0) return RoomObjectCategory.WALL;
if(type === 'room') return RoomObjectCategory.ROOM;
if (type === 'room') return RoomObjectCategory.ROOM;
if(type === RoomObjectUserType.USER) return RoomObjectCategory.UNIT;
if (type === RoomObjectUserType.USER) return RoomObjectCategory.UNIT;
if(type === RoomObjectUserType.PET) return RoomObjectCategory.UNIT;
if (type === RoomObjectUserType.PET) return RoomObjectCategory.UNIT;
if(type === RoomObjectUserType.BOT) return RoomObjectCategory.UNIT;
if (type === RoomObjectUserType.BOT) return RoomObjectCategory.UNIT;
if(type === RoomObjectUserType.RENTABLE_BOT) return RoomObjectCategory.UNIT;
if (type === RoomObjectUserType.RENTABLE_BOT) return RoomObjectCategory.UNIT;
if((type === RoomContentLoader.TILE_CURSOR) || (type === RoomContentLoader.SELECTION_ARROW)) return RoomObjectCategory.CURSOR;
if ((type === RoomContentLoader.TILE_CURSOR) || (type === RoomContentLoader.SELECTION_ARROW)) return RoomObjectCategory.CURSOR;
return RoomObjectCategory.MINIMUM;
}
@ -444,7 +444,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
type = RoomObjectUserType.getRealType(type);
if(type === RoomObjectVisualizationType.USER) return false;
if (type === RoomObjectVisualizationType.USER) return false;
return true;
}
@ -454,13 +454,13 @@ export class RoomContentLoader implements IFurnitureDataListener
let typeName: string = null;
let assetUrls: string[] = [];
if(type && (type.indexOf(',') >= 0))
if (type && (type.indexOf(',') >= 0))
{
typeName = type;
type = typeName.split(',')[0];
}
if(typeName)
if (typeName)
{
assetUrls = this.getAssetUrls(typeName, param, true);
}
@ -469,7 +469,7 @@ export class RoomContentLoader implements IFurnitureDataListener
assetUrls = this.getAssetUrls(type, param, true);
}
if(assetUrls && assetUrls.length)
if (assetUrls && assetUrls.length)
{
const url = assetUrls[0];
@ -481,18 +481,18 @@ export class RoomContentLoader implements IFurnitureDataListener
{
image.onerror = null;
this._images.set(([ type, param ].join('_')), image);
this._images.set(([type, param].join('_')), image);
this._iconListener.onRoomContentLoaded(id, [ type, param ].join('_'), true);
this._iconListener.onRoomContentLoaded(id, [type, param].join('_'), true);
};
image.onerror = () =>
{
image.onload = null;
this._logger.error('Failed to download asset: ' + url);
this._logger.error('Failed to download asset', url);
this._iconListener.onRoomContentLoaded(id, [ type, param ].join('_'), false);
this._iconListener.onRoomContentLoaded(id, [type, param].join('_'), false);
};
return true;
@ -505,18 +505,18 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const assetUrls: string[] = this.getAssetUrls(type);
if(!assetUrls || !assetUrls.length) return;
if (!assetUrls || !assetUrls.length) return;
if((this._pendingContentTypes.indexOf(type) >= 0) || this.getOrRemoveEventDispatcher(type)) return;
if ((this._pendingContentTypes.indexOf(type) >= 0) || this.getOrRemoveEventDispatcher(type)) return;
this._pendingContentTypes.push(type);
this._events.set(type, events);
const loader = new Loader();
for(const url of assetUrls)
for (const url of assetUrls)
{
if(!url || !url.length) continue;
if (!url || !url.length) continue;
loader
.add({
@ -531,9 +531,9 @@ export class RoomContentLoader implements IFurnitureDataListener
const onDownloaded = (status: boolean, url: string) =>
{
if(!status)
if (!status)
{
this._logger.error('Failed to download asset: ' + url);
this._logger.error('Failed to download asset', url);
loader.destroy();
@ -544,13 +544,13 @@ export class RoomContentLoader implements IFurnitureDataListener
remaining--;
if(!remaining)
if (!remaining)
{
loader.destroy();
const events = this._events.get(type);
if(!events) return;
if (!events) return;
events.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type));
@ -560,11 +560,11 @@ export class RoomContentLoader implements IFurnitureDataListener
loader.load((loader, resources) =>
{
for(const key in resources)
for (const key in resources)
{
const resource = resources[key];
if(!resource || resource.error || !resource.xhr)
if (!resource || resource.error || !resource.xhr)
{
onDownloaded(false, resource.url);
@ -573,7 +573,7 @@ export class RoomContentLoader implements IFurnitureDataListener
const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream');
if(resourceType === 'application/octet-stream')
if (resourceType === 'application/octet-stream')
{
const nitroBundle = new NitroBundle(resource.data);
@ -592,7 +592,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const spritesheetData = data.spritesheet;
if(!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
if (!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
{
this.createCollection(data, null);
@ -613,7 +613,7 @@ export class RoomContentLoader implements IFurnitureDataListener
});
};
if(baseTexture.valid)
if (baseTexture.valid)
{
createAsset();
}
@ -633,7 +633,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const existing = this._objectAliases.get(name);
if(!existing) return name;
if (!existing) return name;
return existing;
}
@ -642,49 +642,49 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const existing = this._objectOriginalNames.get(name);
if(!existing) return name;
if (!existing) return name;
return existing;
}
public getAssetUrls(type: string, param: string = null, icon: boolean = false): string[]
{
switch(type)
switch (type)
{
case RoomContentLoader.PLACE_HOLDER:
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER) ];
return [this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER)];
case RoomContentLoader.PLACE_HOLDER_WALL:
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER_WALL) ];
return [this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER_WALL)];
case RoomContentLoader.PLACE_HOLDER_PET:
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER_PET) ];
return [this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER_PET)];
case RoomContentLoader.ROOM:
return [ this.getAssetUrlWithGenericBase('room') ];
return [this.getAssetUrlWithGenericBase('room')];
case RoomContentLoader.TILE_CURSOR:
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.TILE_CURSOR) ];
return [this.getAssetUrlWithGenericBase(RoomContentLoader.TILE_CURSOR)];
case RoomContentLoader.SELECTION_ARROW:
return [ this.getAssetUrlWithGenericBase(RoomContentLoader.SELECTION_ARROW) ];
return [this.getAssetUrlWithGenericBase(RoomContentLoader.SELECTION_ARROW)];
default: {
const category = this.getCategoryForType(type);
if((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL))
if ((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL))
{
const name = this.getAssetAliasName(type);
let assetUrl = (icon ? this.getAssetUrlWithFurniIconBase(name) : this.getAssetUrlWithFurniBase(type));
if(icon)
if (icon)
{
const active = (param && (param !== '') && (this._activeObjectTypeIds.has((name + '*' + param))));
assetUrl = (assetUrl.replace(/%param%/gi, (active ? ('_' + param) : '')));
}
return [ assetUrl ];
return [assetUrl];
}
if(category === RoomObjectCategory.UNIT)
if (category === RoomObjectCategory.UNIT)
{
return [ this.getAssetUrlWithPetBase(type) ];
return [this.getAssetUrlWithPetBase(type)];
}
return null;
@ -697,14 +697,14 @@ export class RoomContentLoader implements IFurnitureDataListener
let assetName: string = null;
let assetUrls: string[] = [];
if(type &&( type.indexOf(',') >= 0))
if (type && (type.indexOf(',') >= 0))
{
assetName = type;
type = assetName.split(',')[0];
}
if(assetName)
if (assetName)
{
assetUrls = this.getAssetUrls(assetName, colorIndex, true);
}
@ -713,7 +713,7 @@ export class RoomContentLoader implements IFurnitureDataListener
assetUrls = this.getAssetUrls(type, colorIndex, true);
}
if(assetUrls && assetUrls.length) return assetUrls[0];
if (assetUrls && assetUrls.length) return assetUrls[0];
return null;
}
@ -742,7 +742,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const model = object && object.model;
if(!model) return;
if (!model) return;
model.setValue(RoomObjectVariable.OBJECT_ROOM_ID, roomId);
}
@ -751,7 +751,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{
const existing = this._events.get(type);
if(remove) this._events.delete(type);
if (remove) this._events.delete(type);
return existing;
}

File diff suppressed because it is too large Load Diff

View File

@ -348,7 +348,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
this.onRoomObjectDataRequestEvent((event as RoomObjectDataRequestEvent), roomId);
return;
default:
NitroLogger.log(`Unhandled Event: ${event.constructor.name}`, `Object ID: ${event.object.id}`);
NitroLogger.warn('Unhandled Event', event.constructor.name, 'Object ID', event.object.id);
return;
}
}

View File

@ -74,23 +74,23 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
{
const logic = this.getLogicType(type);
if(!logic) return null;
if (!logic) return null;
const instance = (new logic() as IRoomObjectEventHandler);
if(!instance) return null;
if (!instance) return null;
instance.eventDispatcher = this._events;
if(!this._cachedEvents.get(type))
if (!this._cachedEvents.get(type))
{
this._cachedEvents.set(type, true);
const eventTypes = instance.getEventTypes();
for(const eventType of eventTypes)
for (const eventType of eventTypes)
{
if(!eventType) continue;
if (!eventType) continue;
this.registerEventType(eventType);
}
@ -101,13 +101,13 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
private registerEventType(type: string): void
{
if(this._registeredEvents.get(type)) return;
if (this._registeredEvents.get(type)) return;
this._registeredEvents.set(type, true);
for(const func of this._functions)
for (const func of this._functions)
{
if(!func) continue;
if (!func) continue;
this._events.addEventListener(type, func);
}
@ -115,15 +115,15 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public registerEventFunction(func: Function): void
{
if(!func) return;
if (!func) return;
if(this._functions.indexOf(func) >= 0) return;
if (this._functions.indexOf(func) >= 0) return;
this._functions.push(func);
for(const eventType of this._registeredEvents.keys())
for (const eventType of this._registeredEvents.keys())
{
if(!eventType) continue;
if (!eventType) continue;
this._events.addEventListener(eventType, func);
}
@ -131,17 +131,17 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public removeEventFunction(func: Function): void
{
if(!func) return;
if (!func) return;
const index = this._functions.indexOf(func);
if(index === -1) return;
if (index === -1) return;
this._functions.splice(index, 1);
for(const event of this._registeredEvents.keys())
for (const event of this._registeredEvents.keys())
{
if(!event) continue;
if (!event) continue;
this._events.removeEventListener(event, func);
}
@ -149,11 +149,11 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public getLogicType(type: string): typeof RoomObjectLogicBase
{
if(!type) return null;
if (!type) return null;
let logic: typeof RoomObjectLogicBase = null;
switch(type)
switch (type)
{
case RoomObjectLogicType.ROOM:
logic = RoomLogic;
@ -354,9 +354,9 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
break;
}
if(!logic)
if (!logic)
{
NitroLogger.log(`Unknown Logic: ${ type }`);
NitroLogger.warn('Unknown Logic', type);
return null;
}

View File

@ -63,18 +63,18 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
{
const visualization = this.getVisualizationType(type);
if(!visualization) return null;
if (!visualization) return null;
return new visualization();
}
public getVisualizationType(type: string): typeof RoomObjectSpriteVisualization
{
if(!type) return null;
if (!type) return null;
let visualization: typeof RoomObjectSpriteVisualization = null;
switch(type)
switch (type)
{
case RoomObjectVisualizationType.ROOM:
visualization = RoomVisualization;
@ -185,9 +185,9 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
break;
}
if(!visualization)
if (!visualization)
{
NitroLogger.log(`Unknown Visualization: ${ type }`);
NitroLogger.log('Unknown Visualization', type);
return null;
}
@ -199,11 +199,11 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
{
const existing = this._visualizationDatas.get(type);
if(existing) return existing;
if (existing) return existing;
let visualizationData: IObjectVisualizationData = null;
switch(visualization)
switch (visualization)
{
case RoomObjectVisualizationType.FURNITURE_STATIC:
case RoomObjectVisualizationType.FURNITURE_GIFT_WRAPPED:
@ -255,21 +255,21 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
break;
}
if(!visualizationData) return null;
if (!visualizationData) return null;
if(!visualizationData.initialize(asset))
if (!visualizationData.initialize(asset))
{
visualizationData.dispose();
return null;
}
if((visualizationData instanceof AvatarVisualizationData) || (visualizationData instanceof FurnitureMannequinVisualizationData))
if ((visualizationData instanceof AvatarVisualizationData) || (visualizationData instanceof FurnitureMannequinVisualizationData))
{
visualizationData.avatarManager = Nitro.instance.avatar;
}
if(RoomObjectVisualizationFactory.CACHING_ENABLED) this._visualizationDatas.set(type, visualizationData);
if (RoomObjectVisualizationFactory.CACHING_ENABLED) this._visualizationDatas.set(type, visualizationData);
return visualizationData;
}

View File

@ -19,7 +19,7 @@ export class FurnitureYoutubeLogic extends FurnitureLogic
{
super.update(time);
if(!this.object.model.getValue<string>(RoomObjectVariable.SESSION_URL_PREFIX))
if (!this.object.model.getValue<string>(RoomObjectVariable.SESSION_URL_PREFIX))
{
this.eventDispatcher.dispatchEvent(new RoomObjectDataRequestEvent(RoomObjectDataRequestEvent.RODRE_URL_PREFIX, this.object));
}
@ -27,9 +27,7 @@ export class FurnitureYoutubeLogic extends FurnitureLogic
public useObject(): void
{
if(!this.object || !this.eventDispatcher) return;
console.log(this.object);
if (!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.YOUTUBE, this.object));
}

View File

@ -8,15 +8,15 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
private _particleSystems: AdvancedMap<number, FurnitureParticleSystem>;
private _currentParticleSystem: FurnitureParticleSystem;
public dispose():void
public dispose(): void
{
super.dispose();
this._currentParticleSystem = null;
if(this._particleSystems)
if (this._particleSystems)
{
for(const particleSystem of this._particleSystems.getValues()) particleSystem.dispose();
for (const particleSystem of this._particleSystems.getValues()) particleSystem.dispose();
this._particleSystems = null;
}
@ -24,25 +24,25 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
protected updateObject(scale: number, direction: number): boolean
{
if(super.updateObject(scale, direction))
if (super.updateObject(scale, direction))
{
if(!this._particleSystems)
if (!this._particleSystems)
{
this._Str_18684();
if(this._particleSystems) this._currentParticleSystem = this._particleSystems.getValue(scale);
if (this._particleSystems) this._currentParticleSystem = this._particleSystems.getValue(scale);
else NitroLogger.log(('ERROR Particle systems could not be read! ' + this.object.type));
else NitroLogger.log('ERROR Particle systems could not be read!', this.object.type);
}
else
{
if((scale !== this._scale) || (this._particleSystems.getValue(scale) !== this._currentParticleSystem))
if ((scale !== this._scale) || (this._particleSystems.getValue(scale) !== this._currentParticleSystem))
{
const particleSystem = this._particleSystems.getValue(scale);
particleSystem._Str_17988(this._currentParticleSystem);
if(this._currentParticleSystem) this._currentParticleSystem.reset();
if (this._currentParticleSystem) this._currentParticleSystem.reset();
this._currentParticleSystem = particleSystem;
}
@ -54,30 +54,30 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
return false;
}
protected updateSprites(scale: number, update: boolean, animation: number):void
protected updateSprites(scale: number, update: boolean, animation: number): void
{
super.updateSprites(scale, update, animation);
if(this._currentParticleSystem) this._currentParticleSystem.updateSprites();
if (this._currentParticleSystem) this._currentParticleSystem.updateSprites();
}
protected updateAnimation(scale: number): number
{
if(this._currentParticleSystem) this._currentParticleSystem.updateAnimation();
if (this._currentParticleSystem) this._currentParticleSystem.updateAnimation();
return super.updateAnimation(scale);
}
protected setAnimation(id: number):void
protected setAnimation(id: number): void
{
if(this._currentParticleSystem) this._currentParticleSystem.setAnimation(id);
if (this._currentParticleSystem) this._currentParticleSystem.setAnimation(id);
super.setAnimation(id);
}
protected getLayerYOffset(scale: number, direction: number, layerId: number): number
{
if(this._currentParticleSystem && this._currentParticleSystem.controlsSprite(layerId))
if (this._currentParticleSystem && this._currentParticleSystem.controlsSprite(layerId))
{
return this._currentParticleSystem.getLayerYOffset(scale, direction, layerId);
}
@ -87,15 +87,15 @@ export class FurnitureFireworksVisualization extends FurnitureAnimatedVisualizat
private _Str_18684(): boolean
{
if(!this.object || !this.object.model) return false;
if (!this.object || !this.object.model) return false;
const fireworksData = this.object.model.getValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA);
if(!fireworksData || !fireworksData.length) return false;
if (!fireworksData || !fireworksData.length) return false;
this._particleSystems = new AdvancedMap();
for(const particleData of fireworksData)
for (const particleData of fireworksData)
{
const size = particleData.size;
const particleSystem = new FurnitureParticleSystem(this);

View File

@ -14,7 +14,7 @@ export class TileObjectMap
let index = 0;
while(index < _arg_2)
while (index < _arg_2)
{
this._tileObjectMap.set(index, new Map());
@ -27,9 +27,9 @@ export class TileObjectMap
public clear(): void
{
for(const k of this._tileObjectMap.values())
for (const k of this._tileObjectMap.values())
{
if(!k) continue;
if (!k) continue;
k.clear();
}
@ -41,7 +41,7 @@ export class TileObjectMap
{
this.clear();
for(const _local_2 of k) this.addRoomObject(_local_2);
for (const _local_2 of k) this.addRoomObject(_local_2);
}
public dispose(): void
@ -53,63 +53,63 @@ export class TileObjectMap
public getObjectIntTile(k: number, _arg_2: number): IRoomObject
{
if((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
if ((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
{
const existing = this._tileObjectMap.get(_arg_2);
if(existing) return existing.get(k);
if (existing) return existing.get(k);
}
return null;
}
public setObjectInTile(k: number, _arg_2: number, _arg_3:IRoomObject): void
public setObjectInTile(k: number, _arg_2: number, _arg_3: IRoomObject): void
{
if(!_arg_3.isReady)
if (!_arg_3.isReady)
{
NitroLogger.log('Assigning non initialized object to tile object map!');
return;
}
if((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
if ((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
{
const existing = this._tileObjectMap.get(_arg_2);
if(existing) existing.set(k, _arg_3);
if (existing) existing.set(k, _arg_3);
}
}
public addRoomObject(k: IRoomObject): void
{
if(!k || !k.model || !k.isReady) return;
if (!k || !k.model || !k.isReady) return;
const location = k.getLocation();
const direction = k.getDirection();
if(!location || !direction) return;
if (!location || !direction) return;
let sizeX = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_X);
let sizeY = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_Y);
if(sizeX < 1) sizeX = 1;
if(sizeY < 1) sizeY = 1;
if (sizeX < 1) sizeX = 1;
if (sizeY < 1) sizeY = 1;
const directionNumber = ((Math.trunc((direction.x + 45)) % 360) / 90);
if((directionNumber === 1) || (directionNumber === 3)) [ sizeX, sizeY ] = [ sizeY, sizeX ];
if ((directionNumber === 1) || (directionNumber === 3)) [sizeX, sizeY] = [sizeY, sizeX];
let y = location.y;
while(y < (location.y + sizeY))
while (y < (location.y + sizeY))
{
let x = location.x;
while(x < (location.x + sizeX))
while (x < (location.x + sizeX))
{
const roomObject = this.getObjectIntTile(x, y);
if((!(roomObject)) || ((!(roomObject === k)) && (roomObject.getLocation().z <= location.z)))
if ((!(roomObject)) || ((!(roomObject === k)) && (roomObject.getLocation().z <= location.z)))
{
this.setObjectInTile(x, y, k);
}