This commit is contained in:
Bill 2022-11-08 16:50:16 -05:00
parent 0508af31e8
commit b3abc727cd
166 changed files with 3501 additions and 3503 deletions

View File

@ -30,7 +30,7 @@ export class NitroLogger implements INitroLogger
public printMessage(modus: string, ...message: any[]): void public printMessage(modus: string, ...message: any[]): void
{ {
if (!this._print) return; if(!this._print) return;
NitroLogger.log(this._name, modus, ...message); NitroLogger.log(this._name, modus, ...message);
} }

View File

@ -1,5 +1,3 @@
import { INitroManager } from '../common'; import { INitroManager } from '../common';
export interface IConfigurationManager extends INitroManager export type IConfigurationManager = INitroManager
{
}

View File

@ -8,21 +8,21 @@ export class NitroConfiguration
public static parseConfiguration(data: { [index: string]: any }, overrides: boolean = false): boolean public static parseConfiguration(data: { [index: string]: any }, overrides: boolean = false): boolean
{ {
if (!data) return false; if(!data) return false;
try try
{ {
const regex = new RegExp(/\${(.*?)}/g); const regex = new RegExp(/\${(.*?)}/g);
for (const key in data) for(const key in data)
{ {
let value = data[key]; let value = data[key];
if (typeof value === 'string') value = this.interpolate((value as string), regex); if(typeof value === 'string') value = this.interpolate((value as string), regex);
if (this._definitions.has(key)) if(this._definitions.has(key))
{ {
if (overrides) this.setValue(key, value); if(overrides) this.setValue(key, value);
} }
else else
{ {
@ -43,17 +43,17 @@ export class NitroConfiguration
public static interpolate(value: string, regex: RegExp = null): string public static interpolate(value: string, regex: RegExp = null): string
{ {
if (!regex) regex = new RegExp(/\${(.*?)}/g); if(!regex) regex = new RegExp(/\${(.*?)}/g);
const pieces = value.match(regex); const pieces = value.match(regex);
if (pieces && pieces.length) if(pieces && pieces.length)
{ {
for (const piece of pieces) for(const piece of pieces)
{ {
const existing = (this._definitions.get(this.removeInterpolateKey(piece)) as string); const existing = (this._definitions.get(this.removeInterpolateKey(piece)) as string);
if (existing) (value = value.replace(piece, existing)); if(existing) (value = value.replace(piece, existing));
} }
} }
@ -69,9 +69,9 @@ export class NitroConfiguration
{ {
let existing = this._definitions.get(key); let existing = this._definitions.get(key);
if (existing === undefined) if(existing === undefined)
{ {
if (this._missingKeys.indexOf(key) >= 0) return value; if(this._missingKeys.indexOf(key) >= 0) return value;
this._missingKeys.push(key); this._missingKeys.push(key);
NitroLogger.warn(`Missing configuration key: ${key}`); NitroLogger.warn(`Missing configuration key: ${key}`);
@ -88,13 +88,13 @@ export class NitroConfiguration
let last = this._config; let last = this._config;
for (let i = 0; i < parts.length; i++) for(let i = 0; i < parts.length; i++)
{ {
const part = parts[i].toString(); const part = parts[i].toString();
if (i !== (parts.length - 1)) if(i !== (parts.length - 1))
{ {
if (!last[part]) last[part] = {}; if(!last[part]) last[part] = {};
last = last[part]; last = last[part];

View File

@ -22,33 +22,33 @@ export class AssetManager extends Disposable implements IAssetManager
public getTexture(name: string): Texture<Resource> public getTexture(name: string): Texture<Resource>
{ {
if (!name) return null; if(!name) return null;
const existing = this._textures.get(name); const existing = this._textures.get(name);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public setTexture(name: string, texture: Texture<Resource>): void public setTexture(name: string, texture: Texture<Resource>): void
{ {
if (!name || !texture) return; if(!name || !texture) return;
this._textures.set(name, texture); this._textures.set(name, texture);
} }
public getAsset(name: string): IGraphicAsset 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); const existing = collection.getAsset(name);
if (!existing) continue; if(!existing) continue;
return existing; return existing;
} }
@ -58,24 +58,24 @@ export class AssetManager extends Disposable implements IAssetManager
public getCollection(name: string): IGraphicAssetCollection public getCollection(name: string): IGraphicAssetCollection
{ {
if (!name) return null; if(!name) return null;
const existing = this._collections.get(name); const existing = this._collections.get(name);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection public createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection
{ {
if (!data) return null; if(!data) return null;
const collection = new GraphicAssetCollection(data, spritesheet); 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); this._collections.set(collection.name, collection);
} }
@ -90,7 +90,7 @@ export class AssetManager extends Disposable implements IAssetManager
public downloadAssets(assetUrls: string[], cb: (status: boolean) => void): void public downloadAssets(assetUrls: string[], cb: (status: boolean) => void): void
{ {
if (!assetUrls || !assetUrls.length) if(!assetUrls || !assetUrls.length)
{ {
cb(true); cb(true);
@ -99,9 +99,9 @@ export class AssetManager extends Disposable implements IAssetManager
const loader = new Loader(); const loader = new Loader();
for (const url of assetUrls) for(const url of assetUrls)
{ {
if (!url) continue; if(!url) continue;
loader loader
.add({ .add({
@ -116,7 +116,7 @@ export class AssetManager extends Disposable implements IAssetManager
const onDownloaded = (status: boolean, url: string) => const onDownloaded = (status: boolean, url: string) =>
{ {
if (!status) if(!status)
{ {
NitroLogger.error('Failed to download asset', url); NitroLogger.error('Failed to download asset', url);
@ -129,7 +129,7 @@ export class AssetManager extends Disposable implements IAssetManager
remaining--; remaining--;
if (!remaining) if(!remaining)
{ {
loader.destroy(); loader.destroy();
@ -141,11 +141,11 @@ export class AssetManager extends Disposable implements IAssetManager
loader.load((loader, resources) => loader.load((loader, resources) =>
{ {
for (const key in resources) for(const key in resources)
{ {
const resource = resources[key]; const resource = resources[key];
if (!resource || resource.error || !resource.xhr) if(!resource || resource.error || !resource.xhr)
{ {
onDownloaded(false, resource.url); onDownloaded(false, resource.url);
@ -154,7 +154,7 @@ export class AssetManager extends Disposable implements IAssetManager
const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream'); 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); const nitroBundle = new NitroBundle(resource.data);
@ -166,12 +166,12 @@ export class AssetManager extends Disposable implements IAssetManager
continue; 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 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); const texture = new Texture(baseTexture);
@ -203,7 +203,7 @@ export class AssetManager extends Disposable implements IAssetManager
{ {
const spritesheetData = data.spritesheet; const spritesheetData = data.spritesheet;
if (!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length) if(!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
{ {
this.createCollection(data, null); this.createCollection(data, null);
@ -224,7 +224,7 @@ export class AssetManager extends Disposable implements IAssetManager
}); });
}; };
if (baseTexture.valid) if(baseTexture.valid)
{ {
createAsset(); createAsset();
} }

View File

@ -23,7 +23,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
constructor(data: IAssetData, spritesheet: Spritesheet) constructor(data: IAssetData, spritesheet: Spritesheet)
{ {
if (!data) throw new Error('invalid_collection'); if(!data) throw new Error('invalid_collection');
this._name = data.name; this._name = data.name;
this._baseTexture = ((spritesheet && spritesheet.baseTexture) || null); this._baseTexture = ((spritesheet && spritesheet.baseTexture) || null);
@ -33,7 +33,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
this._palettes = new Map(); this._palettes = new Map();
this._paletteAssetNames = []; this._paletteAssetNames = [];
if (spritesheet) this.addLibraryAsset(spritesheet.textures); if(spritesheet) this.addLibraryAsset(spritesheet.textures);
this.define(data); this.define(data);
} }
@ -45,23 +45,23 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
public dispose(): void public dispose(): void
{ {
if (this._palettes) if(this._palettes)
{ {
for (const palette of this._palettes.values()) palette.dispose(); for(const palette of this._palettes.values()) palette.dispose();
this._palettes.clear(); this._palettes.clear();
} }
if (this._paletteAssetNames) if(this._paletteAssetNames)
{ {
this.disposePaletteAssets(); this.disposePaletteAssets();
this._paletteAssetNames = null; this._paletteAssetNames = null;
} }
if (this._assets) if(this._assets)
{ {
for (const asset of this._assets.values()) asset.recycle(); for(const asset of this._assets.values()) asset.recycle();
this._assets.clear(); this._assets.clear();
} }
@ -77,7 +77,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
{ {
this._referenceCount--; this._referenceCount--;
if (this._referenceCount <= 0) if(this._referenceCount <= 0)
{ {
this._referenceCount = 0; this._referenceCount = 0;
this._referenceTimestamp = GetTickerTime(); this._referenceTimestamp = GetTickerTime();
@ -91,20 +91,20 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
const assets = data.assets; const assets = data.assets;
const palettes = data.palettes; const palettes = data.palettes;
if (assets) this.defineAssets(assets); if(assets) this.defineAssets(assets);
if (palettes) this.definePalettes(palettes); if(palettes) this.definePalettes(palettes);
} }
private defineAssets(assets: { [index: string]: IAsset }): void private defineAssets(assets: { [index: string]: IAsset }): void
{ {
if (!assets) return; if(!assets) return;
for (const name in assets) for(const name in assets)
{ {
const asset = assets[name]; const asset = assets[name];
if (!asset) continue; if(!asset) continue;
const x = (-(asset.x) || 0); const x = (-(asset.x) || 0);
const y = (-(asset.y) || 0); const y = (-(asset.y) || 0);
@ -113,23 +113,23 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
const usesPalette = (asset.usesPalette || false); const usesPalette = (asset.usesPalette || false);
let source = (asset.source || ''); let source = (asset.source || '');
if (asset.flipH && source.length) flipH = true; if(asset.flipH && source.length) flipH = true;
// if(asset.flipV && source.length) flipV = true; // if(asset.flipV && source.length) flipV = true;
if (!source.length) source = name; if(!source.length) source = name;
const texture = this.getLibraryAsset(source); const texture = this.getLibraryAsset(source);
if (!texture) continue; if(!texture) continue;
let didAddAsset = this.createAsset(name, source, texture, flipH, flipV, x, y, usesPalette); let didAddAsset = this.createAsset(name, source, texture, flipH, flipV, x, y, usesPalette);
if (!didAddAsset) if(!didAddAsset)
{ {
const existingAsset = this.getAsset(name); const existingAsset = this.getAsset(name);
if (existingAsset && (existingAsset.name !== existingAsset.source)) if(existingAsset && (existingAsset.name !== existingAsset.source))
{ {
didAddAsset = this.replaceAsset(name, source, texture, flipH, flipV, x, y, usesPalette); didAddAsset = this.replaceAsset(name, source, texture, flipH, flipV, x, y, usesPalette);
} }
@ -139,28 +139,28 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
private definePalettes(palettes: { [index: string]: IAssetPalette }): void private definePalettes(palettes: { [index: string]: IAssetPalette }): void
{ {
if (!palettes) return; if(!palettes) return;
for (const name in palettes) for(const name in palettes)
{ {
const palette = palettes[name]; const palette = palettes[name];
if (!palette) continue; if(!palette) continue;
const id = palette.id.toString(); const id = palette.id.toString();
if (this._palettes.get(id)) continue; if(this._palettes.get(id)) continue;
let colorOne = 0xFFFFFF; let colorOne = 0xFFFFFF;
let colorTwo = 0xFFFFFF; let colorTwo = 0xFFFFFF;
let color = palette.color1; let color = palette.color1;
if (color && color.length > 0) colorOne = parseInt(color, 16); if(color && color.length > 0) colorOne = parseInt(color, 16);
color = palette.color2; color = palette.color2;
if (color && color.length > 0) colorTwo = parseInt(color, 16); if(color && color.length > 0) colorTwo = parseInt(color, 16);
this._palettes.set(id, new GraphicAssetPalette(palette.rgb, colorOne, colorTwo)); this._palettes.set(id, new GraphicAssetPalette(palette.rgb, colorOne, colorTwo));
} }
@ -168,7 +168,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
private createAsset(name: string, source: string, texture: Texture<Resource>, flipH: boolean, flipV: boolean, x: number, y: number, usesPalette: boolean): boolean private createAsset(name: string, source: string, texture: Texture<Resource>, flipH: boolean, flipV: boolean, x: number, y: number, usesPalette: boolean): boolean
{ {
if (this._assets.get(name)) return false; if(this._assets.get(name)) return false;
const graphicAsset = GraphicAsset.createAsset(name, source, texture, x, y, flipH, flipV, usesPalette); const graphicAsset = GraphicAsset.createAsset(name, source, texture, x, y, flipH, flipV, usesPalette);
@ -181,7 +181,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
{ {
const existing = this._assets.get(name); const existing = this._assets.get(name);
if (existing) if(existing)
{ {
this._assets.delete(name); this._assets.delete(name);
@ -193,11 +193,11 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
public getAsset(name: string): IGraphicAsset public getAsset(name: string): IGraphicAsset
{ {
if (!name) return null; if(!name) return null;
const existing = this._assets.get(name); const existing = this._assets.get(name);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
@ -208,19 +208,19 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
let asset = this.getAsset(saveName); let asset = this.getAsset(saveName);
if (!asset) if(!asset)
{ {
asset = this.getAsset(name); asset = this.getAsset(name);
if (!asset || !asset.usesPalette) return asset; if(!asset || !asset.usesPalette) return asset;
const palette = this.getPalette(paletteName); const palette = this.getPalette(paletteName);
if (palette) if(palette)
{ {
const texture = palette.applyPalette(asset.texture); const texture = palette.applyPalette(asset.texture);
if (texture) if(texture)
{ {
this._paletteAssetNames.push(saveName); this._paletteAssetNames.push(saveName);
@ -248,36 +248,36 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
{ {
const palette = this.getPalette(paletteName); const palette = this.getPalette(paletteName);
if (palette) return [palette.primaryColor, palette.secondaryColor]; if(palette) return [palette.primaryColor, palette.secondaryColor];
return null; return null;
} }
public getPalette(name: string): GraphicAssetPalette public getPalette(name: string): GraphicAssetPalette
{ {
if (!name) return null; if(!name) return null;
const existing = this._palettes.get(name); const existing = this._palettes.get(name);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public addAsset(name: string, texture: Texture<Resource>, override: boolean, x: number = 0, y: number = 0, flipH: boolean = false, flipV: boolean = false): boolean public addAsset(name: string, texture: Texture<Resource>, override: boolean, x: number = 0, y: number = 0, flipH: boolean = false, flipV: boolean = false): boolean
{ {
if (!name || !texture) return false; if(!name || !texture) return false;
const existingTexture = this.getLibraryAsset(name); const existingTexture = this.getLibraryAsset(name);
if (!existingTexture) if(!existingTexture)
{ {
this._textures.set(name, texture); this._textures.set(name, texture);
return this.createAsset(name, name, texture, flipH, flipV, x, y, false); return this.createAsset(name, name, texture, flipH, flipV, x, y, false);
} }
if (override) if(override)
{ {
existingTexture.baseTexture = texture.baseTexture; existingTexture.baseTexture = texture.baseTexture;
existingTexture.frame = texture.frame; existingTexture.frame = texture.frame;
@ -295,13 +295,13 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
{ {
const existing = this._assets.get(name); const existing = this._assets.get(name);
if (!existing) return; if(!existing) return;
this._assets.delete(name); this._assets.delete(name);
const texture = this.getLibraryAsset(existing.source); const texture = this.getLibraryAsset(existing.source);
if (texture) if(texture)
{ {
this._textures.delete(existing.source); this._textures.delete(existing.source);
@ -313,26 +313,26 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
public getLibraryAsset(name: string): Texture<Resource> public getLibraryAsset(name: string): Texture<Resource>
{ {
if (!name) return null; if(!name) return null;
name = this._name + '_' + name; name = this._name + '_' + name;
const texture = this._textures.get(name); const texture = this._textures.get(name);
if (!texture) return null; if(!texture) return null;
return texture; return texture;
} }
private addLibraryAsset(textures: Dict<Texture<Resource>>): void private addLibraryAsset(textures: Dict<Texture<Resource>>): void
{ {
if (!textures) return; if(!textures) return;
for (const name in textures) for(const name in textures)
{ {
const texture = textures[name]; const texture = textures[name];
if (!texture) continue; if(!texture) continue;
this._textures.set(GraphicAssetCollection.removeFileExtension(name), texture); this._textures.set(GraphicAssetCollection.removeFileExtension(name), texture);
} }
@ -340,11 +340,11 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
private disposePaletteAssets(disposeAll: boolean = true): void private disposePaletteAssets(disposeAll: boolean = true): void
{ {
if (this._paletteAssetNames) if(this._paletteAssetNames)
{ {
if (disposeAll || (this._paletteAssetNames.length > GraphicAssetCollection.PALETTE_ASSET_DISPOSE_THRESHOLD)) if(disposeAll || (this._paletteAssetNames.length > GraphicAssetCollection.PALETTE_ASSET_DISPOSE_THRESHOLD))
{ {
for (const name of this._paletteAssetNames) this.disposeAsset(name); for(const name of this._paletteAssetNames) this.disposeAsset(name);
this._paletteAssetNames = []; this._paletteAssetNames = [];
} }

View File

@ -23,11 +23,11 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public addEventListener(type: string, callback: Function): void public addEventListener(type: string, callback: Function): void
{ {
if (!type || !callback) return; if(!type || !callback) return;
const existing = this._listeners.get(type); const existing = this._listeners.get(type);
if (!existing) if(!existing)
{ {
this._listeners.set(type, [callback]); this._listeners.set(type, [callback]);
@ -39,19 +39,19 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public removeEventListener(type: string, callback: any): void public removeEventListener(type: string, callback: any): void
{ {
if (!type || !callback) return; if(!type || !callback) return;
const existing = this._listeners.get(type); 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); existing.splice(i, 1);
if (!existing.length) this._listeners.delete(type); if(!existing.length) this._listeners.delete(type);
return; return;
} }
@ -59,9 +59,9 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
public dispatchEvent(event: INitroEvent): boolean public dispatchEvent(event: INitroEvent): boolean
{ {
if (!event) return false; if(!event) return false;
if (NitroConfiguration.getValue<boolean>('system.dispatcher.log')) this._logger.log('Dispatched Event', event.type); if(NitroConfiguration.getValue<boolean>('system.dispatcher.log')) this._logger.log('Dispatched Event', event.type);
this.processEvent(event); this.processEvent(event);
@ -72,18 +72,18 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
{ {
const existing = this._listeners.get(event.type); const existing = this._listeners.get(event.type);
if (!existing || !existing.length) return; if(!existing || !existing.length) return;
const callbacks = []; const callbacks = [];
for (const callback of existing) for(const callback of existing)
{ {
if (!callback) continue; if(!callback) continue;
callbacks.push(callback); callbacks.push(callback);
} }
while (callbacks.length) while(callbacks.length)
{ {
const callback = callbacks.shift(); const callback = callbacks.shift();

View File

@ -25,7 +25,7 @@ export class NitroManager extends Disposable implements INitroManager
public init(): void public init(): void
{ {
if (this._isLoaded || this._isLoading || this.isDisposing) return; if(this._isLoaded || this._isLoading || this.isDisposing) return;
this._isLoading = true; this._isLoading = true;
@ -42,7 +42,7 @@ export class NitroManager extends Disposable implements INitroManager
protected onDispose(): void protected onDispose(): void
{ {
if (this._events) this._events.dispose(); if(this._events) this._events.dispose();
super.onDispose(); super.onDispose();
} }

View File

@ -44,7 +44,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
public init(socketUrl: string): void public init(socketUrl: string): void
{ {
if (this._stateListener) if(this._stateListener)
{ {
this._stateListener.connectionInit(socketUrl); this._stateListener.connectionInit(socketUrl);
} }
@ -67,13 +67,13 @@ export class SocketConnection extends EventDispatcher implements IConnection
public onReady(): void public onReady(): void
{ {
if (this._isReady) return; if(this._isReady) return;
this._isReady = true; 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._pendingServerMessages = [];
this._pendingClientMessages = []; this._pendingClientMessages = [];
@ -81,7 +81,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private createSocket(socketUrl: string): void private createSocket(socketUrl: string): void
{ {
if (!socketUrl) return; if(!socketUrl) return;
this.destroySocket(); this.destroySocket();
@ -96,14 +96,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
private destroySocket(): void private destroySocket(): void
{ {
if (!this._socket) return; if(!this._socket) return;
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen); this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen);
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose); this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose);
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError); this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError);
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, this.onMessage); 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; this._socket = null;
} }
@ -125,7 +125,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private onMessage(event: MessageEvent): void private onMessage(event: MessageEvent): void
{ {
if (!event) return; if(!event) return;
//this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event); //this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event);
@ -153,28 +153,28 @@ export class SocketConnection extends EventDispatcher implements IConnection
public send(...composers: IMessageComposer<unknown[]>[]): boolean 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); this._pendingClientMessages.push(...composers);
return false; return false;
} }
for (const composer of composers) for(const composer of composers)
{ {
if (!composer) continue; if(!composer) continue;
const header = this._messages.getComposerId(composer); const header = this._messages.getComposerId(composer);
if (header === -1) if(header === -1)
{ {
if (NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('Unknown Composer', composer.constructor.name); if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('Unknown Composer', composer.constructor.name);
continue; continue;
} }
@ -182,14 +182,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
const message = composer.getMessageArray(); const message = composer.getMessageArray();
const encoded = this._codec.encode(header, message); const encoded = this._codec.encode(header, message);
if (!encoded) if(!encoded)
{ {
if (NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('Encoding Failed', composer.constructor.name); if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('Encoding Failed', composer.constructor.name);
continue; continue;
} }
if (NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('OutgoingComposer', header, composer.constructor.name, message); if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('OutgoingComposer', header, composer.constructor.name, message);
this.write(encoded.getBuffer()); this.write(encoded.getBuffer());
} }
@ -199,7 +199,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private write(buffer: ArrayBuffer): void private write(buffer: ArrayBuffer): void
{ {
if (this._socket.readyState !== WebSocket.OPEN) return; if(this._socket.readyState !== WebSocket.OPEN) return;
this._socket.send(buffer); this._socket.send(buffer);
} }
@ -221,11 +221,11 @@ export class SocketConnection extends EventDispatcher implements IConnection
{ {
const wrappers = this.splitReceivedMessages(); 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); this._pendingServerMessages.push(...wrappers);
@ -237,17 +237,17 @@ export class SocketConnection extends EventDispatcher implements IConnection
private processWrappers(...wrappers: IMessageDataWrapper[]): void 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); const messages = this.getMessagesForWrapper(wrapper);
if (!messages || !messages.length) continue; if(!messages || !messages.length) continue;
if (NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser); if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser);
this.handleMessages(...messages); this.handleMessages(...messages);
} }
@ -255,7 +255,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
private splitReceivedMessages(): IMessageDataWrapper[] private splitReceivedMessages(): IMessageDataWrapper[]
{ {
if (!this._dataBuffer || !this._dataBuffer.byteLength) return null; if(!this._dataBuffer || !this._dataBuffer.byteLength) return null;
return this._codec.decode(this); return this._codec.decode(this);
} }
@ -272,13 +272,13 @@ export class SocketConnection extends EventDispatcher implements IConnection
private getMessagesForWrapper(wrapper: IMessageDataWrapper): IMessageEvent[] private getMessagesForWrapper(wrapper: IMessageDataWrapper): IMessageEvent[]
{ {
if (!wrapper) return null; if(!wrapper) return null;
const events = this._messages.getEvents(wrapper.header); const events = this._messages.getEvents(wrapper.header);
if (!events || !events.length) if(!events || !events.length)
{ {
if (NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper); if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
return; return;
} }
@ -288,9 +288,9 @@ export class SocketConnection extends EventDispatcher implements IConnection
//@ts-ignore //@ts-ignore
const parser = new events[0].parserClass(); 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) catch (e)
@ -307,33 +307,33 @@ export class SocketConnection extends EventDispatcher implements IConnection
{ {
messages = [...messages]; messages = [...messages];
for (const message of messages) for(const message of messages)
{ {
if (!message) continue; if(!message) continue;
message.connection = this; message.connection = this;
if (message.callBack) message.callBack(message); if(message.callBack) message.callBack(message);
} }
} }
public registerMessages(configuration: IMessageConfiguration): void public registerMessages(configuration: IMessageConfiguration): void
{ {
if (!configuration) return; if(!configuration) return;
this._messages.registerMessages(configuration); this._messages.registerMessages(configuration);
} }
public addMessageEvent(event: IMessageEvent): void public addMessageEvent(event: IMessageEvent): void
{ {
if (!event || !this._messages) return; if(!event || !this._messages) return;
this._messages.registerMessageEvent(event); this._messages.registerMessageEvent(event);
} }
public removeMessageEvent(event: IMessageEvent): void public removeMessageEvent(event: IMessageEvent): void
{ {
if (!event || !this._messages) return; if(!event || !this._messages) return;
this._messages.removeMessageEvent(event); this._messages.removeMessageEvent(event);
} }

View File

@ -23,36 +23,36 @@ export class MessageClassManager
public registerMessages(configuration: IMessageConfiguration): void public registerMessages(configuration: IMessageConfiguration): void
{ {
for (const [header, handler] of configuration.events) this.registerMessageEventClass(header, handler); for(const [header, handler] of configuration.events) this.registerMessageEventClass(header, handler);
for (const [header, handler] of configuration.composers) this.registerMessageComposerClass(header, handler); for(const [header, handler] of configuration.composers) this.registerMessageComposerClass(header, handler);
} }
private registerMessageEventClass(header: number, handler: Function): void private registerMessageEventClass(header: number, handler: Function): void
{ {
if (!header || !handler) return; if(!header || !handler) return;
this._messageIdByEvent.set(handler, header); this._messageIdByEvent.set(handler, header);
} }
private registerMessageComposerClass(header: number, handler: Function): void private registerMessageComposerClass(header: number, handler: Function): void
{ {
if (!header || !handler) return; if(!header || !handler) return;
this._messageIdByComposer.set(handler, header); this._messageIdByComposer.set(handler, header);
} }
public registerMessageEvent(event: IMessageEvent): void public registerMessageEvent(event: IMessageEvent): void
{ {
if (!event) return; if(!event) return;
const header = this.getEventId(event); const header = this.getEventId(event);
if (!header) return; if(!header) return;
let existing = this._messageInstancesById.get(header); let existing = this._messageInstancesById.get(header);
if (!existing || !existing.length) if(!existing || !existing.length)
{ {
existing = []; existing = [];
@ -64,25 +64,25 @@ export class MessageClassManager
public removeMessageEvent(event: IMessageEvent): void public removeMessageEvent(event: IMessageEvent): void
{ {
if (!event) return; if(!event) return;
const header = this.getEventId(event); const header = this.getEventId(event);
if (!header) return; if(!header) return;
const existing = this._messageInstancesById.get(header); const existing = this._messageInstancesById.get(header);
if (!existing) return; if(!existing) return;
for (const [index, message] of existing.entries()) for(const [index, message] of existing.entries())
{ {
if (!message) continue; if(!message) continue;
if (message !== event) continue; if(message !== event) continue;
existing.splice(index, 1); existing.splice(index, 1);
if (existing.length === 0) this._messageInstancesById.delete(header); if(existing.length === 0) this._messageInstancesById.delete(header);
message.dispose(); message.dispose();
@ -92,36 +92,36 @@ export class MessageClassManager
public getEvents(header: number): IMessageEvent[] public getEvents(header: number): IMessageEvent[]
{ {
if (!header) return; if(!header) return;
const existing = this._messageInstancesById.get(header); const existing = this._messageInstancesById.get(header);
if (!existing) return; if(!existing) return;
return existing; return existing;
} }
public getEventId(event: IMessageEvent): number public getEventId(event: IMessageEvent): number
{ {
if (!event) return -1; if(!event) return -1;
//@ts-ignore //@ts-ignore
const name = (event instanceof MessageEvent ? event.constructor : event) as Function; const name = (event instanceof MessageEvent ? event.constructor : event) as Function;
const existing = this._messageIdByEvent.get(name); const existing = this._messageIdByEvent.get(name);
if (!existing) return -1; if(!existing) return -1;
return existing; return existing;
} }
public getComposerId(composer: IMessageComposer<unknown[]>): number public getComposerId(composer: IMessageComposer<unknown[]>): number
{ {
if (!composer) return -1; if(!composer) return -1;
const existing = this._messageIdByComposer.get(composer.constructor); const existing = this._messageIdByComposer.get(composer.constructor);
if (!existing) return -1; if(!existing) return -1;
return existing; return existing;
} }

View File

@ -32,7 +32,7 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
private loadNextConfiguration(): void private loadNextConfiguration(): void
{ {
if (!this._pendingUrls.length) if(!this._pendingUrls.length)
{ {
this.dispatchConfigurationEvent(ConfigurationEvent.LOADED); this.dispatchConfigurationEvent(ConfigurationEvent.LOADED);
@ -44,7 +44,7 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
public loadConfigurationFromUrl(url: string): void public loadConfigurationFromUrl(url: string): void
{ {
if (!url || (url === '')) if(!url || (url === ''))
{ {
this.dispatchConfigurationEvent(ConfigurationEvent.FAILED); this.dispatchConfigurationEvent(ConfigurationEvent.FAILED);
@ -59,13 +59,13 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
private onConfigurationLoaded(data: { [index: string]: any }, url: string): void private onConfigurationLoaded(data: { [index: string]: any }, url: string): void
{ {
if (!data) return; if(!data) return;
if (NitroConfiguration.parseConfiguration(data)) if(NitroConfiguration.parseConfiguration(data))
{ {
const index = this._pendingUrls.indexOf(url); const index = this._pendingUrls.indexOf(url);
if (index >= 0) this._pendingUrls.splice(index, 1); if(index >= 0) this._pendingUrls.splice(index, 1);
this.loadNextConfiguration(); this.loadNextConfiguration();

View File

@ -14,7 +14,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
this._array = []; this._array = [];
this._keys = []; this._keys = [];
if (map) for (const [key, value] of map.entries()) this.add(key, value); if(map) for(const [key, value] of map.entries()) this.add(key, value);
} }
public get length(): number public get length(): number
@ -29,9 +29,9 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
public dispose(): void public dispose(): void
{ {
if (!this._dictionary) if(!this._dictionary)
{ {
for (const key of this._dictionary.keys()) this._dictionary.delete(key); for(const key of this._dictionary.keys()) this._dictionary.delete(key);
this._dictionary = null; this._dictionary = null;
} }
@ -43,7 +43,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
public reset(): void public reset(): void
{ {
for (const key of this._dictionary.keys()) this._dictionary.delete(key); for(const key of this._dictionary.keys()) this._dictionary.delete(key);
this._length = 0; this._length = 0;
this._array = []; this._array = [];
@ -52,7 +52,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
public unshift(key: T, value: U): boolean public unshift(key: T, value: U): boolean
{ {
if (this._dictionary.get(key) !== null) return false; if(this._dictionary.get(key) !== null) return false;
this._dictionary.set(key, value); this._dictionary.set(key, value);
@ -66,7 +66,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
public add(key: T, value: U): boolean public add(key: T, value: U): boolean
{ {
if (this._dictionary.get(key) !== undefined) return false; if(this._dictionary.get(key) !== undefined) return false;
this._dictionary.set(key, value); this._dictionary.set(key, value);
@ -82,11 +82,11 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
{ {
const value = this._dictionary.get(key); const value = this._dictionary.get(key);
if (!value) return null; if(!value) return null;
const index = this._array.indexOf(value); const index = this._array.indexOf(value);
if (index >= 0) if(index >= 0)
{ {
this._array.splice(index, 1); this._array.splice(index, 1);
this._keys.splice(index, 1); this._keys.splice(index, 1);
@ -101,14 +101,14 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
public getWithIndex(index: number): U public getWithIndex(index: number): U
{ {
if ((index < 0) || (index >= this._length)) return null; if((index < 0) || (index >= this._length)) return null;
return this._array[index]; return this._array[index];
} }
public getKey(index: number): T public getKey(index: number): T
{ {
if ((index < 0) || (index >= this._length)) return null; if((index < 0) || (index >= this._length)) return null;
return this._keys[index]; return this._keys[index];
} }
@ -145,7 +145,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
public concatenate(newValues: IAdvancedMap<T, U>): void public concatenate(newValues: IAdvancedMap<T, U>): void
{ {
for (const k of (newValues as AdvancedMap<T, U>)._keys) this.add(k, newValues.getValue(k)); for(const k of (newValues as AdvancedMap<T, U>)._keys) this.add(k, newValues.getValue(k));
} }
public clone(): IAdvancedMap<T, U> public clone(): IAdvancedMap<T, U>

View File

@ -23,7 +23,7 @@ export class RoomSessionDimmerPresetsEvent extends RoomSessionEvent
public getPreset(id: number): RoomSessionDimmerPresetsEventPresetItem public getPreset(id: number): RoomSessionDimmerPresetsEventPresetItem
{ {
if ((id < 0) || (id >= this._presets.length)) return null; if((id < 0) || (id >= this._presets.length)) return null;
return this._presets[id]; return this._presets[id];
} }

View File

@ -21,7 +21,7 @@ export class RoomSessionVoteEvent extends RoomSessionEvent
this._question = _arg_3; this._question = _arg_3;
this._choices = _arg_4; this._choices = _arg_4;
this._SafeStr_7651 = _arg_5; this._SafeStr_7651 = _arg_5;
if (this._SafeStr_7651 == null) if(this._SafeStr_7651 == null)
{ {
this._SafeStr_7651 = []; this._SafeStr_7651 = [];
} }

View File

@ -54,7 +54,7 @@ export class Nitro implements INitro
constructor(core: INitroCore, options?: IApplicationOptions) constructor(core: INitroCore, options?: IApplicationOptions)
{ {
if (!Nitro.INSTANCE) Nitro.INSTANCE = this; if(!Nitro.INSTANCE) Nitro.INSTANCE = this;
this._worker = null; this._worker = null;
this._application = new PixiApplicationProxy(options); this._application = new PixiApplicationProxy(options);
@ -78,12 +78,12 @@ export class Nitro implements INitro
this._core.configuration.events.addEventListener(ConfigurationEvent.LOADED, this.onConfigurationLoadedEvent.bind(this)); this._core.configuration.events.addEventListener(ConfigurationEvent.LOADED, this.onConfigurationLoadedEvent.bind(this));
this._roomEngine.events.addEventListener(RoomEngineEvent.ENGINE_INITIALIZED, this.onRoomEngineReady.bind(this)); this._roomEngine.events.addEventListener(RoomEngineEvent.ENGINE_INITIALIZED, this.onRoomEngineReady.bind(this));
if (this._worker) this._worker.onmessage = this.createWorkerEvent.bind(this); if(this._worker) this._worker.onmessage = this.createWorkerEvent.bind(this);
} }
public static bootstrap(): void public static bootstrap(): void
{ {
if (Nitro.INSTANCE) if(Nitro.INSTANCE)
{ {
Nitro.INSTANCE.dispose(); Nitro.INSTANCE.dispose();
@ -105,25 +105,25 @@ export class Nitro implements INitro
public init(): void public init(): void
{ {
if (this._isReady || this._isDisposed) return; if(this._isReady || this._isDisposed) return;
if (this._avatar) this._avatar.init(); if(this._avatar) this._avatar.init();
if (this._soundManager) this._soundManager.init(); if(this._soundManager) this._soundManager.init();
if (this._roomEngine) if(this._roomEngine)
{ {
this._roomEngine.sessionDataManager = this._sessionDataManager; this._roomEngine.sessionDataManager = this._sessionDataManager;
this._roomEngine.roomSessionManager = this._roomSessionManager; this._roomEngine.roomSessionManager = this._roomSessionManager;
this._roomEngine.roomManager = this._roomManager; this._roomEngine.roomManager = this._roomManager;
if (this._sessionDataManager) this._sessionDataManager.init(); if(this._sessionDataManager) this._sessionDataManager.init();
if (this._roomSessionManager) this._roomSessionManager.init(); if(this._roomSessionManager) this._roomSessionManager.init();
this._roomEngine.init(); this._roomEngine.init();
} }
if (!this._communication.connection) if(!this._communication.connection)
{ {
throw new Error('No connection found'); throw new Error('No connection found');
} }
@ -135,58 +135,58 @@ export class Nitro implements INitro
public dispose(): void public dispose(): void
{ {
if (this._isDisposed) return; if(this._isDisposed) return;
if (this._roomManager) if(this._roomManager)
{ {
this._roomManager.dispose(); this._roomManager.dispose();
this._roomManager = null; this._roomManager = null;
} }
if (this._roomSessionManager) if(this._roomSessionManager)
{ {
this._roomSessionManager.dispose(); this._roomSessionManager.dispose();
this._roomSessionManager = null; this._roomSessionManager = null;
} }
if (this._sessionDataManager) if(this._sessionDataManager)
{ {
this._sessionDataManager.dispose(); this._sessionDataManager.dispose();
this._sessionDataManager = null; this._sessionDataManager = null;
} }
if (this._roomEngine) if(this._roomEngine)
{ {
this._roomEngine.dispose(); this._roomEngine.dispose();
this._roomEngine = null; this._roomEngine = null;
} }
if (this._avatar) if(this._avatar)
{ {
this._avatar.dispose(); this._avatar.dispose();
this._avatar = null; this._avatar = null;
} }
if (this._soundManager) if(this._soundManager)
{ {
this._soundManager.dispose(); this._soundManager.dispose();
this._soundManager = null; this._soundManager = null;
} }
if (this._communication) if(this._communication)
{ {
this._communication.dispose(); this._communication.dispose();
this._communication = null; this._communication = null;
} }
if (this._application) if(this._application)
{ {
this._application.destroy(); this._application.destroy();
@ -202,7 +202,7 @@ export class Nitro implements INitro
const animationFPS = NitroConfiguration.getValue<number>('system.animation.fps', 24); const animationFPS = NitroConfiguration.getValue<number>('system.animation.fps', 24);
const limitsFPS = NitroConfiguration.getValue<boolean>('system.limits.fps', true); const limitsFPS = NitroConfiguration.getValue<boolean>('system.limits.fps', true);
if (limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS; if(limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS;
} }
private onRoomEngineReady(event: RoomEngineEvent): void private onRoomEngineReady(event: RoomEngineEvent): void
@ -232,7 +232,7 @@ export class Nitro implements INitro
public addWorkerEventTracker(tracker: IWorkerEventTracker): void public addWorkerEventTracker(tracker: IWorkerEventTracker): void
{ {
if (this._workerTrackers.indexOf(tracker) >= 0) return; if(this._workerTrackers.indexOf(tracker) >= 0) return;
this._workerTrackers.push(tracker); this._workerTrackers.push(tracker);
} }
@ -241,20 +241,20 @@ export class Nitro implements INitro
{ {
const index = this._workerTrackers.indexOf(tracker); const index = this._workerTrackers.indexOf(tracker);
if (index === -1) return; if(index === -1) return;
this._workerTrackers.splice(index, 1); this._workerTrackers.splice(index, 1);
} }
public createWorkerEvent(message: MessageEvent): void public createWorkerEvent(message: MessageEvent): void
{ {
if (!message) return; if(!message) return;
const data: { [index: string]: any } = message.data; const data: { [index: string]: any } = message.data;
for (const tracker of this._workerTrackers) for(const tracker of this._workerTrackers)
{ {
if (!tracker) continue; if(!tracker) continue;
tracker.workerMessageReceived(data); tracker.workerMessageReceived(data);
} }
@ -262,14 +262,14 @@ export class Nitro implements INitro
public sendWorkerEvent(message: { [index: string]: any }): void public sendWorkerEvent(message: { [index: string]: any }): void
{ {
if (!message || !this._worker) return; if(!message || !this._worker) return;
this._worker.postMessage(message); this._worker.postMessage(message);
} }
public addLinkEventTracker(tracker: ILinkEventTracker): void public addLinkEventTracker(tracker: ILinkEventTracker): void
{ {
if (this._linkTrackers.indexOf(tracker) >= 0) return; if(this._linkTrackers.indexOf(tracker) >= 0) return;
this._linkTrackers.push(tracker); this._linkTrackers.push(tracker);
} }
@ -278,24 +278,24 @@ export class Nitro implements INitro
{ {
const index = this._linkTrackers.indexOf(tracker); const index = this._linkTrackers.indexOf(tracker);
if (index === -1) return; if(index === -1) return;
this._linkTrackers.splice(index, 1); this._linkTrackers.splice(index, 1);
} }
public createLinkEvent(link: string): void public createLinkEvent(link: string): void
{ {
if (!link || (link === '')) return; if(!link || (link === '')) return;
for (const tracker of this._linkTrackers) for(const tracker of this._linkTrackers)
{ {
if (!tracker) continue; if(!tracker) continue;
const prefix = tracker.eventUrlPrefix; const prefix = tracker.eventUrlPrefix;
if (prefix.length > 0) if(prefix.length > 0)
{ {
if (link.substr(0, prefix.length) === prefix) tracker.linkReceived(link); if(link.substr(0, prefix.length) === prefix) tracker.linkReceived(link);
} }
else else
{ {

View File

@ -31,16 +31,16 @@ export class AvatarAssetDownloadLibrary extends EventDispatcher implements IAvat
const asset = this._assets.getCollection(this._libraryName); const asset = this._assets.getCollection(this._libraryName);
if (asset) this._state = AvatarAssetDownloadLibrary.LOADED; if(asset) this._state = AvatarAssetDownloadLibrary.LOADED;
} }
public downloadAsset(): void public downloadAsset(): void
{ {
if (!this._assets || (this._state === AvatarAssetDownloadLibrary.LOADING) || (this._state === AvatarAssetDownloadLibrary.LOADED)) return; if(!this._assets || (this._state === AvatarAssetDownloadLibrary.LOADING) || (this._state === AvatarAssetDownloadLibrary.LOADED)) return;
const asset = this._assets.getCollection(this._libraryName); const asset = this._assets.getCollection(this._libraryName);
if (asset) if(asset)
{ {
this._state = AvatarAssetDownloadLibrary.LOADED; this._state = AvatarAssetDownloadLibrary.LOADED;
@ -53,7 +53,7 @@ export class AvatarAssetDownloadLibrary extends EventDispatcher implements IAvat
this._assets.downloadAsset(this._downloadUrl, (flag: boolean) => this._assets.downloadAsset(this._downloadUrl, (flag: boolean) =>
{ {
if (flag) if(flag)
{ {
this._state = AvatarAssetDownloadLibrary.LOADED; this._state = AvatarAssetDownloadLibrary.LOADED;

View File

@ -61,7 +61,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
request.onloadend = e => request.onloadend = e =>
{ {
if (request.responseText) if(request.responseText)
{ {
const data = JSON.parse(request.responseText); const data = JSON.parse(request.responseText);
@ -89,16 +89,16 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private processFigureMap(data: any): void 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 id = (library.id as string);
const revision = (library.revision || ''); const revision = (library.revision || '');
if (this._libraryNames.indexOf(id) >= 0) continue; if(this._libraryNames.indexOf(id) >= 0) continue;
this._libraryNames.push(id); this._libraryNames.push(id);
@ -106,7 +106,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
downloadLibrary.addEventListener(AvatarRenderLibraryEvent.DOWNLOAD_COMPLETE, this.onLibraryLoaded); 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 id = (part.id as string);
const type = (part.type as string); const type = (part.type as string);
@ -114,7 +114,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
let existing = this._figureMap.get(partString); let existing = this._figureMap.get(partString);
if (!existing) existing = []; if(!existing) existing = [];
existing.push(downloadLibrary); existing.push(downloadLibrary);
@ -125,9 +125,9 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private onAvatarRenderReady(event: INitroEvent): void private onAvatarRenderReady(event: INitroEvent): 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); this.downloadAvatarFigure(container, listener);
} }
@ -137,34 +137,34 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private onLibraryLoaded(event: AvatarRenderLibraryEvent): void private onLibraryLoaded(event: AvatarRenderLibraryEvent): void
{ {
if (!event || !event.library) return; if(!event || !event.library) return;
const loadedFigures: string[] = []; const loadedFigures: string[] = [];
for (const [figure, libraries] of this._incompleteFigures.entries()) for(const [figure, libraries] of this._incompleteFigures.entries())
{ {
let isReady = true; 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; isReady = false;
break; break;
} }
if (isReady) if(isReady)
{ {
loadedFigures.push(figure); loadedFigures.push(figure);
const listeners = this._figureListeners.get(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); listener.resetFigure(figure);
} }
@ -176,22 +176,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); this._incompleteFigures.delete(figure);
} }
let index = 0; let index = 0;
while (index < this._currentDownloads.length) while(index < this._currentDownloads.length)
{ {
const download = this._currentDownloads[index]; 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++; index++;
@ -202,19 +202,19 @@ export class AvatarAssetDownloadManager extends EventDispatcher
{ {
const libraries = this._missingMandatoryLibs.slice(); 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); 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 public isAvatarFigureContainerReady(container: IAvatarFigureContainer): boolean
{ {
if (!this._isReady || !this._structure.renderManager.isReady) if(!this._isReady || !this._structure.renderManager.isReady)
{ {
return false; return false;
} }
@ -228,38 +228,38 @@ export class AvatarAssetDownloadManager extends EventDispatcher
{ {
const pendingLibraries: AvatarAssetDownloadLibrary[] = []; const pendingLibraries: AvatarAssetDownloadLibrary[] = [];
if (!container || !this._structure) return pendingLibraries; if(!container || !this._structure) return pendingLibraries;
const figureData = this._structure.figureData; const figureData = this._structure.figureData;
if (!figureData) return pendingLibraries; if(!figureData) return pendingLibraries;
const setKeys = container.getPartTypeIds(); const setKeys = container.getPartTypeIds();
for (const key of setKeys) for(const key of setKeys)
{ {
const set = figureData.getSetType(key); const set = figureData.getSetType(key);
if (!set) continue; if(!set) continue;
const figurePartSet = set.getPartSet(container.getPartSetId(key)); 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 name = (part.type + ':' + part.id);
const existing = this._figureMap.get(name); 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); pendingLibraries.push(library);
} }
@ -271,7 +271,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void 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]);
@ -281,13 +281,13 @@ export class AvatarAssetDownloadManager extends EventDispatcher
const figure = container.getFigureString(); const figure = container.getFigureString();
const pendingLibraries = this.getAvatarFigurePendingLibraries(container); 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); let listeners = this._figureListeners.get(figure);
if (!listeners) if(!listeners)
{ {
listeners = []; listeners = [];
@ -299,24 +299,24 @@ export class AvatarAssetDownloadManager extends EventDispatcher
this._incompleteFigures.set(figure, pendingLibraries); this._incompleteFigures.set(figure, pendingLibraries);
for (const library of pendingLibraries) for(const library of pendingLibraries)
{ {
if (!library) continue; if(!library) continue;
this.downloadLibrary(library); this.downloadLibrary(library);
} }
} }
else else
{ {
if (listener && !listener.disposed) listener.resetFigure(figure); if(listener && !listener.disposed) listener.resetFigure(figure);
} }
} }
private downloadLibrary(library: AvatarAssetDownloadLibrary): void 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); this._pendingDownloadQueue.push(library);
@ -325,7 +325,7 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private processDownloadQueue(): void private processDownloadQueue(): void
{ {
while (this._pendingDownloadQueue.length) while(this._pendingDownloadQueue.length)
{ {
const library = this._pendingDownloadQueue[0]; const library = this._pendingDownloadQueue[0];

View File

@ -25,7 +25,7 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
{ {
const existing = this.partSets().get(k); const existing = this.partSets().get(k);
if (!existing) return 0; if(!existing) return 0;
return existing.get('setid'); return existing.get('setid');
} }
@ -34,7 +34,7 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
{ {
const existing = this.partSets().get(k); const existing = this.partSets().get(k);
if (!existing) return null; if(!existing) return null;
return existing.get('colorids'); return existing.get('colorids');
} }
@ -62,9 +62,9 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
{ {
const parts: string[] = []; const parts: string[] = [];
for (const key of this.partSets().keys()) for(const key of this.partSets().keys())
{ {
if (!key) continue; if(!key) continue;
let setParts = []; let setParts = [];
@ -81,20 +81,20 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
private partSets(): Map<string, Map<string, any>> private partSets(): Map<string, Map<string, any>>
{ {
if (!this._parts) this._parts = new Map(); if(!this._parts) this._parts = new Map();
return this._parts; return this._parts;
} }
private parseFigure(figure: string): void private parseFigure(figure: string): void
{ {
if (!figure) figure = ''; if(!figure) figure = '';
for (const part of figure.split('.')) for(const part of figure.split('.'))
{ {
const pieces = part.split('-'); const pieces = part.split('-');
if (pieces.length >= 2) if(pieces.length >= 2)
{ {
const type = pieces[0]; const type = pieces[0];
const setId = parseInt(pieces[1]); const setId = parseInt(pieces[1]);
@ -102,7 +102,7 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
let index = 2; let index = 2;
while (index < pieces.length) while(index < pieces.length)
{ {
colors.push(parseInt(pieces[index])); colors.push(parseInt(pieces[index]));

View File

@ -76,11 +76,11 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
this._assets = _arg_2; this._assets = _arg_2;
this._scale = _arg_4; this._scale = _arg_4;
this._effectListener = _arg_6; this._effectListener = _arg_6;
if (this._scale == null) if(this._scale == null)
{ {
this._scale = AvatarScaleType.LARGE; this._scale = AvatarScaleType.LARGE;
} }
if (_arg_3 == null) if(_arg_3 == null)
{ {
_arg_3 = new AvatarFigureContainer('hr-893-45.hd-180-2.ch-210-66.lg-270-82.sh-300-91.wa-2007-.ri-1-'); _arg_3 = new AvatarFigureContainer('hr-893-45.hd-180-2.ch-210-66.lg-270-82.sh-300-91.wa-2007-.ri-1-');
} }
@ -104,7 +104,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
public dispose(): void public dispose(): void
{ {
if (this._disposed) return; if(this._disposed) return;
this._structure = null; this._structure = null;
this._assets = null; this._assets = null;
@ -113,22 +113,22 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
this._avatarSpriteData = null; this._avatarSpriteData = null;
this._actions = null; this._actions = null;
if (this._image) if(this._image)
{ {
this._image.destroy(); this._image.destroy();
this._image = null; this._image = null;
} }
if (this._cache) if(this._cache)
{ {
this._cache.dispose(); this._cache.dispose();
this._cache = null; this._cache = null;
} }
if (this._fullImageCache) if(this._fullImageCache)
{ {
for (const k of this._fullImageCache.getValues()) (k && k.destroy()); for(const k of this._fullImageCache.getValues()) (k && k.destroy());
this._fullImageCache = null; this._fullImageCache = null;
} }
@ -162,24 +162,24 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
{ {
_arg_2 = (_arg_2 + this._directionOffset); _arg_2 = (_arg_2 + this._directionOffset);
if (_arg_2 < AvatarDirectionAngle.MIN_DIRECTION) if(_arg_2 < AvatarDirectionAngle.MIN_DIRECTION)
{ {
_arg_2 = (AvatarDirectionAngle.MAX_DIRECTION + (_arg_2 + 1)); _arg_2 = (AvatarDirectionAngle.MAX_DIRECTION + (_arg_2 + 1));
} }
if (_arg_2 > AvatarDirectionAngle.MAX_DIRECTION) if(_arg_2 > AvatarDirectionAngle.MAX_DIRECTION)
{ {
_arg_2 = (_arg_2 - (AvatarDirectionAngle.MAX_DIRECTION + 1)); _arg_2 = (_arg_2 - (AvatarDirectionAngle.MAX_DIRECTION + 1));
} }
if (this._structure.isMainAvatarSet(k)) if(this._structure.isMainAvatarSet(k))
{ {
this._mainDirection = _arg_2; this._mainDirection = _arg_2;
} }
if ((k === AvatarSetType.HEAD) || (k === AvatarSetType.FULL)) if((k === AvatarSetType.HEAD) || (k === AvatarSetType.FULL))
{ {
if ((k === AvatarSetType.HEAD) && (this.isHeadTurnPreventedByAction())) if((k === AvatarSetType.HEAD) && (this.isHeadTurnPreventedByAction()))
{ {
_arg_2 = this._mainDirection; _arg_2 = this._mainDirection;
} }
@ -225,34 +225,34 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
private getFullImageCacheKey(): string private getFullImageCacheKey(): string
{ {
if (!this._useFullImageCache) return null; if(!this._useFullImageCache) return null;
if (((this._sortedActions.length == 1) && (this._mainDirection == this._headDirection))) if(((this._sortedActions.length == 1) && (this._mainDirection == this._headDirection)))
{ {
return (this._mainDirection + this._currentActionsString) + (this._frameCounter % 4); return (this._mainDirection + this._currentActionsString) + (this._frameCounter % 4);
} }
if (this._sortedActions.length == 2) if(this._sortedActions.length == 2)
{ {
for (const k of this._sortedActions) for(const k of this._sortedActions)
{ {
if (((k.actionType == 'fx') && ((((k.actionParameter == '33') || (k.actionParameter == '34')) || (k.actionParameter == '35')) || (k.actionParameter == '36')))) if(((k.actionType == 'fx') && ((((k.actionParameter == '33') || (k.actionParameter == '34')) || (k.actionParameter == '35')) || (k.actionParameter == '36'))))
{ {
return (this._mainDirection + this._currentActionsString) + 0; return (this._mainDirection + this._currentActionsString) + 0;
} }
if (((k.actionType == 'fx') && ((k.actionParameter == '38') || (k.actionParameter == '39')))) if(((k.actionType == 'fx') && ((k.actionParameter == '38') || (k.actionParameter == '39'))))
{ {
return (((this._mainDirection + '_') + this._headDirection) + this._currentActionsString) + (this._frameCounter % 11); return (((this._mainDirection + '_') + this._headDirection) + this._currentActionsString) + (this._frameCounter % 11);
} }
if ((k.actionType === 'dance') && ((k.actionParameter === '1') || (k.actionParameter === '2') || (k.actionParameter === '3') || (k.actionParameter === '4'))) if((k.actionType === 'dance') && ((k.actionParameter === '1') || (k.actionParameter === '2') || (k.actionParameter === '3') || (k.actionParameter === '4')))
{ {
let frame = (this._frameCounter % 8); let frame = (this._frameCounter % 8);
if ((k.actionParameter === '3')) frame = (this._frameCounter % 10); if((k.actionParameter === '3')) frame = (this._frameCounter % 10);
if ((k.actionParameter === '4')) frame = (this._frameCounter % 16); if((k.actionParameter === '4')) frame = (this._frameCounter % 16);
return (((this._mainDirection + k.actionType) + k.actionParameter) + frame); return (((this._mainDirection + k.actionType) + k.actionParameter) + frame);
} }
@ -264,7 +264,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
private getBodyParts(k: string, _arg_2: string, _arg_3: number): string[] private getBodyParts(k: string, _arg_2: string, _arg_3: number): string[]
{ {
if ((((!(_arg_3 == this._cachedBodyPartsDirection)) || (!(_arg_2 == this._cachedBodyPartsGeometryType))) || (!(k == this._cachedBodyPartsAvatarSet)))) if((((!(_arg_3 == this._cachedBodyPartsDirection)) || (!(_arg_2 == this._cachedBodyPartsGeometryType))) || (!(k == this._cachedBodyPartsAvatarSet))))
{ {
this._cachedBodyPartsDirection = _arg_3; this._cachedBodyPartsDirection = _arg_3;
this._cachedBodyPartsGeometryType = _arg_2; this._cachedBodyPartsGeometryType = _arg_2;
@ -277,18 +277,18 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
public getAvatarPartsForCamera(k: string): void public getAvatarPartsForCamera(k: string): void
{ {
let _local_4: string; let _local_4: string;
if (this._mainAction == null) if(this._mainAction == null)
{ {
return; return;
} }
const _local_2 = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType); const _local_2 = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType);
if (_local_2 == null) if(_local_2 == null)
{ {
return; return;
} }
const _local_3 = this.getBodyParts(k, this._mainAction.definition.geometryType, this._mainDirection); const _local_3 = this.getBodyParts(k, this._mainAction.definition.geometryType, this._mainDirection);
let _local_6 = (_local_3.length - 1); let _local_6 = (_local_3.length - 1);
while (_local_6 >= 0) while(_local_6 >= 0)
{ {
_local_4 = _local_3[_local_6]; _local_4 = _local_3[_local_6];
const _local_5 = this._cache.getImageContainer(_local_4, this._frameCounter, true); const _local_5 = this._cache.getImageContainer(_local_4, this._frameCounter, true);
@ -298,19 +298,19 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
public getImage(setType: string, hightlight: boolean, scale: number = 1, cache: boolean = true): RenderTexture public getImage(setType: string, hightlight: boolean, scale: number = 1, cache: boolean = true): RenderTexture
{ {
if (!this._changes) return this._image; if(!this._changes) return this._image;
if (!this._mainAction) return null; if(!this._mainAction) return null;
if (!this._actionsSorted) this.endActionAppends(); if(!this._actionsSorted) this.endActionAppends();
const avatarCanvas = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType); const avatarCanvas = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType);
if (!avatarCanvas) return null; if(!avatarCanvas) return null;
if (this._image && ((this._image.width !== avatarCanvas.width) || (this._image.height !== avatarCanvas.height))) if(this._image && ((this._image.width !== avatarCanvas.width) || (this._image.height !== avatarCanvas.height)))
{ {
if (this._reusableTexture) if(this._reusableTexture)
{ {
this._reusableTexture.destroy(true); this._reusableTexture.destroy(true);
@ -330,16 +330,16 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
let isCachable = true; let isCachable = true;
let partCount = (_local_6.length - 1); let partCount = (_local_6.length - 1);
while (partCount >= 0) while(partCount >= 0)
{ {
const set = _local_6[partCount]; const set = _local_6[partCount];
const part = this._cache.getImageContainer(set, this._frameCounter); const part = this._cache.getImageContainer(set, this._frameCounter);
if (part) if(part)
{ {
const partCacheContainer = part.image; const partCacheContainer = part.image;
if (!partCacheContainer) if(!partCacheContainer)
{ {
container.destroy({ container.destroy({
children: true children: true
@ -352,7 +352,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
const point = part.regPoint.clone(); const point = part.regPoint.clone();
if (point) if(point)
{ {
point.x += avatarCanvas.offset.x; point.x += avatarCanvas.offset.x;
point.y += avatarCanvas.offset.y; point.y += avatarCanvas.offset.y;
@ -364,7 +364,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
partContainer.addChild(partCacheContainer); partContainer.addChild(partCacheContainer);
if (partContainer) if(partContainer)
{ {
partContainer.position.set(point.x, point.y); partContainer.position.set(point.x, point.y);
@ -376,13 +376,13 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
partCount--; partCount--;
} }
if (this._avatarSpriteData) if(this._avatarSpriteData)
{ {
if (!container.filters) container.filters = []; if(!container.filters) container.filters = [];
if (this._avatarSpriteData.colorTransform) container.filters.push(this._avatarSpriteData.colorTransform); if(this._avatarSpriteData.colorTransform) container.filters.push(this._avatarSpriteData.colorTransform);
if (this._avatarSpriteData.paletteIsGrayscale) if(this._avatarSpriteData.paletteIsGrayscale)
{ {
this.convertToGrayscale(container); this.convertToGrayscale(container);
@ -390,12 +390,12 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
} }
} }
if (!cache) if(!cache)
{ {
return TextureUtils.generateTexture(container, new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height)); return TextureUtils.generateTexture(container, new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height));
} }
if (this._reusableTexture) if(this._reusableTexture)
{ {
PixiApplicationProxy.instance.renderer.render(container, { PixiApplicationProxy.instance.renderer.render(container, {
renderTexture: this._reusableTexture, renderTexture: this._reusableTexture,
@ -407,7 +407,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
this._reusableTexture = TextureUtils.generateTexture(container, new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height)); this._reusableTexture = TextureUtils.generateTexture(container, new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height));
} }
if (!this._reusableTexture) return null; if(!this._reusableTexture) return null;
/* /*
if(this._avatarSpriteData) if(this._avatarSpriteData)
@ -432,31 +432,31 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
const textureImageData = textureCtx.getImageData(0, 0, textureCanvas.width, textureCanvas.height); const textureImageData = textureCtx.getImageData(0, 0, textureCanvas.width, textureCanvas.height);
const data = textureImageData.data; const data = textureImageData.data;
for (let i = 0; i < data.length; i += 4) for(let i = 0; i < data.length; i += 4)
{ {
if (reds.length == 256) if(reds.length == 256)
{ {
let paletteColor = reds[data[i]]; let paletteColor = reds[data[i]];
if (paletteColor === undefined) paletteColor = 0; if(paletteColor === undefined) paletteColor = 0;
data[i] = ((paletteColor >> 16) & 0xFF); data[i] = ((paletteColor >> 16) & 0xFF);
data[i + 1] = ((paletteColor >> 8) & 0xFF); data[i + 1] = ((paletteColor >> 8) & 0xFF);
data[i + 2] = (paletteColor & 0xFF); data[i + 2] = (paletteColor & 0xFF);
} }
if (greens.length == 256) if(greens.length == 256)
{ {
let paletteColor = greens[data[i + 1]]; let paletteColor = greens[data[i + 1]];
if (paletteColor === undefined) paletteColor = 0; if(paletteColor === undefined) paletteColor = 0;
data[i] = ((paletteColor >> 16) & 0xFF); data[i] = ((paletteColor >> 16) & 0xFF);
data[i + 1] = ((paletteColor >> 8) & 0xFF); data[i + 1] = ((paletteColor >> 8) & 0xFF);
data[i + 2] = (paletteColor & 0xFF); data[i + 2] = (paletteColor & 0xFF);
} }
if (blues.length == 256) if(blues.length == 256)
{ {
let paletteColor = greens[data[i + 2]]; let paletteColor = greens[data[i + 2]];
if (paletteColor === undefined) paletteColor = 0; if(paletteColor === undefined) paletteColor = 0;
data[i] = ((paletteColor >> 16) & 0xFF); data[i] = ((paletteColor >> 16) & 0xFF);
data[i + 1] = ((paletteColor >> 8) & 0xFF); data[i + 1] = ((paletteColor >> 8) & 0xFF);
@ -478,13 +478,13 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
public getImageAsSprite(setType: string, scale: number = 1): Sprite public getImageAsSprite(setType: string, scale: number = 1): Sprite
{ {
if (!this._mainAction) return null; if(!this._mainAction) return null;
if (!this._actionsSorted) this.endActionAppends(); if(!this._actionsSorted) this.endActionAppends();
const avatarCanvas = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType); const avatarCanvas = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType);
if (!avatarCanvas) return null; if(!avatarCanvas) return null;
const setTypes = this.getBodyParts(setType, this._mainAction.definition.geometryType, this._mainDirection); const setTypes = this.getBodyParts(setType, this._mainAction.definition.geometryType, this._mainDirection);
const container = new NitroSprite(); const container = new NitroSprite();
@ -497,16 +497,16 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
let partCount = (setTypes.length - 1); let partCount = (setTypes.length - 1);
while (partCount >= 0) while(partCount >= 0)
{ {
const set = setTypes[partCount]; const set = setTypes[partCount];
const part = this._cache.getImageContainer(set, this._frameCounter); const part = this._cache.getImageContainer(set, this._frameCounter);
if (part) if(part)
{ {
const partCacheContainer = part.image; const partCacheContainer = part.image;
if (!partCacheContainer) if(!partCacheContainer)
{ {
container.destroy({ container.destroy({
children: true children: true
@ -517,7 +517,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
const point = part.regPoint.clone(); const point = part.regPoint.clone();
if (point) if(point)
{ {
point.x += avatarCanvas.offset.x; point.x += avatarCanvas.offset.x;
point.y += avatarCanvas.offset.y; point.y += avatarCanvas.offset.y;
@ -543,29 +543,29 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
public getCroppedImage(setType: string, scale: number = 1): HTMLImageElement public getCroppedImage(setType: string, scale: number = 1): HTMLImageElement
{ {
if (!this._mainAction) return null; if(!this._mainAction) return null;
if (!this._actionsSorted) this.endActionAppends(); if(!this._actionsSorted) this.endActionAppends();
const avatarCanvas = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType); const avatarCanvas = this._structure.getCanvas(this._scale, this._mainAction.definition.geometryType);
if (!avatarCanvas) return null; if(!avatarCanvas) return null;
const setTypes = this.getBodyParts(setType, this._mainAction.definition.geometryType, this._mainDirection); const setTypes = this.getBodyParts(setType, this._mainAction.definition.geometryType, this._mainDirection);
const container = new NitroContainer(); const container = new NitroContainer();
let partCount = (setTypes.length - 1); let partCount = (setTypes.length - 1);
while (partCount >= 0) while(partCount >= 0)
{ {
const set = setTypes[partCount]; const set = setTypes[partCount];
const part = this._cache.getImageContainer(set, this._frameCounter); const part = this._cache.getImageContainer(set, this._frameCounter);
if (part) if(part)
{ {
const partCacheContainer = part.image; const partCacheContainer = part.image;
if (!partCacheContainer) if(!partCacheContainer)
{ {
container.destroy({ container.destroy({
children: true children: true
@ -576,7 +576,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
const point = part.regPoint.clone(); const point = part.regPoint.clone();
if (point) if(point)
{ {
point.x += avatarCanvas.offset.x; point.x += avatarCanvas.offset.x;
point.y += avatarCanvas.offset.y; point.y += avatarCanvas.offset.y;
@ -588,7 +588,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
partContainer.addChild(partCacheContainer); partContainer.addChild(partCacheContainer);
if (partContainer) if(partContainer)
{ {
partContainer.position.set(point.x, point.y); partContainer.position.set(point.x, point.y);
@ -604,7 +604,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
const image = TextureUtils.generateImage(texture); const image = TextureUtils.generateImage(texture);
if (!image) return null; if(!image) return null;
return image; return image;
} }
@ -613,9 +613,9 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
{ {
const existing = this._fullImageCache.getValue(k); const existing = this._fullImageCache.getValue(k);
if (existing) if(existing)
{ {
if (!existing.valid) if(!existing.valid)
{ {
this._fullImageCache.remove(k); this._fullImageCache.remove(k);
@ -632,18 +632,18 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
{ {
const existing = this._fullImageCache.getValue(k); const existing = this._fullImageCache.getValue(k);
if (existing) if(existing)
{ {
this._fullImageCache.remove(k); this._fullImageCache.remove(k);
existing.destroy(true); existing.destroy(true);
} }
if (this._fullImageCache.length === this._fullImageCacheSize) if(this._fullImageCache.length === this._fullImageCacheSize)
{ {
const oldestKey = this._fullImageCache.getKey(0); const oldestKey = this._fullImageCache.getKey(0);
if (oldestKey) if(oldestKey)
{ {
const removed = this._fullImageCache.remove(oldestKey); const removed = this._fullImageCache.remove(oldestKey);
@ -676,13 +676,13 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
{ {
let k: ActiveActionData; let k: ActiveActionData;
if (!this.sortActions()) return; if(!this.sortActions()) return;
for (const k of this._sortedActions) for(const k of this._sortedActions)
{ {
if (k.actionType === AvatarAction.EFFECT) if(k.actionType === AvatarAction.EFFECT)
{ {
if (!this._effectManager.isAvatarEffectReady(parseInt(k.actionParameter))) this._effectManager.downloadAvatarEffect(parseInt(k.actionParameter), this); if(!this._effectManager.isAvatarEffectReady(parseInt(k.actionParameter))) this._effectManager.downloadAvatarEffect(parseInt(k.actionParameter), this);
} }
} }
@ -696,14 +696,14 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
this._actionsSorted = false; this._actionsSorted = false;
if (_args && (_args.length > 0)) _local_3 = _args[0]; if(_args && (_args.length > 0)) _local_3 = _args[0];
if ((_local_3 !== undefined) && (_local_3 !== null)) _local_3 = _local_3.toString(); if((_local_3 !== undefined) && (_local_3 !== null)) _local_3 = _local_3.toString();
switch (k) switch(k)
{ {
case AvatarAction.POSTURE: case AvatarAction.POSTURE:
switch (_local_3) switch(_local_3)
{ {
case AvatarAction.POSTURE_LAY: case AvatarAction.POSTURE_LAY:
case AvatarAction.POSTURE_WALK: case AvatarAction.POSTURE_WALK:
@ -716,11 +716,11 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
case AvatarAction.SNOWWAR_DIE_BACK: case AvatarAction.SNOWWAR_DIE_BACK:
case AvatarAction.SNOWWAR_PICK: case AvatarAction.SNOWWAR_PICK:
case AvatarAction.SNOWWAR_THROW: case AvatarAction.SNOWWAR_THROW:
if ((_local_3 === AvatarAction.POSTURE_LAY) || (_local_3 === AvatarAction.POSTURE_LAY) || (_local_3 === AvatarAction.POSTURE_LAY)) if((_local_3 === AvatarAction.POSTURE_LAY) || (_local_3 === AvatarAction.POSTURE_LAY) || (_local_3 === AvatarAction.POSTURE_LAY))
{ {
if (_local_3 === AvatarAction.POSTURE_LAY) if(_local_3 === AvatarAction.POSTURE_LAY)
{ {
if (this._mainDirection == 0) if(this._mainDirection == 0)
{ {
this.setDirection(AvatarSetType.FULL, 4); this.setDirection(AvatarSetType.FULL, 4);
} }
@ -739,7 +739,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
} }
break; break;
case AvatarAction.GESTURE: case AvatarAction.GESTURE:
switch (_local_3) switch(_local_3)
{ {
case AvatarAction.GESTURE_AGGRAVATED: case AvatarAction.GESTURE_AGGRAVATED:
case AvatarAction.GESTURE_SAD: case AvatarAction.GESTURE_SAD:
@ -763,9 +763,9 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
case AvatarAction.EXPRESSION_SNOWBOARD_OLLIE: case AvatarAction.EXPRESSION_SNOWBOARD_OLLIE:
case AvatarAction.EXPRESSION_SNOWBORD_360: case AvatarAction.EXPRESSION_SNOWBORD_360:
case AvatarAction.EXPRESSION_RIDE_JUMP: case AvatarAction.EXPRESSION_RIDE_JUMP:
if (_local_3 === AvatarAction.EFFECT) if(_local_3 === AvatarAction.EFFECT)
{ {
if ((((((_local_3 === '33') || (_local_3 === '34')) || (_local_3 === '35')) || (_local_3 === '36')) || (_local_3 === '38')) || (_local_3 === '39')) if((((((_local_3 === '33') || (_local_3 === '34')) || (_local_3 === '35')) || (_local_3 === '36')) || (_local_3 === '38')) || (_local_3 === '39'))
{ {
this._useFullImageCache = true; this._useFullImageCache = true;
} }
@ -776,7 +776,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
case AvatarAction.CARRY_OBJECT: case AvatarAction.CARRY_OBJECT:
case AvatarAction.USE_OBJECT: { case AvatarAction.USE_OBJECT: {
const _local_4 = this._structure.getActionDefinitionWithState(k); const _local_4 = this._structure.getActionDefinitionWithState(k);
if (_local_4) _local_3 = _local_4.getParameterValue(_local_3); if(_local_4) _local_3 = _local_4.getParameterValue(_local_3);
this.addActionData(k, _local_3); this.addActionData(k, _local_3);
break; break;
} }
@ -788,13 +788,13 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
protected addActionData(k: string, _arg_2: string = ''): void protected addActionData(k: string, _arg_2: string = ''): void
{ {
let _local_3: ActiveActionData; let _local_3: ActiveActionData;
if (!this._actions) this._actions = []; if(!this._actions) this._actions = [];
let _local_4 = 0; let _local_4 = 0;
while (_local_4 < this._actions.length) while(_local_4 < this._actions.length)
{ {
_local_3 = this._actions[_local_4]; _local_3 = this._actions[_local_4];
if (((_local_3.actionType == k) && (_local_3.actionParameter == _arg_2))) if(((_local_3.actionType == k) && (_local_3.actionParameter == _arg_2)))
{ {
return; return;
} }
@ -827,14 +827,14 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
let _local_2: IActionDefinition; let _local_2: IActionDefinition;
let _local_3: ActiveActionData; let _local_3: ActiveActionData;
let k: boolean; let k: boolean;
if (this._sortedActions == null) if(this._sortedActions == null)
{ {
return false; return false;
} }
for (const _local_3 of this._sortedActions) for(const _local_3 of this._sortedActions)
{ {
_local_2 = this._structure.getActionDefinitionWithState(_local_3.actionType); _local_2 = this._structure.getActionDefinitionWithState(_local_3.actionType);
if (((!(_local_2 == null)) && (_local_2.getPreventHeadTurn(_local_3.actionParameter)))) if(((!(_local_2 == null)) && (_local_2.getPreventHeadTurn(_local_3.actionParameter))))
{ {
k = true; k = true;
} }
@ -854,11 +854,11 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
this._sortedActions = this._structure.sortActions(this._actions); this._sortedActions = this._structure.sortActions(this._actions);
this._animationFrameCount = this._structure.maxFrames(this._sortedActions); this._animationFrameCount = this._structure.maxFrames(this._sortedActions);
if (!this._sortedActions) if(!this._sortedActions)
{ {
this._canvasOffsets = [0, 0, 0]; this._canvasOffsets = [0, 0, 0];
if (this._lastActionsString !== '') if(this._lastActionsString !== '')
{ {
k = true; k = true;
@ -869,15 +869,15 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
{ {
this._canvasOffsets = this._structure.getCanvasOffsets(this._sortedActions, this._scale, this._mainDirection); this._canvasOffsets = this._structure.getCanvasOffsets(this._sortedActions, this._scale, this._mainDirection);
for (const _local_4 of this._sortedActions) for(const _local_4 of this._sortedActions)
{ {
this._currentActionsString = (this._currentActionsString + (_local_4.actionType + _local_4.actionParameter)); this._currentActionsString = (this._currentActionsString + (_local_4.actionType + _local_4.actionParameter));
if (_local_4.actionType === AvatarAction.EFFECT) if(_local_4.actionType === AvatarAction.EFFECT)
{ {
const _local_5 = parseInt(_local_4.actionParameter); const _local_5 = parseInt(_local_4.actionParameter);
if (this._effectIdInUse !== _local_5) _local_2 = true; if(this._effectIdInUse !== _local_5) _local_2 = true;
this._effectIdInUse = _local_5; this._effectIdInUse = _local_5;
@ -885,16 +885,16 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
} }
} }
if (!_local_3) if(!_local_3)
{ {
if (this._effectIdInUse > -1) _local_2 = true; if(this._effectIdInUse > -1) _local_2 = true;
this._effectIdInUse = -1; this._effectIdInUse = -1;
} }
if (_local_2) this._cache.disposeInactiveActions(0); if(_local_2) this._cache.disposeInactiveActions(0);
if (this._lastActionsString != this._currentActionsString) if(this._lastActionsString != this._currentActionsString)
{ {
k = true; k = true;
@ -909,60 +909,60 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
private setActionsToParts(): void private setActionsToParts(): void
{ {
if (!this._sortedActions == null) return; if(!this._sortedActions == null) return;
const _local_3: number = GetTickerTime(); const _local_3: number = GetTickerTime();
const _local_4: string[] = []; const _local_4: string[] = [];
for (const k of this._sortedActions) _local_4.push(k.actionType); for(const k of this._sortedActions) _local_4.push(k.actionType);
for (const k of this._sortedActions) for(const k of this._sortedActions)
{ {
if ((k && k.definition) && k.definition.isAnimation) if((k && k.definition) && k.definition.isAnimation)
{ {
const _local_2 = this._structure.getAnimation(((k.definition.state + '.') + k.actionParameter)); const _local_2 = this._structure.getAnimation(((k.definition.state + '.') + k.actionParameter));
if (_local_2 && _local_2.hasOverriddenActions()) if(_local_2 && _local_2.hasOverriddenActions())
{ {
const _local_5 = _local_2.overriddenActionNames(); const _local_5 = _local_2.overriddenActionNames();
if (_local_5) if(_local_5)
{ {
for (const _local_6 of _local_5) for(const _local_6 of _local_5)
{ {
if (_local_4.indexOf(_local_6) >= 0) k.overridingAction = _local_2.overridingAction(_local_6); if(_local_4.indexOf(_local_6) >= 0) k.overridingAction = _local_2.overridingAction(_local_6);
} }
} }
} }
if (_local_2 && _local_2.resetOnToggle) if(_local_2 && _local_2.resetOnToggle)
{ {
this._animationHasResetOnToggle = true; this._animationHasResetOnToggle = true;
} }
} }
} }
for (const k of this._sortedActions) for(const k of this._sortedActions)
{ {
if (!((!(k)) || (!(k.definition)))) if(!((!(k)) || (!(k.definition))))
{ {
if (k.definition.isAnimation && (k.actionParameter === '')) k.actionParameter = '1'; if(k.definition.isAnimation && (k.actionParameter === '')) k.actionParameter = '1';
this.setActionToParts(k, _local_3); this.setActionToParts(k, _local_3);
if (k.definition.isAnimation) if(k.definition.isAnimation)
{ {
this._isAnimating = k.definition.isAnimated(k.actionParameter); this._isAnimating = k.definition.isAnimated(k.actionParameter);
const _local_2 = this._structure.getAnimation(((k.definition.state + '.') + k.actionParameter)); const _local_2 = this._structure.getAnimation(((k.definition.state + '.') + k.actionParameter));
if (_local_2) if(_local_2)
{ {
this._sprites = this._sprites.concat(_local_2.spriteData); this._sprites = this._sprites.concat(_local_2.spriteData);
if (_local_2.hasDirectionData()) this._directionOffset = _local_2.directionData.offset; if(_local_2.hasDirectionData()) this._directionOffset = _local_2.directionData.offset;
if (_local_2.hasAvatarData()) this._avatarSpriteData = _local_2.avatarData; if(_local_2.hasAvatarData()) this._avatarSpriteData = _local_2.avatarData;
} }
} }
} }
@ -971,15 +971,15 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
private setActionToParts(k: IActiveActionData, _arg_2: number): void private setActionToParts(k: IActiveActionData, _arg_2: number): void
{ {
if (((k == null) || (k.definition == null))) if(((k == null) || (k.definition == null)))
{ {
return; return;
} }
if (k.definition.assetPartDefinition == '') if(k.definition.assetPartDefinition == '')
{ {
return; return;
} }
if (k.definition.isMain) if(k.definition.isMain)
{ {
this._mainAction = k; this._mainAction = k;
this._cache.setGeometryType(k.definition.geometryType); this._cache.setGeometryType(k.definition.geometryType);
@ -990,11 +990,11 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
private resetBodyPartCache(k: IActiveActionData): void private resetBodyPartCache(k: IActiveActionData): void
{ {
if (!k) return; if(!k) return;
if (k.definition.assetPartDefinition === '') return; if(k.definition.assetPartDefinition === '') return;
if (k.definition.isMain) if(k.definition.isMain)
{ {
this._mainAction = k; this._mainAction = k;
this._cache.setGeometryType(k.definition.geometryType); this._cache.setGeometryType(k.definition.geometryType);
@ -1016,7 +1016,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
let _local_5 = 0.33; let _local_5 = 0.33;
const _local_6 = 1; const _local_6 = 1;
switch (channel) switch(channel)
{ {
case AvatarImage.CHANNELS_UNIQUE: case AvatarImage.CHANNELS_UNIQUE:
_local_3 = 0.3; _local_3 = 0.3;
@ -1084,7 +1084,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
public resetEffect(effect: number): void public resetEffect(effect: number): void
{ {
if (effect === this._effectIdInUse) if(effect === this._effectIdInUse)
{ {
this.resetActions(); this.resetActions();
this.setActionsToParts(); this.setActionsToParts();
@ -1092,7 +1092,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
this._animationHasResetOnToggle = true; this._animationHasResetOnToggle = true;
this._changes = true; this._changes = true;
if (this._effectListener) this._effectListener.resetEffect(effect); if(this._effectListener) this._effectListener.resetEffect(effect);
} }
} }
} }

View File

@ -30,16 +30,16 @@ export class AvatarImagePartContainer
this._isBlendable = isBlendable; this._isBlendable = isBlendable;
this._blendTransform = null; this._blendTransform = null;
if (this._partType === 'ey') this._isColorable = false; if(this._partType === 'ey') this._isColorable = false;
} }
public getFrameIndex(k: number): number public getFrameIndex(k: number): number
{ {
if (!this._frames || !this._frames.length) return 0; if(!this._frames || !this._frames.length) return 0;
const frameNumber = (k % this._frames.length); const frameNumber = (k % this._frames.length);
if (this._frames[frameNumber] instanceof AvatarAnimationFrame) if(this._frames[frameNumber] instanceof AvatarAnimationFrame)
{ {
return this._frames[frameNumber].number; return this._frames[frameNumber].number;
} }
@ -51,9 +51,9 @@ export class AvatarImagePartContainer
{ {
const frameNumber = (k % this._frames.length); const frameNumber = (k % this._frames.length);
if (this._frames && (this._frames.length > frameNumber)) if(this._frames && (this._frames.length > frameNumber))
{ {
if (this._frames[frameNumber] instanceof AvatarAnimationFrame) if(this._frames[frameNumber] instanceof AvatarAnimationFrame)
{ {
return this._frames[frameNumber]; return this._frames[frameNumber];
} }
@ -66,9 +66,9 @@ export class AvatarImagePartContainer
{ {
const frameNumber = (k % this._frames.length); const frameNumber = (k % this._frames.length);
if (this._frames && (this._frames.length > frameNumber)) if(this._frames && (this._frames.length > frameNumber))
{ {
if (this._frames[frameNumber] instanceof AvatarAnimationFrame) if(this._frames[frameNumber] instanceof AvatarAnimationFrame)
{ {
const frame = this._frames[frameNumber]; const frame = this._frames[frameNumber];

View File

@ -8,7 +8,7 @@ import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager';
import { AvatarFigureContainer } from './AvatarFigureContainer'; import { AvatarFigureContainer } from './AvatarFigureContainer';
import { AvatarImage } from './AvatarImage'; import { AvatarImage } from './AvatarImage';
import { AvatarStructure } from './AvatarStructure'; import { AvatarStructure } from './AvatarStructure';
import { HabboAvatarAnimations } from "./data/HabboAvatarAnimations"; import { HabboAvatarAnimations } from './data/HabboAvatarAnimations';
import { HabboAvatarGeometry } from './data/HabboAvatarGeometry'; import { HabboAvatarGeometry } from './data/HabboAvatarGeometry';
import { HabboAvatarPartSets } from './data/HabboAvatarPartSets'; import { HabboAvatarPartSets } from './data/HabboAvatarPartSets';
import { EffectAssetDownloadManager } from './EffectAssetDownloadManager'; import { EffectAssetDownloadManager } from './EffectAssetDownloadManager';
@ -74,7 +74,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
this._aliasCollection.init(); this._aliasCollection.init();
if (!this._avatarAssetDownloadManager) if(!this._avatarAssetDownloadManager)
{ {
this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(Nitro.instance.core.asset, this._structure); this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(Nitro.instance.core.asset, this._structure);
@ -82,7 +82,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
this._avatarAssetDownloadManager.addEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded); this._avatarAssetDownloadManager.addEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
} }
if (!this._effectAssetDownloadManager) if(!this._effectAssetDownloadManager)
{ {
this._effectAssetDownloadManager = new EffectAssetDownloadManager(Nitro.instance.core.asset, this._structure); this._effectAssetDownloadManager = new EffectAssetDownloadManager(Nitro.instance.core.asset, this._structure);
@ -95,14 +95,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public onDispose(): void public onDispose(): void
{ {
if (this._avatarAssetDownloadManager) if(this._avatarAssetDownloadManager)
{ {
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.DOWNLOADER_READY, this.onAvatarAssetDownloaderReady); this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.DOWNLOADER_READY, this.onAvatarAssetDownloaderReady);
this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded); this._avatarAssetDownloadManager.removeEventListener(AvatarAssetDownloadManager.LIBRARY_LOADED, this.onAvatarAssetDownloaded);
} }
if (this._effectAssetDownloadManager) if(this._effectAssetDownloadManager)
{ {
this._effectAssetDownloadManager.removeEventListener(EffectAssetDownloadManager.DOWNLOADER_READY, this.onEffectAssetDownloaderReady); this._effectAssetDownloadManager.removeEventListener(EffectAssetDownloadManager.DOWNLOADER_READY, this.onEffectAssetDownloaderReady);
@ -112,7 +112,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadGeometry(): void private loadGeometry(): void
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.initGeometry(HabboAvatarGeometry.geometry); this._structure.initGeometry(HabboAvatarGeometry.geometry);
@ -123,7 +123,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadPartSets(): void private loadPartSets(): void
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.initPartSets(HabboAvatarPartSets.partSets); this._structure.initPartSets(HabboAvatarPartSets.partSets);
@ -136,7 +136,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const defaultActions = NitroConfiguration.getValue<string>('avatar.default.actions'); const defaultActions = NitroConfiguration.getValue<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(); const request = new XMLHttpRequest();
@ -148,7 +148,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
request.onloadend = e => request.onloadend = e =>
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.updateActions(JSON.parse(request.responseText)); this._structure.updateActions(JSON.parse(request.responseText));
@ -171,7 +171,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private loadAnimations(): void private loadAnimations(): void
{ {
if (!this._structure) return; if(!this._structure) return;
this._structure.initAnimation(HabboAvatarAnimations.animations); this._structure.initAnimation(HabboAvatarAnimations.animations);
@ -184,14 +184,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const defaultFigureData = NitroConfiguration.getValue<IFigureData>('avatar.default.figuredata'); const defaultFigureData = NitroConfiguration.getValue<IFigureData>('avatar.default.figuredata');
if (!defaultFigureData || (typeof defaultFigureData === 'string')) if(!defaultFigureData || (typeof defaultFigureData === 'string'))
{ {
NitroLogger.error('XML figuredata is no longer supported'); NitroLogger.error('XML figuredata is no longer supported');
return; return;
} }
if (this._structure) this._structure.initFigureData(defaultFigureData); if(this._structure) this._structure.initFigureData(defaultFigureData);
const structureDownloader = new AvatarStructureDownload(NitroConfiguration.getValue<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData)); const structureDownloader = new AvatarStructureDownload(NitroConfiguration.getValue<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData));
@ -209,7 +209,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaderReady(event: INitroEvent): void private onAvatarAssetDownloaderReady(event: INitroEvent): void
{ {
if (!event) return; if(!event) return;
this._figureMapReady = true; this._figureMapReady = true;
@ -218,14 +218,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaded(event: INitroEvent): void private onAvatarAssetDownloaded(event: INitroEvent): void
{ {
if (!event) return; if(!event) return;
this._aliasCollection.reset(); this._aliasCollection.reset();
} }
private onEffectAssetDownloaderReady(event: INitroEvent): void private onEffectAssetDownloaderReady(event: INitroEvent): void
{ {
if (!event) return; if(!event) return;
this._effectMapReady = true; this._effectMapReady = true;
@ -234,20 +234,20 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onEffectAssetDownloaded(event: INitroEvent): void private onEffectAssetDownloaded(event: INitroEvent): void
{ {
if (!event) return; if(!event) return;
this._aliasCollection.reset(); this._aliasCollection.reset();
} }
private checkReady(): void 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; 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 public createFigureContainer(figure: string): IAvatarFigureContainer
@ -257,25 +257,25 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public isFigureContainerReady(container: IAvatarFigureContainer): boolean public isFigureContainerReady(container: IAvatarFigureContainer): boolean
{ {
if (!this._avatarAssetDownloadManager) return false; if(!this._avatarAssetDownloadManager) return false;
return this._avatarAssetDownloadManager.isAvatarFigureContainerReady(container); return this._avatarAssetDownloadManager.isAvatarFigureContainerReady(container);
} }
public createAvatarImage(figure: string, size: string, gender: string, listener: IAvatarImageListener = null, effectListener: IAvatarEffectListener = null): IAvatarImage 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); 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); 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); this._avatarAssetDownloadManager.downloadAvatarFigure(figureContainer, listener);
@ -284,7 +284,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void public downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void
{ {
if (!this._avatarAssetDownloadManager) return; if(!this._avatarAssetDownloadManager) return;
this._avatarAssetDownloadManager.downloadAvatarFigure(container, listener); this._avatarAssetDownloadManager.downloadAvatarFigure(container, listener);
} }
@ -295,17 +295,17 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const typeIds = this._structure.getMandatorySetTypeIds(gender, 2); const typeIds = this._structure.getMandatorySetTypeIds(gender, 2);
if (typeIds) if(typeIds)
{ {
const figureData = this._structure.figureData; 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); const figurePartSet = this._structure.getDefaultPartSet(id, gender);
if (figurePartSet) if(figurePartSet)
{ {
container.updatePart(id, figurePartSet.id, [0]); container.updatePart(id, figurePartSet.id, [0]);
@ -316,15 +316,15 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const setType = figureData.getSetType(id); const setType = figureData.getSetType(id);
if (setType) if(setType)
{ {
const figurePartSet = setType.getPartSet(container.getPartSetId(id)); const figurePartSet = setType.getPartSet(container.getPartSetId(id));
if (!figurePartSet) if(!figurePartSet)
{ {
const partSet = this._structure.getDefaultPartSet(id, gender); const partSet = this._structure.getDefaultPartSet(id, gender);
if (partSet) if(partSet)
{ {
container.updatePart(id, partSet.id, [0]); container.updatePart(id, partSet.id, [0]);
@ -341,49 +341,49 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[] = null): number 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 figureData = this._structure.figureData;
const parts = Array.from(container.getPartTypeIds()); const parts = Array.from(container.getPartTypeIds());
let clubLevel = 0; let clubLevel = 0;
for (const part of parts) for(const part of parts)
{ {
const set = figureData.getSetType(part); const set = figureData.getSetType(part);
if (!set) continue; if(!set) continue;
const setId = container.getPartSetId(part); const setId = container.getPartSetId(part);
const partSet = set.getPartSet(setId); const partSet = set.getPartSet(setId);
if (partSet) if(partSet)
{ {
clubLevel = Math.max(partSet.clubLevel, clubLevel); clubLevel = Math.max(partSet.clubLevel, clubLevel);
const palette = figureData.getPalette(set.paletteID); const palette = figureData.getPalette(set.paletteID);
const colors = container.getPartColorIds(part); const colors = container.getPartColorIds(part);
for (const colorId of colors) for(const colorId of colors)
{ {
const color = palette.getColor(colorId); const color = palette.getColor(colorId);
if (!color) continue; if(!color) continue;
clubLevel = Math.max(color.clubLevel, clubLevel); 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); 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; return clubLevel;
@ -405,7 +405,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const partSets: IFigurePartSet[] = this.resolveFigureSets(_arg_3); 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)); container.savePartData(partSet.type, partSet.id, container.getColourIds(partSet.type));
} }
@ -418,11 +418,11 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const structure = this.structureData; const structure = this.structureData;
const partSets: IFigurePartSet[] = []; const partSets: IFigurePartSet[] = [];
for (const setId of setIds) for(const setId of setIds)
{ {
const partSet = structure.getFigurePartSet(setId); const partSet = structure.getFigurePartSet(setId);
if (partSet) partSets.push(partSet); if(partSet) partSets.push(partSet);
} }
return partSets; return partSets;
@ -430,7 +430,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[] 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); return this._structure.getMandatorySetTypeIds(k, _arg_2);
} }
@ -457,7 +457,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public get structureData(): IStructureData public get structureData(): IStructureData
{ {
if (this._structure) return this._structure.figureData; if(this._structure) return this._structure.figureData;
return null; return null;
} }

View File

@ -42,7 +42,7 @@ export class AvatarStructure extends EventDispatcher
public dispose(): void public dispose(): void
{ {
if (this.disposed) return; if(this.disposed) return;
super.dispose(); super.dispose();
@ -55,14 +55,14 @@ export class AvatarStructure extends EventDispatcher
public initGeometry(k: any): void public initGeometry(k: any): void
{ {
if (!k) return; if(!k) return;
this._geometry = new AvatarModelGeometry(k); this._geometry = new AvatarModelGeometry(k);
} }
public initActions(k: IAssetManager, _arg_2: any): void public initActions(k: IAssetManager, _arg_2: any): void
{ {
if (!_arg_2) return; if(!_arg_2) return;
this._actionManager = new AvatarActionManager(k, _arg_2); this._actionManager = new AvatarActionManager(k, _arg_2);
this._defaultAction = this._actionManager.getDefaultAction(); this._defaultAction = this._actionManager.getDefaultAction();
@ -77,9 +77,9 @@ export class AvatarStructure extends EventDispatcher
public initPartSets(k: any): boolean public initPartSets(k: any): boolean
{ {
if (!k) return false; if(!k) return false;
if (this._partSetsData.parse(k)) if(this._partSetsData.parse(k))
{ {
this._partSetsData.getPartDefinition('ri').appendToFigure = true; this._partSetsData.getPartDefinition('ri').appendToFigure = true;
this._partSetsData.getPartDefinition('li').appendToFigure = true; this._partSetsData.getPartDefinition('li').appendToFigure = true;
@ -92,14 +92,14 @@ export class AvatarStructure extends EventDispatcher
public initAnimation(k: any): boolean public initAnimation(k: any): boolean
{ {
if (!k) return false; if(!k) return false;
return this._animationData.parse(k); return this._animationData.parse(k);
} }
public initFigureData(k: IFigureData): boolean public initFigureData(k: IFigureData): boolean
{ {
if (!k) return false; if(!k) return false;
return this._figureData.parse(k); return this._figureData.parse(k);
} }
@ -113,11 +113,11 @@ export class AvatarStructure extends EventDispatcher
{ {
let index = 0; let index = 0;
while (index < _arg_3) while(index < _arg_3)
{ {
const collection = k.getCollection((_arg_2 + index)); const collection = k.getCollection((_arg_2 + index));
if (collection) if(collection)
{ {
const animationData = collection.data; const animationData = collection.data;
@ -137,15 +137,15 @@ export class AvatarStructure extends EventDispatcher
{ {
const _local_4 = k.getPartColorIds(_arg_2); const _local_4 = k.getPartColorIds(_arg_2);
if ((!(_local_4)) || (_local_4.length < _arg_3)) return null; if((!(_local_4)) || (_local_4.length < _arg_3)) return null;
const _local_5 = this._figureData.getSetType(_arg_2); const _local_5 = this._figureData.getSetType(_arg_2);
if (_local_5 == null) return null; if(_local_5 == null) return null;
const _local_6 = this._figureData.getPalette(_local_5.paletteID); const _local_6 = this._figureData.getPalette(_local_5.paletteID);
if (!_local_6) return null; if(!_local_6) return null;
return _local_6.getColor(_local_4[_arg_3]); return _local_6.getColor(_local_4[_arg_3]);
} }
@ -184,7 +184,7 @@ export class AvatarStructure extends EventDispatcher
{ {
let _local_2 = 0; let _local_2 = 0;
for (const _local_3 of k) for(const _local_3 of k)
{ {
_local_2 = Math.max(_local_2, this._animationData.getFrameCount(_local_3.definition)); _local_2 = Math.max(_local_2, this._animationData.getFrameCount(_local_3.definition));
} }
@ -193,12 +193,12 @@ export class AvatarStructure extends EventDispatcher
public getMandatorySetTypeIds(k: string, _arg_2: number): string[] public getMandatorySetTypeIds(k: string, _arg_2: number): string[]
{ {
if (!this._mandatorySetTypeIds[k]) if(!this._mandatorySetTypeIds[k])
{ {
this._mandatorySetTypeIds[k] = []; this._mandatorySetTypeIds[k] = [];
} }
if (this._mandatorySetTypeIds[k][_arg_2]) if(this._mandatorySetTypeIds[k][_arg_2])
{ {
return this._mandatorySetTypeIds[k][_arg_2]; return this._mandatorySetTypeIds[k][_arg_2];
} }
@ -235,16 +235,16 @@ export class AvatarStructure extends EventDispatcher
const _local_4: string[] = []; const _local_4: string[] = [];
const _local_5 = k.definition.geometryType; const _local_5 = k.definition.geometryType;
if (k.definition.isAnimation) if(k.definition.isAnimation)
{ {
const _local_7 = ((k.definition.state + '.') + k.actionParameter); const _local_7 = ((k.definition.state + '.') + k.actionParameter);
const _local_8 = this._animationManager.getAnimation(_local_7); const _local_8 = this._animationManager.getAnimation(_local_7);
if (_local_8) if(_local_8)
{ {
_local_3 = _local_8.getAnimatedBodyPartIds(0, k.overridingAction); _local_3 = _local_8.getAnimatedBodyPartIds(0, k.overridingAction);
if (_local_8.hasAddData()) if(_local_8.hasAddData())
{ {
const _local_11 = { const _local_11 = {
id: '', id: '',
@ -262,11 +262,11 @@ export class AvatarStructure extends EventDispatcher
setType: '' setType: ''
}; };
for (const _local_13 of _local_8.addData) for(const _local_13 of _local_8.addData)
{ {
const _local_6 = this._geometry.getBodyPart(_local_5, _local_13.align); const _local_6 = this._geometry.getBodyPart(_local_5, _local_13.align);
if (_local_6) if(_local_6)
{ {
_local_11.id = _local_13.id; _local_11.id = _local_13.id;
_local_6.addPart(_local_11, _arg_2); _local_6.addPart(_local_11, _arg_2);
@ -276,30 +276,30 @@ export class AvatarStructure extends EventDispatcher
const _local_10 = this._partSetsData.addPartDefinition(_local_12); const _local_10 = this._partSetsData.addPartDefinition(_local_12);
_local_10.appendToFigure = true; _local_10.appendToFigure = true;
if (_local_13.base === '') _local_10.staticId = 1; if(_local_13.base === '') _local_10.staticId = 1;
if (_local_4.indexOf(_local_6.id) === -1) _local_4.push(_local_6.id); if(_local_4.indexOf(_local_6.id) === -1) _local_4.push(_local_6.id);
} }
} }
} }
} }
for (const _local_9 of _local_3) for(const _local_9 of _local_3)
{ {
const _local_6 = this._geometry.getBodyPart(_local_5, _local_9); const _local_6 = this._geometry.getBodyPart(_local_5, _local_9);
if (_local_6 && (_local_4.indexOf(_local_6.id) === -1)) _local_4.push(_local_6.id); if(_local_6 && (_local_4.indexOf(_local_6.id) === -1)) _local_4.push(_local_6.id);
} }
} }
else else
{ {
_local_3 = this._partSetsData.getActiveParts(k.definition); _local_3 = this._partSetsData.getActiveParts(k.definition);
for (const _local_14 of _local_3) for(const _local_14 of _local_3)
{ {
const _local_6 = this._geometry.getBodyPartOfItem(_local_5, _local_14, _arg_2); const _local_6 = this._geometry.getBodyPartOfItem(_local_5, _local_14, _arg_2);
if (_local_6 && (_local_4.indexOf(_local_6.id) === -1)) _local_4.push(_local_6.id); if(_local_6 && (_local_4.indexOf(_local_6.id) === -1)) _local_4.push(_local_6.id);
} }
} }
@ -322,7 +322,7 @@ export class AvatarStructure extends EventDispatcher
{ {
const _local_5 = this._animationData.getAction(k.definition); const _local_5 = this._animationData.getAction(k.definition);
if (_local_5) return _local_5.getFrameBodyPartOffset(_arg_2, _arg_3, _arg_4); if(_local_5) return _local_5.getFrameBodyPartOffset(_arg_2, _arg_3, _arg_4);
return AnimationAction.DEFAULT_OFFSET; return AnimationAction.DEFAULT_OFFSET;
} }
@ -335,31 +335,31 @@ export class AvatarStructure extends EventDispatcher
let _local_20: AvatarAnimationFrame[] = []; let _local_20: AvatarAnimationFrame[] = [];
let _local_36: IPartColor = null; let _local_36: IPartColor = null;
if (!_arg_3 == null) return []; if(!_arg_3 == null) return [];
const _local_9 = this._partSetsData.getActiveParts(_arg_3.definition); const _local_9 = this._partSetsData.getActiveParts(_arg_3.definition);
const _local_11: AvatarImagePartContainer[] = []; const _local_11: AvatarImagePartContainer[] = [];
let _local_14: any[] = [0]; let _local_14: any[] = [0];
const _local_15 = this._animationData.getAction(_arg_3.definition); const _local_15 = this._animationData.getAction(_arg_3.definition);
if (_arg_3.definition.isAnimation) if(_arg_3.definition.isAnimation)
{ {
const _local_24 = ((_arg_3.definition.state + '.') + _arg_3.actionParameter); const _local_24 = ((_arg_3.definition.state + '.') + _arg_3.actionParameter);
const _local_10 = this._animationManager.getAnimation(_local_24); const _local_10 = this._animationManager.getAnimation(_local_24);
if (_local_10) if(_local_10)
{ {
_local_14 = this.getPopulatedArray(_local_10.frameCount(_arg_3.overridingAction)); _local_14 = this.getPopulatedArray(_local_10.frameCount(_arg_3.overridingAction));
for (const _local_25 of _local_10.getAnimatedBodyPartIds(0, _arg_3.overridingAction)) for(const _local_25 of _local_10.getAnimatedBodyPartIds(0, _arg_3.overridingAction))
{ {
if (_local_25 === k) if(_local_25 === k)
{ {
const _local_26 = this._geometry.getBodyPart(_arg_4, _local_25); const _local_26 = this._geometry.getBodyPart(_arg_4, _local_25);
if (_local_26) if(_local_26)
{ {
for (const _local_27 of _local_26.getDynamicParts(_arg_7)) for(const _local_27 of _local_26.getDynamicParts(_arg_7))
{ {
_local_9.push(_local_27.id); _local_9.push(_local_27.id);
} }
@ -372,11 +372,11 @@ export class AvatarStructure extends EventDispatcher
const _local_16 = this._geometry.getParts(_arg_4, k, _arg_5, _local_9, _arg_7); const _local_16 = this._geometry.getParts(_arg_4, k, _arg_5, _local_9, _arg_7);
const _local_21 = _arg_2.getPartTypeIds(); const _local_21 = _arg_2.getPartTypeIds();
for (const _local_17 of _local_21) for(const _local_17 of _local_21)
{ {
if (_arg_8) if(_arg_8)
{ {
if (_arg_8.get(_local_17)) continue; if(_arg_8.get(_local_17)) continue;
} }
const _local_28 = _arg_2.getPartSetId(_local_17); const _local_28 = _arg_2.getPartSetId(_local_17);
@ -385,27 +385,27 @@ export class AvatarStructure extends EventDispatcher
if (_local_30) if(_local_30)
{ {
const _local_31 = this._figureData.getPalette(_local_30.paletteID); const _local_31 = this._figureData.getPalette(_local_30.paletteID);
if (_local_31) if(_local_31)
{ {
const _local_32 = _local_30.getPartSet(_local_28); const _local_32 = _local_30.getPartSet(_local_28);
if (_local_32) if(_local_32)
{ {
removes = removes.concat(_local_32.hiddenLayers); removes = removes.concat(_local_32.hiddenLayers);
for (const _local_33 of _local_32.parts) for(const _local_33 of _local_32.parts)
{ {
if (_local_16.indexOf(_local_33.type) > -1) if(_local_16.indexOf(_local_33.type) > -1)
{ {
if (_local_15) if(_local_15)
{ {
const _local_19 = _local_15.getPart(_local_33.type); const _local_19 = _local_15.getPart(_local_33.type);
if (_local_19) if(_local_19)
{ {
_local_20 = _local_19.frames; _local_20 = _local_19.frames;
} }
@ -421,15 +421,15 @@ export class AvatarStructure extends EventDispatcher
_local_34 = _arg_3.definition; _local_34 = _arg_3.definition;
if (_local_9.indexOf(_local_33.type) === -1) _local_34 = this._defaultAction; if(_local_9.indexOf(_local_33.type) === -1) _local_34 = this._defaultAction;
const _local_13 = this._partSetsData.getPartDefinition(_local_33.type); const _local_13 = this._partSetsData.getPartDefinition(_local_33.type);
let _local_35 = (!_local_13) ? _local_33.type : _local_13.flippedSetType; let _local_35 = (!_local_13) ? _local_33.type : _local_13.flippedSetType;
if (!_local_35 || (_local_35 === '')) _local_35 = _local_33.type; if(!_local_35 || (_local_35 === '')) _local_35 = _local_33.type;
if (_local_29 && (_local_29.length > (_local_33.colorLayerIndex - 1))) if(_local_29 && (_local_29.length > (_local_33.colorLayerIndex - 1)))
{ {
_local_36 = _local_31.getColor(_local_29[(_local_33.colorLayerIndex - 1)]); _local_36 = _local_31.getColor(_local_29[(_local_33.colorLayerIndex - 1)]);
} }
@ -447,18 +447,18 @@ export class AvatarStructure extends EventDispatcher
const _local_22: AvatarImagePartContainer[] = []; const _local_22: AvatarImagePartContainer[] = [];
for (const _local_12 of _local_16) for(const _local_12 of _local_16)
{ {
let _local_39: IPartColor = null; let _local_39: IPartColor = null;
let _local_38 = false; let _local_38 = false;
const _local_40 = ((_arg_8) && (_arg_8.get(_local_12))); const _local_40 = ((_arg_8) && (_arg_8.get(_local_12)));
for (const _local_23 of _local_11) for(const _local_23 of _local_11)
{ {
if (_local_23.partType === _local_12) if(_local_23.partType === _local_12)
{ {
if (_local_40) if(_local_40)
{ {
_local_39 = _local_23.color; _local_39 = _local_23.color;
} }
@ -466,31 +466,31 @@ export class AvatarStructure extends EventDispatcher
{ {
_local_38 = true; _local_38 = true;
if (removes.indexOf(_local_12) === -1) _local_22.push(_local_23); if(removes.indexOf(_local_12) === -1) _local_22.push(_local_23);
} }
} }
} }
if (!_local_38) if(!_local_38)
{ {
if (_local_40) if(_local_40)
{ {
const _local_41 = _arg_8.get(_local_12); const _local_41 = _arg_8.get(_local_12);
let _local_42 = 0; let _local_42 = 0;
let _local_43 = 0; let _local_43 = 0;
while (_local_43 < _local_41.length) while(_local_43 < _local_41.length)
{ {
_local_42 = (_local_42 + _local_41.charCodeAt(_local_43)); _local_42 = (_local_42 + _local_41.charCodeAt(_local_43));
_local_43++; _local_43++;
} }
if (_local_15) if(_local_15)
{ {
const _local_19 = _local_15.getPart(_local_12); const _local_19 = _local_15.getPart(_local_12);
if (_local_19) if(_local_19)
{ {
_local_20 = _local_19.frames; _local_20 = _local_19.frames;
} }
@ -510,11 +510,11 @@ export class AvatarStructure extends EventDispatcher
} }
else else
{ {
if (_local_9.indexOf(_local_12) > -1) if(_local_9.indexOf(_local_12) > -1)
{ {
const _local_44 = this._geometry.getBodyPartOfItem(_arg_4, _local_12, _arg_7); const _local_44 = this._geometry.getBodyPartOfItem(_arg_4, _local_12, _arg_7);
if (k !== _local_44.id) if(k !== _local_44.id)
{ {
// //
} }
@ -525,36 +525,36 @@ export class AvatarStructure extends EventDispatcher
let _local_45 = false; let _local_45 = false;
let _local_46 = 1; let _local_46 = 1;
if (_local_13.appendToFigure) if(_local_13.appendToFigure)
{ {
let _local_47 = '1'; let _local_47 = '1';
if (_arg_3.actionParameter !== '') if(_arg_3.actionParameter !== '')
{ {
_local_47 = _arg_3.actionParameter; _local_47 = _arg_3.actionParameter;
} }
if (_local_13.hasStaticId()) if(_local_13.hasStaticId())
{ {
_local_47 = _local_13.staticId.toString(); _local_47 = _local_13.staticId.toString();
} }
if (_local_10 != null) if(_local_10 != null)
{ {
const _local_48 = _local_10.getAddData(_local_12); const _local_48 = _local_10.getAddData(_local_12);
if (_local_48) if(_local_48)
{ {
_local_45 = _local_48.isBlended; _local_45 = _local_48.isBlended;
_local_46 = _local_48.blend; _local_46 = _local_48.blend;
} }
} }
if (_local_15) if(_local_15)
{ {
const _local_19 = _local_15.getPart(_local_12); const _local_19 = _local_15.getPart(_local_12);
if (_local_19) if(_local_19)
{ {
_local_20 = _local_19.frames; _local_20 = _local_19.frames;
} }
@ -587,7 +587,7 @@ export class AvatarStructure extends EventDispatcher
let index = 0; let index = 0;
while (index < k) while(index < k)
{ {
_local_2.push(index); _local_2.push(index);
@ -599,13 +599,13 @@ export class AvatarStructure extends EventDispatcher
public getItemIds(): string[] public getItemIds(): string[]
{ {
if (this._actionManager) if(this._actionManager)
{ {
const k = this._actionManager.getActionDefinition('CarryItem').params; const k = this._actionManager.getActionDefinition('CarryItem').params;
const _local_2 = []; const _local_2 = [];
for (const _local_3 of k.values()) _local_2.push(_local_3); for(const _local_3 of k.values()) _local_2.push(_local_3);
return _local_2; return _local_2;
} }

View File

@ -33,16 +33,16 @@ export class EffectAssetDownloadLibrary extends EventDispatcher implements IEffe
const asset = this._assets.getCollection(this._libraryName); const asset = this._assets.getCollection(this._libraryName);
if (asset) this._state = EffectAssetDownloadLibrary.LOADED; if(asset) this._state = EffectAssetDownloadLibrary.LOADED;
} }
public downloadAsset(): void public downloadAsset(): void
{ {
if (!this._assets || (this._state === EffectAssetDownloadLibrary.LOADING) || (this._state === EffectAssetDownloadLibrary.LOADED)) return; if(!this._assets || (this._state === EffectAssetDownloadLibrary.LOADING) || (this._state === EffectAssetDownloadLibrary.LOADED)) return;
const asset = this._assets.getCollection(this._libraryName); const asset = this._assets.getCollection(this._libraryName);
if (asset) if(asset)
{ {
this._state = EffectAssetDownloadLibrary.LOADED; this._state = EffectAssetDownloadLibrary.LOADED;
@ -55,13 +55,13 @@ export class EffectAssetDownloadLibrary extends EventDispatcher implements IEffe
this._assets.downloadAsset(this._downloadUrl, (flag: boolean) => this._assets.downloadAsset(this._downloadUrl, (flag: boolean) =>
{ {
if (flag) if(flag)
{ {
this._state = EffectAssetDownloadLibrary.LOADED; this._state = EffectAssetDownloadLibrary.LOADED;
const collection = this._assets.getCollection(this._libraryName); const collection = this._assets.getCollection(this._libraryName);
if (collection) this._animation = collection.data.animations; if(collection) this._animation = collection.data.animations;
this.dispatchEvent(new AvatarRenderEffectLibraryEvent(AvatarRenderEffectLibraryEvent.DOWNLOAD_COMPLETE, this)); this.dispatchEvent(new AvatarRenderEffectLibraryEvent(AvatarRenderEffectLibraryEvent.DOWNLOAD_COMPLETE, this));
} }

View File

@ -61,7 +61,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
request.onloadend = e => request.onloadend = e =>
{ {
if (request.responseText) if(request.responseText)
{ {
const data = JSON.parse(request.responseText); const data = JSON.parse(request.responseText);
@ -89,17 +89,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
private processEffectMap(data: any): void 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 id = (effect.id as string);
const lib = (effect.lib as string); const lib = (effect.lib as string);
const revision = (effect.revision || ''); const revision = (effect.revision || '');
if (this._libraryNames.indexOf(lib) >= 0) continue; if(this._libraryNames.indexOf(lib) >= 0) continue;
this._libraryNames.push(lib); this._libraryNames.push(lib);
@ -109,7 +109,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
let existing = this._effectMap.get(id); let existing = this._effectMap.get(id);
if (!existing) existing = []; if(!existing) existing = [];
existing.push(downloadLibrary); existing.push(downloadLibrary);
@ -119,7 +119,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
public downloadAvatarEffect(id: number, listener: IAvatarEffectListener): void 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]);
@ -128,13 +128,13 @@ export class EffectAssetDownloadManager extends EventDispatcher
const pendingLibraries = this.getAvatarEffectPendingLibraries(id); 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()); let listeners = this._effectListeners.get(id.toString());
if (!listeners) listeners = []; if(!listeners) listeners = [];
listeners.push(listener); listeners.push(listener);
@ -143,24 +143,24 @@ export class EffectAssetDownloadManager extends EventDispatcher
this._incompleteEffects.set(id.toString(), pendingLibraries); 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); this.downloadLibrary(library);
} }
} }
else else
{ {
if (listener && !listener.disposed) listener.resetEffect(id); if(listener && !listener.disposed) listener.resetEffect(id);
} }
} }
private onAvatarRenderReady(event: INitroEvent): void private onAvatarRenderReady(event: INitroEvent): 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); this.downloadAvatarEffect(id, listener);
} }
@ -170,34 +170,34 @@ export class EffectAssetDownloadManager extends EventDispatcher
private onLibraryLoaded(event: AvatarRenderEffectLibraryEvent): void private onLibraryLoaded(event: AvatarRenderEffectLibraryEvent): void
{ {
if (!event || !event.library) return; if(!event || !event.library) return;
const loadedEffects: string[] = []; const loadedEffects: string[] = [];
this._structure.registerAnimation(event.library.animation); 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; 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; isReady = false;
break; break;
} }
if (isReady) if(isReady)
{ {
loadedEffects.push(id); loadedEffects.push(id);
const listeners = this._effectListeners.get(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)); listener.resetEffect(parseInt(id));
} }
@ -208,17 +208,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; let index = 0;
while (index < this._currentDownloads.length) while(index < this._currentDownloads.length)
{ {
const download = this._currentDownloads[index]; 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++; index++;
@ -229,19 +229,19 @@ export class EffectAssetDownloadManager extends EventDispatcher
{ {
const libraries = this._missingMandatoryLibs.slice(); 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); 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 public isAvatarEffectReady(effect: number): boolean
{ {
if (!this._isReady || !this._structure.renderManager.isReady) if(!this._isReady || !this._structure.renderManager.isReady)
{ {
return false; return false;
} }
@ -255,17 +255,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
{ {
const pendingLibraries: EffectAssetDownloadLibrary[] = []; const pendingLibraries: EffectAssetDownloadLibrary[] = [];
if (!this._structure) return pendingLibraries; if(!this._structure) return pendingLibraries;
const libraries = this._effectMap.get(id.toString()); 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);
} }
} }
@ -274,9 +274,9 @@ export class EffectAssetDownloadManager extends EventDispatcher
private downloadLibrary(library: EffectAssetDownloadLibrary): void 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); this._pendingDownloadQueue.push(library);
@ -285,7 +285,7 @@ export class EffectAssetDownloadManager extends EventDispatcher
private processDownloadQueue(): void private processDownloadQueue(): void
{ {
while (this._pendingDownloadQueue.length) while(this._pendingDownloadQueue.length)
{ {
const library = this._pendingDownloadQueue[0]; const library = this._pendingDownloadQueue[0];

View File

@ -41,22 +41,22 @@ export class ActionDefinition implements IActionDefinition
this._defaultParameterValue = ''; this._defaultParameterValue = '';
this._canvasOffsets = null; this._canvasOffsets = null;
if (data.params && (data.params.length > 0)) if(data.params && (data.params.length > 0))
{ {
for (const param of data.params) for(const param of data.params)
{ {
if (!param) continue; if(!param) continue;
if (param.id === 'default') this._defaultParameterValue = param.value; if(param.id === 'default') this._defaultParameterValue = param.value;
else this._params.set(param.id, param.value); else this._params.set(param.id, param.value);
} }
} }
if (data.types && (data.types.length > 0)) if(data.types && (data.types.length > 0))
{ {
for (const type of data.types) for(const type of data.types)
{ {
if (!type) continue; if(!type) continue;
const action = new ActionType(type); const action = new ActionType(type);
@ -67,11 +67,11 @@ export class ActionDefinition implements IActionDefinition
public setOffsets(k: string, _arg_2: number, _arg_3: number[]): void public setOffsets(k: string, _arg_2: number, _arg_3: number[]): void
{ {
if (!this._canvasOffsets) this._canvasOffsets = new Map(); if(!this._canvasOffsets) this._canvasOffsets = new Map();
let existing = this._canvasOffsets.get(k); let existing = this._canvasOffsets.get(k);
if (!existing) if(!existing)
{ {
existing = new Map(); existing = new Map();
@ -83,33 +83,33 @@ export class ActionDefinition implements IActionDefinition
public getOffsets(k: string, _arg_2: number): number[] public getOffsets(k: string, _arg_2: number): number[]
{ {
if (!this._canvasOffsets) return null; if(!this._canvasOffsets) return null;
const existing = this._canvasOffsets.get(k); const existing = this._canvasOffsets.get(k);
if (!existing) return null; if(!existing) return null;
return existing.get(_arg_2); return existing.get(_arg_2);
} }
public getType(id: string): ActionType public getType(id: string): ActionType
{ {
if (!id) return null; if(!id) return null;
const existing = this._types.get(parseInt(id)); const existing = this._types.get(parseInt(id));
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public getParameterValue(id: string): string public getParameterValue(id: string): string
{ {
if (!id) return ''; if(!id) return '';
const existing = this._params.get(id); const existing = this._params.get(id);
if (!existing) return this._defaultParameterValue; if(!existing) return this._defaultParameterValue;
return existing; return existing;
} }
@ -121,33 +121,33 @@ export class ActionDefinition implements IActionDefinition
private getTypePrevents(type: string): string[] private getTypePrevents(type: string): string[]
{ {
if (!type) return []; if(!type) return [];
const existing = this._types.get(parseInt(type)); const existing = this._types.get(parseInt(type));
if (!existing) return []; if(!existing) return [];
return existing.prevents; return existing.prevents;
} }
public getPreventHeadTurn(k: string): boolean public getPreventHeadTurn(k: string): boolean
{ {
if (!k) return this._preventHeadTurn; if(!k) return this._preventHeadTurn;
const type = this.getType(k); const type = this.getType(k);
if (!type) return this._preventHeadTurn; if(!type) return this._preventHeadTurn;
return type.preventHeadTurn; return type.preventHeadTurn;
} }
public isAnimated(k: string): boolean public isAnimated(k: string): boolean
{ {
if (!k) return true; if(!k) return true;
const type = this.getType(k); const type = this.getType(k);
if (!type) return true; if(!type) return true;
return type.isAnimated; return type.isAnimated;
} }

View File

@ -26,7 +26,7 @@ export class ActiveActionData implements IActiveActionData
public get id(): string public get id(): string
{ {
if (!this._definition) return ''; if(!this._definition) return '';
return this._definition.id + '_' + this._actionParameter; return this._definition.id + '_' + this._actionParameter;
} }

View File

@ -18,36 +18,36 @@ export class AvatarActionManager
public updateActions(data: any): void public updateActions(data: any): void
{ {
if (!data) return; if(!data) return;
for (const action of data.actions) for(const action of data.actions)
{ {
if (!action || !action.state) continue; if(!action || !action.state) continue;
const definition = new ActionDefinition(action); const definition = new ActionDefinition(action);
this._actions.set(definition.state, definition); this._actions.set(definition.state, definition);
} }
if (data.actionOffsets) this.parseActionOffsets(data.actionOffsets); if(data.actionOffsets) this.parseActionOffsets(data.actionOffsets);
} }
private parseActionOffsets(offsets: any): void private parseActionOffsets(offsets: any): void
{ {
if (!offsets || !offsets.length) return; if(!offsets || !offsets.length) return;
for (const offset of offsets) for(const offset of offsets)
{ {
const action = this._actions.get(offset.action); const action = this._actions.get(offset.action);
if (!action) continue; if(!action) continue;
for (const canvasOffset of offset.offsets) for(const canvasOffset of offset.offsets)
{ {
const size = (canvasOffset.size || ''); const size = (canvasOffset.size || '');
const direction = canvasOffset.direction; const direction = canvasOffset.direction;
if ((size === '') || (direction === undefined)) continue; if((size === '') || (direction === undefined)) continue;
const x = (canvasOffset.x || 0); const x = (canvasOffset.x || 0);
const y = (canvasOffset.y || 0); const y = (canvasOffset.y || 0);
@ -60,11 +60,11 @@ export class AvatarActionManager
public getActionDefinition(id: string): ActionDefinition public getActionDefinition(id: string): ActionDefinition
{ {
if (!id) return null; if(!id) return null;
for (const action of this._actions.values()) for(const action of this._actions.values())
{ {
if (!action || (action.id !== id)) continue; if(!action || (action.id !== id)) continue;
return action; return action;
} }
@ -76,18 +76,18 @@ export class AvatarActionManager
{ {
const existing = this._actions.get(state); const existing = this._actions.get(state);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
public getDefaultAction(): ActionDefinition public getDefaultAction(): ActionDefinition
{ {
if (this._defaultAction) return this._defaultAction; if(this._defaultAction) return this._defaultAction;
for (const action of this._actions.values()) for(const action of this._actions.values())
{ {
if (!action || !action.isDefault) continue; if(!action || !action.isDefault) continue;
this._defaultAction = action; this._defaultAction = action;
@ -101,14 +101,14 @@ export class AvatarActionManager
{ {
let canvasOffsets: number[] = []; let canvasOffsets: number[] = [];
for (const activeAction of k) for(const activeAction of k)
{ {
if (!activeAction) continue; if(!activeAction) continue;
const action = this._actions.get(activeAction.actionType); const action = this._actions.get(activeAction.actionType);
const offsets = action && action.getOffsets(_arg_2, _arg_3); const offsets = action && action.getOffsets(_arg_2, _arg_3);
if (offsets) canvasOffsets = offsets; if(offsets) canvasOffsets = offsets;
} }
return canvasOffsets; return canvasOffsets;
@ -116,19 +116,19 @@ export class AvatarActionManager
public sortActions(actions: IActiveActionData[]): IActiveActionData[] public sortActions(actions: IActiveActionData[]): IActiveActionData[]
{ {
if (!actions) return null; if(!actions) return null;
actions = this.filterActions(actions); actions = this.filterActions(actions);
const validatedActions: IActiveActionData[] = []; const validatedActions: IActiveActionData[] = [];
for (const action of actions) for(const action of actions)
{ {
if (!action) continue; if(!action) continue;
const definition = this._actions.get(action.actionType); const definition = this._actions.get(action.actionType);
if (!definition) continue; if(!definition) continue;
action.definition = definition; action.definition = definition;
@ -145,24 +145,24 @@ export class AvatarActionManager
let preventions: string[] = []; let preventions: string[] = [];
const activeActions: IActiveActionData[] = []; const activeActions: IActiveActionData[] = [];
for (const action of actions) for(const action of actions)
{ {
if (!action) continue; if(!action) continue;
const localAction = this._actions.get(action.actionType); const localAction = this._actions.get(action.actionType);
if (localAction) preventions = preventions.concat(localAction.getPrevents(action.actionParameter)); if(localAction) preventions = preventions.concat(localAction.getPrevents(action.actionParameter));
} }
for (const action of actions) for(const action of actions)
{ {
if (!action) continue; if(!action) continue;
let actionType = action.actionType; let actionType = action.actionType;
if (action.actionType === 'fx') actionType = (actionType + ('.' + action.actionParameter)); if(action.actionType === 'fx') actionType = (actionType + ('.' + action.actionParameter));
if (preventions.indexOf(actionType) >= 0) continue; if(preventions.indexOf(actionType) >= 0) continue;
activeActions.push(action); activeActions.push(action);
} }
@ -172,14 +172,14 @@ export class AvatarActionManager
private sortByPrecedence(actionOne: IActiveActionData, actionTwo: IActiveActionData): number private sortByPrecedence(actionOne: IActiveActionData, actionTwo: IActiveActionData): number
{ {
if (!actionOne || !actionTwo) return 0; if(!actionOne || !actionTwo) return 0;
const precedenceOne = actionOne.definition.precedence; const precedenceOne = actionOne.definition.precedence;
const precedenceTwo = actionTwo.definition.precedence; const precedenceTwo = actionTwo.definition.precedence;
if (precedenceOne < precedenceTwo) return 1; if(precedenceOne < precedenceTwo) return 1;
if (precedenceOne > precedenceTwo) return -1; if(precedenceOne > precedenceTwo) return -1;
return 0; return 0;
} }

View File

@ -36,37 +36,37 @@ export class Animation implements IAnimation
this._overrideFrames = null; this._overrideFrames = null;
this._resetOnToggle = (_arg_2.resetOnToggle || false); this._resetOnToggle = (_arg_2.resetOnToggle || false);
if (_arg_2.sprites && _arg_2.sprites.length) if(_arg_2.sprites && _arg_2.sprites.length)
{ {
this._spriteData = []; this._spriteData = [];
for (const sprite of _arg_2.sprites) this._spriteData.push(new SpriteDataContainer(this, sprite)); for(const sprite of _arg_2.sprites) this._spriteData.push(new SpriteDataContainer(this, sprite));
} }
if (_arg_2.avatars && _arg_2.avatars.length) this._avatarData = new AvatarDataContainer(_arg_2.avatars[0]); if(_arg_2.avatars && _arg_2.avatars.length) this._avatarData = new AvatarDataContainer(_arg_2.avatars[0]);
if (_arg_2.directions && _arg_2.directions.length) this._directionData = new DirectionDataContainer(_arg_2.directions[0]); if(_arg_2.directions && _arg_2.directions.length) this._directionData = new DirectionDataContainer(_arg_2.directions[0]);
if (_arg_2.removes && _arg_2.removes.length) if(_arg_2.removes && _arg_2.removes.length)
{ {
this._removeData = []; this._removeData = [];
for (const remove of _arg_2.removes) this._removeData.push(remove.id); for(const remove of _arg_2.removes) this._removeData.push(remove.id);
} }
if (_arg_2.adds && _arg_2.adds.length) if(_arg_2.adds && _arg_2.adds.length)
{ {
this._addData = []; this._addData = [];
for (const add of _arg_2.adds) this._addData.push(new AddDataContainer(add)); for(const add of _arg_2.adds) this._addData.push(new AddDataContainer(add));
} }
if (_arg_2.overrides && _arg_2.overrides.length) if(_arg_2.overrides && _arg_2.overrides.length)
{ {
this._overrideFrames = new Map(); this._overrideFrames = new Map();
this._overriddenActions = new Map(); this._overriddenActions = new Map();
for (const override of _arg_2.overrides) for(const override of _arg_2.overrides)
{ {
const name = override.name; const name = override.name;
const value = override.override; const value = override.override;
@ -86,23 +86,23 @@ export class Animation implements IAnimation
private parseFrames(frames: AvatarAnimationLayerData[][], _arg_2: IAssetAnimationFrame[], _arg_3: AvatarStructure): void private parseFrames(frames: AvatarAnimationLayerData[][], _arg_2: IAssetAnimationFrame[], _arg_3: AvatarStructure): void
{ {
if (!_arg_2 || !_arg_2.length) return; if(!_arg_2 || !_arg_2.length) return;
for (const frame of _arg_2) for(const frame of _arg_2)
{ {
let repeats = 1; let repeats = 1;
if (frame.repeats && (frame.repeats > 1)) repeats = frame.repeats; if(frame.repeats && (frame.repeats > 1)) repeats = frame.repeats;
let index = 0; let index = 0;
while (index < repeats) while(index < repeats)
{ {
const layers: AvatarAnimationLayerData[] = []; const layers: AvatarAnimationLayerData[] = [];
if (frame.bodyparts && frame.bodyparts.length) if(frame.bodyparts && frame.bodyparts.length)
{ {
for (const bodyPart of frame.bodyparts) for(const bodyPart of frame.bodyparts)
{ {
const definition = _arg_3.getActionDefinition(bodyPart.action); const definition = _arg_3.getActionDefinition(bodyPart.action);
const layer = new AvatarAnimationLayerData(bodyPart, AvatarAnimationLayerData.BODYPART, definition); const layer = new AvatarAnimationLayerData(bodyPart, AvatarAnimationLayerData.BODYPART, definition);
@ -111,9 +111,9 @@ export class Animation implements IAnimation
} }
} }
if (frame.fxs && frame.fxs.length) if(frame.fxs && frame.fxs.length)
{ {
for (const fx of frame.fxs) for(const fx of frame.fxs)
{ {
const definition = _arg_3.getActionDefinition(fx.action); const definition = _arg_3.getActionDefinition(fx.action);
const layer = new AvatarAnimationLayerData(fx, AvatarAnimationLayerData.FX, definition); const layer = new AvatarAnimationLayerData(fx, AvatarAnimationLayerData.FX, definition);
@ -131,13 +131,13 @@ export class Animation implements IAnimation
public frameCount(k: string = null): number public frameCount(k: string = null): number
{ {
if (!k) return this._frames.length; if(!k) return this._frames.length;
if (this._overrideFrames) if(this._overrideFrames)
{ {
const _local_2 = this._overrideFrames.get(k); const _local_2 = this._overrideFrames.get(k);
if (_local_2) return _local_2.length; if(_local_2) return _local_2.length;
} }
return 0; return 0;
@ -145,38 +145,38 @@ export class Animation implements IAnimation
public hasOverriddenActions(): boolean public hasOverriddenActions(): boolean
{ {
if (!this._overriddenActions) return false; if(!this._overriddenActions) return false;
return (this._overriddenActions.size > 0); return (this._overriddenActions.size > 0);
} }
public overriddenActionNames(): string[] public overriddenActionNames(): string[]
{ {
if (!this._overriddenActions) return null; if(!this._overriddenActions) return null;
const keys: string[] = []; const keys: string[] = [];
for (const key of this._overriddenActions.keys()) keys.push(key); for(const key of this._overriddenActions.keys()) keys.push(key);
return keys; return keys;
} }
public overridingAction(k: string): string public overridingAction(k: string): string
{ {
if (!this._overriddenActions) return null; if(!this._overriddenActions) return null;
return this._overriddenActions.get(k); return this._overriddenActions.get(k);
} }
private getFrame(frameCount: number, _arg_2: string = null): AvatarAnimationLayerData[] private getFrame(frameCount: number, _arg_2: string = null): AvatarAnimationLayerData[]
{ {
if (frameCount < 0) frameCount = 0; if(frameCount < 0) frameCount = 0;
let layers: AvatarAnimationLayerData[] = []; let layers: AvatarAnimationLayerData[] = [];
if (!_arg_2) if(!_arg_2)
{ {
if (this._frames.length > 0) if(this._frames.length > 0)
{ {
layers = this._frames[(frameCount % this._frames.length)]; layers = this._frames[(frameCount % this._frames.length)];
} }
@ -185,7 +185,7 @@ export class Animation implements IAnimation
{ {
const overrideLayers = this._overrideFrames.get(_arg_2); const overrideLayers = this._overrideFrames.get(_arg_2);
if (overrideLayers && (overrideLayers.length > 0)) if(overrideLayers && (overrideLayers.length > 0))
{ {
layers = overrideLayers[(frameCount % overrideLayers.length)]; layers = overrideLayers[(frameCount % overrideLayers.length)];
} }
@ -198,20 +198,20 @@ export class Animation implements IAnimation
{ {
const _local_3: string[] = []; const _local_3: string[] = [];
for (const layer of this.getFrame(k, _arg_2)) for(const layer of this.getFrame(k, _arg_2))
{ {
if (layer.type === AvatarAnimationLayerData.BODYPART) if(layer.type === AvatarAnimationLayerData.BODYPART)
{ {
_local_3.push(layer.id); _local_3.push(layer.id);
} }
else if (layer.type === AvatarAnimationLayerData.FX) else if(layer.type === AvatarAnimationLayerData.FX)
{ {
if (this._addData && this._addData.length) if(this._addData && this._addData.length)
{ {
for (const _local_5 of this._addData) for(const _local_5 of this._addData)
{ {
if (_local_5.id === layer.id) _local_3.push(_local_5.align); if(_local_5.id === layer.id) _local_3.push(_local_5.align);
} }
} }
} }
@ -222,17 +222,17 @@ export class Animation implements IAnimation
public getLayerData(frameCount: number, spriteId: string, _arg_3: string = null): AvatarAnimationLayerData public getLayerData(frameCount: number, spriteId: string, _arg_3: string = null): AvatarAnimationLayerData
{ {
for (const layer of this.getFrame(frameCount, _arg_3)) for(const layer of this.getFrame(frameCount, _arg_3))
{ {
if (layer.id === spriteId) return layer; if(layer.id === spriteId) return layer;
if (layer.type === AvatarAnimationLayerData.FX) if(layer.type === AvatarAnimationLayerData.FX)
{ {
if (this._addData && this._addData.length) if(this._addData && this._addData.length)
{ {
for (const addData of this._addData) for(const addData of this._addData)
{ {
if (((addData.align === spriteId) && (addData.id === layer.id))) return layer; if(((addData.align === spriteId) && (addData.id === layer.id))) return layer;
} }
} }
} }
@ -258,11 +258,11 @@ export class Animation implements IAnimation
public getAddData(k: string): AddDataContainer public getAddData(k: string): AddDataContainer
{ {
if (this._addData) if(this._addData)
{ {
for (const _local_2 of this._addData) for(const _local_2 of this._addData)
{ {
if (_local_2.id === k) return _local_2; if(_local_2.id === k) return _local_2;
} }
} }

View File

@ -26,7 +26,7 @@ export class AnimationManager implements IAnimationManager
{ {
const existing = this._animations.get(animation); const existing = this._animations.get(animation);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
@ -35,7 +35,7 @@ export class AnimationManager implements IAnimationManager
{ {
const existing = this.getAnimation(animation); const existing = this.getAnimation(animation);
if (!existing) return null; if(!existing) return null;
return existing.getLayerData(frameCount, spriteId); return existing.getLayerData(frameCount, spriteId);
} }

View File

@ -29,13 +29,13 @@ export class AvatarAnimationLayerData implements IAnimationLayerData
this._base = (k.base || ''); this._base = (k.base || '');
this._items = new Map(); this._items = new Map();
if (k.items) for (const _local_4 of k.items) this._items.set(_local_4.id, _local_4.base); if(k.items) for(const _local_4 of k.items) this._items.set(_local_4.id, _local_4.base);
let _local_5 = ''; let _local_5 = '';
if (this._base !== '') _local_5 = this.baseAsInt().toString(); if(this._base !== '') _local_5 = this.baseAsInt().toString();
if (_arg_3) if(_arg_3)
{ {
this._action = new ActiveActionData(_arg_3.state, this.base); this._action = new ActiveActionData(_arg_3.state, this.base);
this._action.definition = _arg_3; this._action.definition = _arg_3;
@ -52,7 +52,7 @@ export class AvatarAnimationLayerData implements IAnimationLayerData
let k = 0; let k = 0;
let index = 0; let index = 0;
while (index < this._base.length) while(index < this._base.length)
{ {
k = (k + this._base.charCodeAt(index)); k = (k + this._base.charCodeAt(index));

View File

@ -41,7 +41,7 @@ export class AvatarDataContainer implements IAvatarDataContainer
this._alphaMultiplier = 1; this._alphaMultiplier = 1;
this._paletteIsGrayscale = true; this._paletteIsGrayscale = true;
if (this._ink === 37) if(this._ink === 37)
{ {
this._alphaMultiplier = 0.5; this._alphaMultiplier = 0.5;
this._paletteIsGrayscale = false; this._paletteIsGrayscale = false;
@ -110,9 +110,9 @@ export class AvatarDataContainer implements IAvatarDataContainer
let _local_22 = greenBackground; let _local_22 = greenBackground;
let _local_23 = blueBackground; let _local_23 = blueBackground;
for (let i = 0; i < 256; i++) for(let i = 0; i < 256; i++)
{ {
if ((((_local_21 == redBackground) && (_local_22 == greenBackground)) && (_local_23 == blueBackground))) if((((_local_21 == redBackground) && (_local_22 == greenBackground)) && (_local_23 == blueBackground)))
{ {
_local_20 = 0; _local_20 = 0;
} }

View File

@ -26,13 +26,13 @@ export class SpriteDataContainer implements ISpriteDataContainer
const directions = _arg_2.directionList; const directions = _arg_2.directionList;
if (directions && directions.length) if(directions && directions.length)
{ {
for (const direction of directions) for(const direction of directions)
{ {
const id = direction.id; const id = direction.id;
if (id === undefined) continue; if(id === undefined) continue;
this._dx[id] = (direction.dx || 0); this._dx[id] = (direction.dx || 0);
this._dy[id] = (direction.dy || 0); this._dy[id] = (direction.dy || 0);
@ -43,21 +43,21 @@ export class SpriteDataContainer implements ISpriteDataContainer
public getDirectionOffsetX(k: number): number public getDirectionOffsetX(k: number): number
{ {
if (k < this._dx.length) return this._dx[k]; if(k < this._dx.length) return this._dx[k];
return 0; return 0;
} }
public getDirectionOffsetY(k: number): number public getDirectionOffsetY(k: number): number
{ {
if (k < this._dy.length) return this._dy[k]; if(k < this._dy.length) return this._dy[k];
return 0; return 0;
} }
public getDirectionOffsetZ(k: number): number public getDirectionOffsetZ(k: number): number
{ {
if (k < this._dz.length) return this._dz[k]; if(k < this._dz.length) return this._dz[k];
return 0; return 0;
} }

View File

@ -17,11 +17,11 @@ export class AvatarImageActionCache
{ {
this.debugInfo('[dispose]'); this.debugInfo('[dispose]');
if (!this._cache) return; if(!this._cache) return;
for (const direction of this._cache.values()) for(const direction of this._cache.values())
{ {
if (direction) direction.dispose(); if(direction) direction.dispose();
} }
this._cache.clear(); this._cache.clear();
@ -31,7 +31,7 @@ export class AvatarImageActionCache
{ {
const existing = this._cache.get(k.toString()); const existing = this._cache.get(k.toString());
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }

View File

@ -15,20 +15,20 @@ export class AvatarImageBodyPartCache
public setAction(k: IActiveActionData, _arg_2: number): void public setAction(k: IActiveActionData, _arg_2: number): void
{ {
if (!this._currentAction) this._currentAction = k; if(!this._currentAction) this._currentAction = k;
const _local_3 = this.getActionCache(this._currentAction); const _local_3 = this.getActionCache(this._currentAction);
if (_local_3) _local_3.setLastAccessTime(_arg_2); if(_local_3) _local_3.setLastAccessTime(_arg_2);
this._currentAction = k; this._currentAction = k;
} }
public dispose(): void public dispose(): void
{ {
if (!this._disposed) if(!this._disposed)
{ {
if (!this._cache) return; if(!this._cache) return;
this.disposeActions(0, 2147483647); this.disposeActions(0, 2147483647);
@ -41,15 +41,15 @@ export class AvatarImageBodyPartCache
public disposeActions(k: number, _arg_2: number): void public disposeActions(k: number, _arg_2: number): void
{ {
if (!this._cache || this._disposed) return; if(!this._cache || this._disposed) return;
for (const [key, cache] of this._cache.entries()) for(const [key, cache] of this._cache.entries())
{ {
if (!cache) continue; if(!cache) continue;
const _local_3 = cache.getLastAccessTime(); const _local_3 = cache.getLastAccessTime();
if ((_arg_2 - _local_3) >= k) if((_arg_2 - _local_3) >= k)
{ {
cache.dispose(); cache.dispose();
@ -75,18 +75,18 @@ export class AvatarImageBodyPartCache
public getActionCache(k: IActiveActionData = null): AvatarImageActionCache public getActionCache(k: IActiveActionData = null): AvatarImageActionCache
{ {
if (!this._currentAction) return null; if(!this._currentAction) return null;
if (!k) k = this._currentAction; if(!k) k = this._currentAction;
if (k.overridingAction) return this._cache.get(k.overridingAction); if(k.overridingAction) return this._cache.get(k.overridingAction);
return this._cache.get(k.id); return this._cache.get(k.id);
} }
public updateActionCache(k: IActiveActionData, _arg_2: AvatarImageActionCache): void public updateActionCache(k: IActiveActionData, _arg_2: AvatarImageActionCache): void
{ {
if (k.overridingAction) this._cache.set(k.overridingAction, _arg_2); if(k.overridingAction) this._cache.set(k.overridingAction, _arg_2);
else this._cache.set(k.id, _arg_2); else this._cache.set(k.id, _arg_2);
} }

View File

@ -45,7 +45,7 @@ export class AvatarImageCache
public dispose(): void public dispose(): void
{ {
if (this._disposed) return; if(this._disposed) return;
this._structure = null; this._structure = null;
this._avatar = null; this._avatar = null;
@ -53,11 +53,11 @@ export class AvatarImageCache
this._canvas = null; this._canvas = null;
this._disposed = true; this._disposed = true;
if (this._cache) if(this._cache)
{ {
for (const cache of this._cache.values()) for(const cache of this._cache.values())
{ {
if (!cache) continue; if(!cache) continue;
cache.dispose(); cache.dispose();
} }
@ -65,11 +65,11 @@ export class AvatarImageCache
this._cache = null; this._cache = null;
} }
if (this._unionImages) if(this._unionImages)
{ {
for (const image of this._unionImages) for(const image of this._unionImages)
{ {
if (!image) continue; if(!image) continue;
image.dispose(); image.dispose();
} }
@ -82,11 +82,11 @@ export class AvatarImageCache
{ {
const time = GetTickerTime(); const time = GetTickerTime();
if (this._cache) if(this._cache)
{ {
for (const cache of this._cache.values()) for(const cache of this._cache.values())
{ {
if (!cache) continue; if(!cache) continue;
cache.disposeActions(k, time); cache.disposeActions(k, time);
} }
@ -95,11 +95,11 @@ export class AvatarImageCache
public resetBodyPartCache(k: IActiveActionData): void public resetBodyPartCache(k: IActiveActionData): void
{ {
if (this._cache) if(this._cache)
{ {
for (const cache of this._cache.values()) for(const cache of this._cache.values())
{ {
if (!cache) continue; if(!cache) continue;
cache.setAction(k, 0); cache.setAction(k, 0);
} }
@ -110,13 +110,13 @@ export class AvatarImageCache
{ {
const parts = this._structure.getBodyPartsUnordered(k); const parts = this._structure.getBodyPartsUnordered(k);
if (parts) if(parts)
{ {
for (const part of parts) for(const part of parts)
{ {
const actionCache = this.getBodyPartCache(part); const actionCache = this.getBodyPartCache(part);
if (!actionCache) continue; if(!actionCache) continue;
actionCache.setDirection(_arg_2); actionCache.setDirection(_arg_2);
} }
@ -127,19 +127,19 @@ export class AvatarImageCache
{ {
const _local_3 = this._structure.getActiveBodyPartIds(k, this._avatar); const _local_3 = this._structure.getActiveBodyPartIds(k, this._avatar);
for (const _local_4 of _local_3) for(const _local_4 of _local_3)
{ {
const _local_5 = this.getBodyPartCache(_local_4); const _local_5 = this.getBodyPartCache(_local_4);
if (_local_5) _local_5.setAction(k, _arg_2); if(_local_5) _local_5.setAction(k, _arg_2);
} }
} }
public setGeometryType(k: string): void public setGeometryType(k: string): void
{ {
if (this._geometryType === k) return; if(this._geometryType === k) return;
if ((((this._geometryType === GeometryType.SITTING) && (k === GeometryType.VERTICAL)) || ((this._geometryType === GeometryType.VERTICAL) && (k === GeometryType.SITTING)) || ((this._geometryType === GeometryType.SNOWWARS_HORIZONTAL) && (k = GeometryType.SNOWWARS_HORIZONTAL)))) if((((this._geometryType === GeometryType.SITTING) && (k === GeometryType.VERTICAL)) || ((this._geometryType === GeometryType.VERTICAL) && (k === GeometryType.SITTING)) || ((this._geometryType === GeometryType.SNOWWARS_HORIZONTAL) && (k = GeometryType.SNOWWARS_HORIZONTAL))))
{ {
this._geometryType = k; this._geometryType = k;
this._canvas = null; this._canvas = null;
@ -157,7 +157,7 @@ export class AvatarImageCache
{ {
let _local_4 = this.getBodyPartCache(k); let _local_4 = this.getBodyPartCache(k);
if (!_local_4) if(!_local_4)
{ {
_local_4 = new AvatarImageBodyPartCache(); _local_4 = new AvatarImageBodyPartCache();
@ -168,48 +168,48 @@ export class AvatarImageCache
let _local_7 = _local_4.getAction(); let _local_7 = _local_4.getAction();
let frameCount = frameNumber; let frameCount = frameNumber;
if (_local_7.definition.startFromFrameZero) frameCount -= _local_7.startFrame; if(_local_7.definition.startFromFrameZero) frameCount -= _local_7.startFrame;
let _local_8 = _local_7; let _local_8 = _local_7;
let _local_9: string[] = []; let _local_9: string[] = [];
let _local_10: Map<string, string> = new Map(); let _local_10: Map<string, string> = new Map();
const _local_11 = new Point(); const _local_11 = new Point();
if (!((!(_local_7)) || (!(_local_7.definition)))) if(!((!(_local_7)) || (!(_local_7.definition))))
{ {
if (_local_7.definition.isAnimation) if(_local_7.definition.isAnimation)
{ {
let _local_15 = _local_5; let _local_15 = _local_5;
const _local_16 = this._structure.getAnimation(((_local_7.definition.state + '.') + _local_7.actionParameter)); const _local_16 = this._structure.getAnimation(((_local_7.definition.state + '.') + _local_7.actionParameter));
const _local_17 = (frameNumber - _local_7.startFrame); const _local_17 = (frameNumber - _local_7.startFrame);
if (_local_16) if(_local_16)
{ {
const _local_18 = _local_16.getLayerData(_local_17, k, _local_7.overridingAction); const _local_18 = _local_16.getLayerData(_local_17, k, _local_7.overridingAction);
if (_local_18) if(_local_18)
{ {
_local_15 = (_local_5 + _local_18.dd); _local_15 = (_local_5 + _local_18.dd);
if (_local_18.dd < 0) if(_local_18.dd < 0)
{ {
if (_local_15 < 0) if(_local_15 < 0)
{ {
_local_15 = (8 + _local_15); _local_15 = (8 + _local_15);
} }
else if (_local_15 > 7) _local_15 = (8 - _local_15); else if(_local_15 > 7) _local_15 = (8 - _local_15);
} }
else else
{ {
if (_local_15 < 0) if(_local_15 < 0)
{ {
_local_15 = (_local_15 + 8); _local_15 = (_local_15 + 8);
} }
else if (_local_15 > 7) _local_15 = (_local_15 - 8); else if(_local_15 > 7) _local_15 = (_local_15 - 8);
} }
if (this._scale === AvatarScaleType.LARGE) if(this._scale === AvatarScaleType.LARGE)
{ {
_local_11.x = _local_18.dx; _local_11.x = _local_18.dx;
_local_11.y = _local_18.dy; _local_11.y = _local_18.dy;
@ -222,21 +222,21 @@ export class AvatarImageCache
frameCount = _local_18.animationFrame; frameCount = _local_18.animationFrame;
if (_local_18.action) if(_local_18.action)
{ {
_local_7 = _local_18.action; _local_7 = _local_18.action;
} }
if (_local_18.type === AvatarAnimationLayerData.BODYPART) if(_local_18.type === AvatarAnimationLayerData.BODYPART)
{ {
if (_local_18.action != null) if(_local_18.action != null)
{ {
_local_8 = _local_18.action; _local_8 = _local_18.action;
} }
_local_5 = _local_15; _local_5 = _local_15;
} }
else if (_local_18.type === AvatarAnimationLayerData.FX) _local_5 = _local_15; else if(_local_18.type === AvatarAnimationLayerData.FX) _local_5 = _local_15;
_local_10 = _local_18.items; _local_10 = _local_18.items;
} }
@ -248,7 +248,7 @@ export class AvatarImageCache
let _local_12 = _local_4.getActionCache(_local_8); let _local_12 = _local_4.getActionCache(_local_8);
if (!_local_12 || _arg_3) if(!_local_12 || _arg_3)
{ {
_local_12 = new AvatarImageActionCache(); _local_12 = new AvatarImageActionCache();
_local_4.updateActionCache(_local_8, _local_12); _local_4.updateActionCache(_local_8, _local_12);
@ -256,7 +256,7 @@ export class AvatarImageCache
let _local_13 = _local_12.getDirectionCache(_local_5); let _local_13 = _local_12.getDirectionCache(_local_5);
if (!_local_13 || _arg_3) if(!_local_13 || _arg_3)
{ {
const _local_19 = this._structure.getParts(k, this._avatar.getFigure(), _local_8, this._geometryType, _local_5, _local_9, this._avatar, _local_10); const _local_19 = this._structure.getParts(k, this._avatar.getFigure(), _local_8, this._geometryType, _local_5, _local_9, this._avatar, _local_10);
@ -267,15 +267,15 @@ export class AvatarImageCache
let _local_14 = _local_13.getImageContainer(frameCount); let _local_14 = _local_13.getImageContainer(frameCount);
if (!_local_14 || _arg_3) if(!_local_14 || _arg_3)
{ {
const _local_20 = _local_13.getPartList(); const _local_20 = _local_13.getPartList();
_local_14 = this.renderBodyPart(_local_5, _local_20, frameCount, _local_7, _arg_3); _local_14 = this.renderBodyPart(_local_5, _local_20, frameCount, _local_7, _arg_3);
if (_local_14 && !_arg_3) if(_local_14 && !_arg_3)
{ {
if (_local_14.isCacheable) _local_13.updateImageContainer(_local_14, frameCount); if(_local_14.isCacheable) _local_13.updateImageContainer(_local_14, frameCount);
} }
else else
{ {
@ -304,7 +304,7 @@ export class AvatarImageCache
{ {
let existing = this._cache.get(k); let existing = this._cache.get(k);
if (!existing) if(!existing)
{ {
existing = new AvatarImageBodyPartCache(); existing = new AvatarImageBodyPartCache();
@ -316,13 +316,13 @@ export class AvatarImageCache
private renderBodyPart(direction: number, containers: AvatarImagePartContainer[], frameCount: number, _arg_4: IActiveActionData, renderServerData: boolean = false): AvatarImageBodyPartContainer private renderBodyPart(direction: number, containers: AvatarImagePartContainer[], frameCount: number, _arg_4: IActiveActionData, renderServerData: boolean = false): AvatarImageBodyPartContainer
{ {
if (!containers || !containers.length) return null; if(!containers || !containers.length) return null;
if (!this._canvas) if(!this._canvas)
{ {
this._canvas = this._structure.getCanvas(this._scale, this._geometryType); this._canvas = this._structure.getCanvas(this._scale, this._geometryType);
if (!this._canvas) return null; if(!this._canvas) return null;
} }
const isFlipped = AvatarDirectionAngle.DIRECTION_IS_FLIPPED[direction] || false; const isFlipped = AvatarDirectionAngle.DIRECTION_IS_FLIPPED[direction] || false;
@ -330,15 +330,15 @@ export class AvatarImageCache
let isCacheable = true; let isCacheable = true;
let containerIndex = (containers.length - 1); let containerIndex = (containers.length - 1);
while (containerIndex >= 0) while(containerIndex >= 0)
{ {
const container = containers[containerIndex]; const container = containers[containerIndex];
let color = 16777215; let color = 16777215;
if (!((direction == 7) && ((container.partType === 'fc') || (container.partType === 'ey')))) if(!((direction == 7) && ((container.partType === 'fc') || (container.partType === 'ey'))))
{ {
if (!((container.partType === 'ri') && !container.partId)) if(!((container.partType === 'ri') && !container.partId))
{ {
const partId = container.partId; const partId = container.partId;
const animationFrame = container.getFrameDefinition(frameCount); const animationFrame = container.getFrameDefinition(frameCount);
@ -346,59 +346,59 @@ export class AvatarImageCache
let partType = container.partType; let partType = container.partType;
let frameNumber = 0; let frameNumber = 0;
if (animationFrame) if(animationFrame)
{ {
frameNumber = animationFrame.number; frameNumber = animationFrame.number;
if ((animationFrame.assetPartDefinition) && (animationFrame.assetPartDefinition !== '')) assetPartDefinition = animationFrame.assetPartDefinition; if((animationFrame.assetPartDefinition) && (animationFrame.assetPartDefinition !== '')) assetPartDefinition = animationFrame.assetPartDefinition;
} }
else frameNumber = container.getFrameIndex(frameCount); else frameNumber = container.getFrameIndex(frameCount);
let assetDirection = direction; let assetDirection = direction;
let flipH = false; let flipH = false;
if (isFlipped) if(isFlipped)
{ {
if (((assetPartDefinition === 'wav') && (((partType === AvatarFigurePartType.LEFT_HAND) || (partType === AvatarFigurePartType.LEFT_SLEEVE)) || (partType === AvatarFigurePartType.LEFT_COAT_SLEEVE))) || ((assetPartDefinition === 'drk') && (((partType === AvatarFigurePartType.RIGHT_HAND) || (partType === AvatarFigurePartType.RIGHT_SLEEVE)) || (partType === AvatarFigurePartType.RIGHT_COAT_SLEEVE))) || ((assetPartDefinition === 'blw') && (partType === AvatarFigurePartType.RIGHT_HAND)) || ((assetPartDefinition === 'sig') && (partType === AvatarFigurePartType.LEFT_HAND)) || ((assetPartDefinition === 'respect') && (partType === AvatarFigurePartType.LEFT_HAND)) || (partType === AvatarFigurePartType.RIGHT_HAND_ITEM) || (partType === AvatarFigurePartType.LEFT_HAND_ITEM) || (partType === AvatarFigurePartType.CHEST_PRINT)) if(((assetPartDefinition === 'wav') && (((partType === AvatarFigurePartType.LEFT_HAND) || (partType === AvatarFigurePartType.LEFT_SLEEVE)) || (partType === AvatarFigurePartType.LEFT_COAT_SLEEVE))) || ((assetPartDefinition === 'drk') && (((partType === AvatarFigurePartType.RIGHT_HAND) || (partType === AvatarFigurePartType.RIGHT_SLEEVE)) || (partType === AvatarFigurePartType.RIGHT_COAT_SLEEVE))) || ((assetPartDefinition === 'blw') && (partType === AvatarFigurePartType.RIGHT_HAND)) || ((assetPartDefinition === 'sig') && (partType === AvatarFigurePartType.LEFT_HAND)) || ((assetPartDefinition === 'respect') && (partType === AvatarFigurePartType.LEFT_HAND)) || (partType === AvatarFigurePartType.RIGHT_HAND_ITEM) || (partType === AvatarFigurePartType.LEFT_HAND_ITEM) || (partType === AvatarFigurePartType.CHEST_PRINT))
{ {
flipH = true; flipH = true;
} }
else else
{ {
if (direction === 4) assetDirection = 2; if(direction === 4) assetDirection = 2;
else if (direction === 5) assetDirection = 1; else if(direction === 5) assetDirection = 1;
else if (direction === 6) assetDirection = 0; else if(direction === 6) assetDirection = 0;
if (container.flippedPartType !== partType) partType = container.flippedPartType; if(container.flippedPartType !== partType) partType = container.flippedPartType;
} }
} }
let assetName = (this._scale + '_' + assetPartDefinition + '_' + partType + '_' + partId + '_' + assetDirection + '_' + frameNumber); let assetName = (this._scale + '_' + assetPartDefinition + '_' + partType + '_' + partId + '_' + assetDirection + '_' + frameNumber);
let asset = this._assets.getAsset(assetName); let asset = this._assets.getAsset(assetName);
if (!asset) if(!asset)
{ {
assetName = (this._scale + '_std_' + partType + '_' + partId + '_' + assetDirection + '_0'); assetName = (this._scale + '_std_' + partType + '_' + partId + '_' + assetDirection + '_0');
asset = this._assets.getAsset(assetName); asset = this._assets.getAsset(assetName);
} }
if (asset) if(asset)
{ {
const texture = asset.texture; const texture = asset.texture;
if (!texture || !texture.valid || !texture.baseTexture) if(!texture || !texture.valid || !texture.baseTexture)
{ {
isCacheable = false; isCacheable = false;
} }
else else
{ {
if (container.isColorable && container.color) color = container.color.rgb; if(container.isColorable && container.color) color = container.color.rgb;
const offset = new Point(-(asset.x), -(asset.y)); const offset = new Point(-(asset.x), -(asset.y));
if (flipH) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 65 : 31)); if(flipH) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 65 : 31));
if (renderServerData) if(renderServerData)
{ {
const spriteData = new RoomObjectSpriteData(); const spriteData = new RoomObjectSpriteData();
@ -410,17 +410,17 @@ export class AvatarImageCache
spriteData.height = asset.rectangle.height; spriteData.height = asset.rectangle.height;
spriteData.flipH = flipH; spriteData.flipH = flipH;
if (assetPartDefinition === 'lay') spriteData.x = (spriteData.x + 53); if(assetPartDefinition === 'lay') spriteData.x = (spriteData.x + 53);
if (isFlipped) if(isFlipped)
{ {
spriteData.flipH = (!(spriteData.flipH)); spriteData.flipH = (!(spriteData.flipH));
if (spriteData.flipH) spriteData.x = (-(spriteData.x) - texture.width); if(spriteData.flipH) spriteData.x = (-(spriteData.x) - texture.width);
else spriteData.x = (spriteData.x + 65); else spriteData.x = (spriteData.x + 65);
} }
if (container.isColorable) spriteData.color = `${color}`; if(container.isColorable) spriteData.color = `${color}`;
this._serverRenderData.push(spriteData); this._serverRenderData.push(spriteData);
} }
@ -434,21 +434,21 @@ export class AvatarImageCache
containerIndex--; containerIndex--;
} }
if (!this._unionImages.length) return null; if(!this._unionImages.length) return null;
const imageData = this.createUnionImage(this._unionImages, isFlipped); const imageData = this.createUnionImage(this._unionImages, isFlipped);
const canvasOffset = ((this._scale === AvatarScaleType.LARGE) ? (this._canvas.height - 16) : (this._canvas.height - 8)); const canvasOffset = ((this._scale === AvatarScaleType.LARGE) ? (this._canvas.height - 16) : (this._canvas.height - 8));
const offset = new Point(-(imageData.regPoint.x), (canvasOffset - imageData.regPoint.y)); const offset = new Point(-(imageData.regPoint.x), (canvasOffset - imageData.regPoint.y));
if (isFlipped && (assetPartDefinition !== 'lay')) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 67 : 31)); if(isFlipped && (assetPartDefinition !== 'lay')) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 67 : 31));
let imageIndex = (this._unionImages.length - 1); let imageIndex = (this._unionImages.length - 1);
while (imageIndex >= 0) while(imageIndex >= 0)
{ {
const _local_17 = this._unionImages.pop(); const _local_17 = this._unionImages.pop();
if (_local_17) _local_17.dispose(); if(_local_17) _local_17.dispose();
imageIndex--; imageIndex--;
} }
@ -459,7 +459,7 @@ export class AvatarImageCache
private convertColorToHex(k: number): string private convertColorToHex(k: number): string
{ {
let _local_2: string = (k * 0xFF).toString(16); let _local_2: string = (k * 0xFF).toString(16);
if (_local_2.length < 2) if(_local_2.length < 2)
{ {
_local_2 = ('0' + _local_2); _local_2 = ('0' + _local_2);
} }
@ -470,7 +470,7 @@ export class AvatarImageCache
{ {
const bounds = new Rectangle(); const bounds = new Rectangle();
for (const data of k) data && bounds.enlarge(data.offsetRect); for(const data of k) data && bounds.enlarge(data.offsetRect);
const point = new Point(-(bounds.x), -(bounds.y)); const point = new Point(-(bounds.x), -(bounds.y));
const container = new NitroContainer(); const container = new NitroContainer();
@ -482,9 +482,9 @@ export class AvatarImageCache
container.addChild(sprite); container.addChild(sprite);
for (const data of k) for(const data of k)
{ {
if (!data) continue; if(!data) continue;
const texture = data.texture; const texture = data.texture;
const color = data.colorTransform; const color = data.colorTransform;
@ -494,9 +494,9 @@ export class AvatarImageCache
regPoint.x -= data.regPoint.x; regPoint.x -= data.regPoint.x;
regPoint.y -= data.regPoint.y; regPoint.y -= data.regPoint.y;
if (isFlipped) regPoint.x = (container.width - (regPoint.x + data.rect.width)); if(isFlipped) regPoint.x = (container.width - (regPoint.x + data.rect.width));
if (flipH) if(flipH)
{ {
this._matrix.a = -1; this._matrix.a = -1;
this._matrix.tx = ((data.rect.x + data.rect.width) + regPoint.x); this._matrix.tx = ((data.rect.x + data.rect.width) + regPoint.x);

View File

@ -25,27 +25,27 @@ export class AvatarModelGeometry
const camera = k.camera; const camera = k.camera;
if (camera) if(camera)
{ {
this._camera.x = parseFloat(camera.x); this._camera.x = parseFloat(camera.x);
this._camera.y = parseFloat(camera.y); this._camera.y = parseFloat(camera.y);
this._camera.z = parseFloat(camera.z); this._camera.z = parseFloat(camera.z);
} }
if (k.canvases && (k.canvases.length > 0)) if(k.canvases && (k.canvases.length > 0))
{ {
for (const canvas of k.canvases) for(const canvas of k.canvases)
{ {
if (!canvas) continue; if(!canvas) continue;
const scale = canvas.scale; const scale = canvas.scale;
const geometries = new Map(); const geometries = new Map();
if (canvas.geometries && (canvas.geometries.length > 0)) if(canvas.geometries && (canvas.geometries.length > 0))
{ {
for (const geometry of canvas.geometries) for(const geometry of canvas.geometries)
{ {
if (!geometry) continue; if(!geometry) continue;
const avatarCanvas = new AvatarCanvas(geometry, scale); const avatarCanvas = new AvatarCanvas(geometry, scale);
@ -57,26 +57,26 @@ export class AvatarModelGeometry
} }
} }
if (k.types && (k.types.length > 0)) if(k.types && (k.types.length > 0))
{ {
for (const type of k.types) for(const type of k.types)
{ {
if (!type) continue; if(!type) continue;
const bodyParts: Map<string, GeometryBodyPart> = new Map(); const bodyParts: Map<string, GeometryBodyPart> = new Map();
const itemIds: Map<string, GeometryBodyPart> = new Map(); const itemIds: Map<string, GeometryBodyPart> = new Map();
if (type.bodyParts && (type.bodyParts.length > 0)) if(type.bodyParts && (type.bodyParts.length > 0))
{ {
for (const bodyPart of type.bodyParts) for(const bodyPart of type.bodyParts)
{ {
if (!bodyPart) continue; if(!bodyPart) continue;
const geometryBodyPart = new GeometryBodyPart(bodyPart); const geometryBodyPart = new GeometryBodyPart(bodyPart);
bodyParts.set(geometryBodyPart.id, geometryBodyPart); bodyParts.set(geometryBodyPart.id, geometryBodyPart);
for (const part of geometryBodyPart.getPartIds(null)) for(const part of geometryBodyPart.getPartIds(null))
{ {
itemIds.set(part, geometryBodyPart); itemIds.set(part, geometryBodyPart);
} }
@ -91,13 +91,13 @@ export class AvatarModelGeometry
public removeDynamicItems(k: IAvatarImage): void public removeDynamicItems(k: IAvatarImage): void
{ {
for (const geometry of this._geometryTypes.values()) for(const geometry of this._geometryTypes.values())
{ {
if (!geometry) continue; if(!geometry) continue;
for (const part of geometry.values()) for(const part of geometry.values())
{ {
if (!part) continue; if(!part) continue;
part.removeDynamicParts(k); part.removeDynamicParts(k);
} }
@ -108,7 +108,7 @@ export class AvatarModelGeometry
{ {
const avatarSet = this._avatarSet.findAvatarSet(k); const avatarSet = this._avatarSet.findAvatarSet(k);
if (!avatarSet) return []; if(!avatarSet) return [];
return avatarSet.getBodyParts(); return avatarSet.getBodyParts();
} }
@ -117,7 +117,7 @@ export class AvatarModelGeometry
{ {
const avatarSet = this._avatarSet.findAvatarSet(k); const avatarSet = this._avatarSet.findAvatarSet(k);
if (!avatarSet) return false; if(!avatarSet) return false;
return avatarSet.isMain; return avatarSet.isMain;
} }
@ -126,7 +126,7 @@ export class AvatarModelGeometry
{ {
const canvas = this._canvases.get(k); const canvas = this._canvases.get(k);
if (!canvas) return null; if(!canvas) return null;
return (canvas.get(_arg_2) || null); return (canvas.get(_arg_2) || null);
} }
@ -135,18 +135,18 @@ export class AvatarModelGeometry
{ {
const existing = this._geometryTypes.get(k); const existing = this._geometryTypes.get(k);
if (existing) return true; if(existing) return true;
return false; return false;
} }
private hasBodyPart(k: string, _arg_2: string): boolean private hasBodyPart(k: string, _arg_2: string): boolean
{ {
if (this.typeExists(k)) if(this.typeExists(k))
{ {
const existing = this._geometryTypes.get(k); const existing = this._geometryTypes.get(k);
if (existing && existing.get(_arg_2)) return true; if(existing && existing.get(_arg_2)) return true;
} }
return false; return false;
@ -158,11 +158,11 @@ export class AvatarModelGeometry
const types = []; const types = [];
if (parts) if(parts)
{ {
for (const part of parts.values()) for(const part of parts.values())
{ {
if (!part) continue; if(!part) continue;
types.push(part.id); types.push(part.id);
} }
@ -173,7 +173,7 @@ export class AvatarModelGeometry
private getBodyPartsOfType(k: string): Map<string, GeometryBodyPart> private getBodyPartsOfType(k: string): Map<string, GeometryBodyPart>
{ {
if (this.typeExists(k)) return this._geometryTypes.get(k); if(this.typeExists(k)) return this._geometryTypes.get(k);
return new Map(); return new Map();
} }
@ -187,21 +187,21 @@ export class AvatarModelGeometry
{ {
const itemIds = this._itemIdToBodyPartMap.get(k); const itemIds = this._itemIdToBodyPartMap.get(k);
if (itemIds) if(itemIds)
{ {
const part = itemIds.get(_arg_2); const part = itemIds.get(_arg_2);
if (part) return part; if(part) return part;
const parts = this.getBodyPartsOfType(k); const parts = this.getBodyPartsOfType(k);
if (parts) if(parts)
{ {
for (const part of parts.values()) for(const part of parts.values())
{ {
if (!part) continue; if(!part) continue;
if (part.hasPart(_arg_2, _arg_3)) return part; if(part.hasPart(_arg_2, _arg_3)) return part;
} }
} }
} }
@ -214,13 +214,13 @@ export class AvatarModelGeometry
const parts = this.getBodyPartIdsInAvatarSet(_arg_2); const parts = this.getBodyPartIdsInAvatarSet(_arg_2);
const geometryParts = []; const geometryParts = [];
for (const part of parts) for(const part of parts)
{ {
if (!part) continue; if(!part) continue;
const bodyPart = k.get(part); const bodyPart = k.get(part);
if (bodyPart) if(bodyPart)
{ {
geometryParts.push(bodyPart); geometryParts.push(bodyPart);
} }
@ -231,7 +231,7 @@ export class AvatarModelGeometry
public getBodyPartsAtAngle(k: string, _arg_2: number, _arg_3: string): string[] public getBodyPartsAtAngle(k: string, _arg_2: number, _arg_3: string): string[]
{ {
if (!_arg_3) return []; if(!_arg_3) return [];
const geometryParts = this.getBodyPartsOfType(_arg_3); const geometryParts = this.getBodyPartsOfType(_arg_3);
const parts = this.getBodyPartsInAvatarSet(geometryParts, k); const parts = this.getBodyPartsInAvatarSet(geometryParts, k);
@ -240,9 +240,9 @@ export class AvatarModelGeometry
this._transformation = Matrix4x4.getYRotationMatrix(_arg_2); this._transformation = Matrix4x4.getYRotationMatrix(_arg_2);
for (const part of parts.values()) for(const part of parts.values())
{ {
if (!part) continue; if(!part) continue;
part.applyTransform(this._transformation); part.applyTransform(this._transformation);
@ -254,16 +254,16 @@ export class AvatarModelGeometry
const partA = a[0]; const partA = a[0];
const partB = b[0]; const partB = b[0];
if (partA < partB) return -1; if(partA < partB) return -1;
if (partA > partB) return 1; if(partA > partB) return 1;
return 0; return 0;
}); });
for (const set of sets) for(const set of sets)
{ {
if (!set) continue; if(!set) continue;
ids.push(set[1].id); ids.push(set[1].id);
} }
@ -273,7 +273,7 @@ export class AvatarModelGeometry
public getParts(k: string, _arg_2: string, _arg_3: number, _arg_4: any[], _arg_5: IAvatarImage): string[] public getParts(k: string, _arg_2: string, _arg_3: number, _arg_4: any[], _arg_5: IAvatarImage): string[]
{ {
if (this.hasBodyPart(k, _arg_2)) if(this.hasBodyPart(k, _arg_2))
{ {
const part = this.getBodyPartsOfType(k).get(_arg_2); const part = this.getBodyPartsOfType(k).get(_arg_2);

View File

@ -20,11 +20,11 @@ export class GeometryBodyPart extends Node3D
this._parts = new Map(); this._parts = new Map();
this._dynamicParts = new Map(); this._dynamicParts = new Map();
if (k.items && (k.items.length > 0)) if(k.items && (k.items.length > 0))
{ {
for (const item of k.items) for(const item of k.items)
{ {
if (!item) continue; if(!item) continue;
const geometryItem = new GeometryItem(item); const geometryItem = new GeometryItem(item);
@ -38,13 +38,13 @@ export class GeometryBodyPart extends Node3D
const existing = this._dynamicParts.get(k); const existing = this._dynamicParts.get(k);
const parts: GeometryItem[] = []; const parts: GeometryItem[] = [];
if (existing) if(existing)
{ {
for (const index in existing) for(const index in existing)
{ {
const item = existing[index]; const item = existing[index];
if (!item) continue; if(!item) continue;
parts.push(item); parts.push(item);
} }
@ -57,24 +57,24 @@ export class GeometryBodyPart extends Node3D
{ {
const ids: string[] = []; const ids: string[] = [];
for (const part of this._parts.values()) for(const part of this._parts.values())
{ {
if (!part) continue; if(!part) continue;
ids.push(part.id); ids.push(part.id);
} }
if (k) if(k)
{ {
const existing = this._dynamicParts.get(k); const existing = this._dynamicParts.get(k);
if (existing) if(existing)
{ {
for (const index in existing) for(const index in existing)
{ {
const part = existing[index]; const part = existing[index];
if (!part) continue; if(!part) continue;
ids.push(part.id); ids.push(part.id);
} }
@ -93,11 +93,11 @@ export class GeometryBodyPart extends Node3D
public addPart(k: any, _arg_2: IAvatarImage): boolean public addPart(k: any, _arg_2: IAvatarImage): boolean
{ {
if (this.hasPart(k.id, _arg_2)) return false; if(this.hasPart(k.id, _arg_2)) return false;
let existing = this._dynamicParts.get(_arg_2); let existing = this._dynamicParts.get(_arg_2);
if (!existing) if(!existing)
{ {
existing = {}; existing = {};
@ -113,7 +113,7 @@ export class GeometryBodyPart extends Node3D
{ {
let existingPart = (this._parts.get(k) || null); let existingPart = (this._parts.get(k) || null);
if (!existingPart && (this._dynamicParts.get(_arg_2) !== undefined)) if(!existingPart && (this._dynamicParts.get(_arg_2) !== undefined))
{ {
existingPart = (this._dynamicParts.get(_arg_2)[k] || null); existingPart = (this._dynamicParts.get(_arg_2)[k] || null);
} }
@ -125,9 +125,9 @@ export class GeometryBodyPart extends Node3D
{ {
const parts: [number, GeometryItem][] = []; const parts: [number, GeometryItem][] = [];
for (const part of this._parts.values()) for(const part of this._parts.values())
{ {
if (!part) continue; if(!part) continue;
part.applyTransform(k); part.applyTransform(k);
@ -136,13 +136,13 @@ export class GeometryBodyPart extends Node3D
const existingDynamic = this._dynamicParts.get(_arg_4); const existingDynamic = this._dynamicParts.get(_arg_4);
if (existingDynamic) if(existingDynamic)
{ {
for (const index in existingDynamic) for(const index in existingDynamic)
{ {
const part = existingDynamic[index]; const part = existingDynamic[index];
if (!part) continue; if(!part) continue;
part.applyTransform(k); part.applyTransform(k);
@ -155,18 +155,18 @@ export class GeometryBodyPart extends Node3D
const partA = a[0]; const partA = a[0];
const partB = b[0]; const partB = b[0];
if (partA < partB) return -1; if(partA < partB) return -1;
if (partA > partB) return 1; if(partA > partB) return 1;
return 0; return 0;
}); });
const partIds: string[] = []; const partIds: string[] = [];
for (const part of parts) for(const part of parts)
{ {
if (!part) continue; if(!part) continue;
partIds.push(part[1].id); partIds.push(part[1].id);
} }

View File

@ -12,11 +12,11 @@ export class AvatarAnimationData implements IFigureSetData
public parse(data: any): boolean public parse(data: any): boolean
{ {
if (data && (data.length > 0)) if(data && (data.length > 0))
{ {
for (const animation of data) for(const animation of data)
{ {
if (!animation) continue; if(!animation) continue;
const newAnimation = new AnimationAction(animation); const newAnimation = new AnimationAction(animation);
@ -29,7 +29,7 @@ export class AvatarAnimationData implements IFigureSetData
public appendJSON(k: any): boolean public appendJSON(k: any): boolean
{ {
for (const _local_2 of k.action) for(const _local_2 of k.action)
{ {
this._actions.set(_local_2.id, new AnimationAction(_local_2)); this._actions.set(_local_2.id, new AnimationAction(_local_2));
} }
@ -41,7 +41,7 @@ export class AvatarAnimationData implements IFigureSetData
{ {
const existing = this._actions.get(action.id); const existing = this._actions.get(action.id);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
@ -50,7 +50,7 @@ export class AvatarAnimationData implements IFigureSetData
{ {
const animationAction = this.getAction(k); const animationAction = this.getAction(k);
if (!animationAction) return 0; if(!animationAction) return 0;
return animationAction.frameCount; return animationAction.frameCount;
} }

View File

@ -16,7 +16,7 @@ export class AvatarCanvas
this._height = k.height; this._height = k.height;
this._offset = new Point(k.dx, k.dy); this._offset = new Point(k.dx, k.dy);
if (_arg_2 == AvatarScaleType.LARGE) this._regPoint = new Point(((this._width - 64) / 2), 0); if(_arg_2 == AvatarScaleType.LARGE) this._regPoint = new Point(((this._width - 64) / 2), 0);
else this._regPoint = new Point(((this._width - 32) / 2), 0); else this._regPoint = new Point(((this._width - 32) / 2), 0);
} }

View File

@ -31,9 +31,9 @@ export class AvatarStructureDownload extends EventDispatcher
{ {
const response = request.responseText; 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)); this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE));
}; };

View File

@ -19,22 +19,22 @@ export class FigureSetData implements IFigureSetData, IStructureData
public parse(data: IFigureData): boolean public parse(data: IFigureData): boolean
{ {
if (!data) return false; if(!data) return false;
for (const palette of data.palettes) for(const palette of data.palettes)
{ {
const newPalette = new Palette(palette); const newPalette = new Palette(palette);
if (!newPalette) continue; if(!newPalette) continue;
this._palettes.set(newPalette.id.toString(), newPalette); this._palettes.set(newPalette.id.toString(), newPalette);
} }
for (const set of data.setTypes) for(const set of data.setTypes)
{ {
const newSet = new SetType(set); const newSet = new SetType(set);
if (!newSet) continue; if(!newSet) continue;
this._setTypes.set(newSet.type, newSet); this._setTypes.set(newSet.type, newSet);
} }
@ -44,11 +44,11 @@ export class FigureSetData implements IFigureSetData, IStructureData
public injectJSON(data: IFigureData): void public injectJSON(data: IFigureData): void
{ {
for (const setType of data.setTypes) for(const setType of data.setTypes)
{ {
const existingSetType = this._setTypes.get(setType.type); const existingSetType = this._setTypes.get(setType.type);
if (existingSetType) existingSetType.cleanUp(setType); if(existingSetType) existingSetType.cleanUp(setType);
else this._setTypes.set(setType.type, new SetType(setType)); else this._setTypes.set(setType.type, new SetType(setType));
} }
@ -57,23 +57,23 @@ export class FigureSetData implements IFigureSetData, IStructureData
public appendJSON(data: IFigureData): boolean public appendJSON(data: IFigureData): boolean
{ {
if (!data) return false; if(!data) return false;
for (const palette of data.palettes) for(const palette of data.palettes)
{ {
const id = palette.id.toString(); const id = palette.id.toString();
const existingPalette = this._palettes.get(id); const existingPalette = this._palettes.get(id);
if (!existingPalette) this._palettes.set(id, new Palette(palette)); if(!existingPalette) this._palettes.set(id, new Palette(palette));
else existingPalette.append(palette); else existingPalette.append(palette);
} }
for (const setType of data.setTypes) for(const setType of data.setTypes)
{ {
const type = setType.type; const type = setType.type;
const existingSetType = this._setTypes.get(type); const existingSetType = this._setTypes.get(type);
if (!existingSetType) this._setTypes.set(type, new SetType(setType)); if(!existingSetType) this._setTypes.set(type, new SetType(setType));
else existingSetType.append(setType); else existingSetType.append(setType);
} }
@ -84,9 +84,9 @@ export class FigureSetData implements IFigureSetData, IStructureData
{ {
const types: string[] = []; const types: string[] = [];
for (const set of this._setTypes.values()) for(const set of this._setTypes.values())
{ {
if (!set || !set.isMandatory(k, _arg_2)) continue; if(!set || !set.isMandatory(k, _arg_2)) continue;
types.push(set.type); types.push(set.type);
} }
@ -98,7 +98,7 @@ export class FigureSetData implements IFigureSetData, IStructureData
{ {
const setType = this._setTypes.get(type); const setType = this._setTypes.get(type);
if (!setType) return null; if(!setType) return null;
return setType.getDefaultPartSet(gender); return setType.getDefaultPartSet(gender);
} }
@ -115,11 +115,11 @@ export class FigureSetData implements IFigureSetData, IStructureData
public getFigurePartSet(k: number): IFigurePartSet public getFigurePartSet(k: number): IFigurePartSet
{ {
for (const set of this._setTypes.values()) for(const set of this._setTypes.values())
{ {
const partSet = set.getPartSet(k); const partSet = set.getPartSet(k);
if (!partSet) continue; if(!partSet) continue;
return partSet; return partSet;
} }

View File

@ -15,21 +15,21 @@ export class PartSetsData implements IFigureSetData
public parse(data: any): boolean public parse(data: any): boolean
{ {
if (data.partSet && (data.partSet.length > 0)) if(data.partSet && (data.partSet.length > 0))
{ {
for (const part of data.partSet) for(const part of data.partSet)
{ {
if (!part) continue; if(!part) continue;
this._parts.set(part.setType, new PartDefinition(part)); this._parts.set(part.setType, new PartDefinition(part));
} }
} }
if (data.activePartSets && (data.activePartSets.length > 0)) if(data.activePartSets && (data.activePartSets.length > 0))
{ {
for (const activePart of data.activePartSets) for(const activePart of data.activePartSets)
{ {
if (!activePart) continue; if(!activePart) continue;
this._activePartSets.set(activePart.id, new ActivePartSet(activePart)); this._activePartSets.set(activePart.id, new ActivePartSet(activePart));
} }
@ -40,21 +40,21 @@ export class PartSetsData implements IFigureSetData
public appendJSON(data: any): boolean public appendJSON(data: any): boolean
{ {
if (data.partSet && (data.partSet.length > 0)) if(data.partSet && (data.partSet.length > 0))
{ {
for (const part of data.partSet) for(const part of data.partSet)
{ {
if (!part) continue; if(!part) continue;
this._parts.set(part.setType, new PartDefinition(part)); this._parts.set(part.setType, new PartDefinition(part));
} }
} }
if (data.activePartSets && (data.activePartSets.length > 0)) if(data.activePartSets && (data.activePartSets.length > 0))
{ {
for (const activePart of data.activePartSets) for(const activePart of data.activePartSets)
{ {
if (!activePart) continue; if(!activePart) continue;
this._activePartSets.set(activePart.id, new ActivePartSet(activePart)); this._activePartSets.set(activePart.id, new ActivePartSet(activePart));
} }
@ -67,7 +67,7 @@ export class PartSetsData implements IFigureSetData
{ {
const activePartSet = this._activePartSets.get(k.activePartSet); const activePartSet = this._activePartSets.get(k.activePartSet);
if (!activePartSet) return []; if(!activePartSet) return [];
return activePartSet.parts; return activePartSet.parts;
} }
@ -76,7 +76,7 @@ export class PartSetsData implements IFigureSetData
{ {
const existing = this._parts.get(part); const existing = this._parts.get(part);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }
@ -87,7 +87,7 @@ export class PartSetsData implements IFigureSetData
let existing = this._parts.get(_local_2); let existing = this._parts.get(_local_2);
if (!existing) if(!existing)
{ {
existing = new PartDefinition(k); existing = new PartDefinition(k);
@ -101,7 +101,7 @@ export class PartSetsData implements IFigureSetData
{ {
const existing = this._activePartSets.get(k.activePartSet); const existing = this._activePartSets.get(k.activePartSet);
if (!existing) return null; if(!existing) return null;
return existing; return existing;
} }

View File

@ -11,7 +11,7 @@ export class FigurePart implements IFigurePart
constructor(data: IFigureDataPart) constructor(data: IFigureDataPart)
{ {
if (!data) throw new Error('invalid_data'); if(!data) throw new Error('invalid_data');
this._id = data.id; this._id = data.id;
this._type = data.type; this._type = data.type;

View File

@ -16,7 +16,7 @@ export class FigurePartSet implements IFigurePartSet
constructor(type: string, data: IFigureDataSet) constructor(type: string, data: IFigureDataSet)
{ {
if (!type || !data) throw new Error('invalid_data'); if(!type || !data) throw new Error('invalid_data');
this._id = data.id; this._id = data.id;
this._type = type; this._type = type;
@ -29,24 +29,24 @@ export class FigurePartSet implements IFigurePartSet
this._isPreSelectable = data.preselectable; this._isPreSelectable = data.preselectable;
this._isSellable = data.sellable; this._isSellable = data.sellable;
for (const part of data.parts) for(const part of data.parts)
{ {
const newPart = new FigurePart(part); const newPart = new FigurePart(part);
const partIndex = this.getPartIndex(newPart); const partIndex = this.getPartIndex(newPart);
if (partIndex !== -1) this._parts.splice(partIndex, 0, newPart); if(partIndex !== -1) this._parts.splice(partIndex, 0, newPart);
else this._parts.push(newPart); else this._parts.push(newPart);
} }
if (data.hiddenLayers) if(data.hiddenLayers)
{ {
for (const hiddenLayer of data.hiddenLayers) this._hiddenLayers.push(hiddenLayer.partType); for(const hiddenLayer of data.hiddenLayers) this._hiddenLayers.push(hiddenLayer.partType);
} }
} }
public dispose(): void public dispose(): void
{ {
for (const part of this._parts) for(const part of this._parts)
{ {
const figurePart = part as FigurePart; const figurePart = part as FigurePart;
@ -61,15 +61,15 @@ export class FigurePartSet implements IFigurePartSet
{ {
const totalParts = this._parts.length; const totalParts = this._parts.length;
if (!totalParts) return -1; if(!totalParts) return -1;
for (let i = 0; i < totalParts; i++) for(let i = 0; i < totalParts; i++)
{ {
const existingPart = this._parts[i]; const existingPart = this._parts[i];
if (!existingPart) continue; if(!existingPart) continue;
if (existingPart.type !== part.type || existingPart.index > part.index) continue; if(existingPart.type !== part.type || existingPart.index > part.index) continue;
return i; return i;
} }
@ -79,9 +79,9 @@ export class FigurePartSet implements IFigurePartSet
public getPart(k: string, _arg_2: number): IFigurePart public getPart(k: string, _arg_2: number): IFigurePart
{ {
for (const part of this._parts) for(const part of this._parts)
{ {
if ((part.type !== k) || (part.id !== _arg_2)) continue; if((part.type !== k) || (part.id !== _arg_2)) continue;
return part; return part;
} }

View File

@ -9,7 +9,7 @@ export class Palette implements IPalette
constructor(data: IFigureDataPalette) constructor(data: IFigureDataPalette)
{ {
if (!data) throw new Error('invalid_data'); if(!data) throw new Error('invalid_data');
this._id = data.id; this._id = data.id;
this._colors = new AdvancedMap(); this._colors = new AdvancedMap();
@ -19,7 +19,7 @@ export class Palette implements IPalette
public append(data: IFigureDataPalette): void public append(data: IFigureDataPalette): void
{ {
for (const color of data.colors) for(const color of data.colors)
{ {
const newColor = new PartColor(color); const newColor = new PartColor(color);
@ -29,7 +29,7 @@ export class Palette implements IPalette
public getColor(id: number): IPartColor public getColor(id: number): IPartColor
{ {
if ((id === undefined) || id < 0) return null; if((id === undefined) || id < 0) return null;
return (this._colors.getValue(id.toString()) || null); return (this._colors.getValue(id.toString()) || null);
} }

View File

@ -10,7 +10,7 @@ export class PartColor implements IPartColor
constructor(data: IFigureDataColor) constructor(data: IFigureDataColor)
{ {
if (!data) throw new Error('invalid_data'); if(!data) throw new Error('invalid_data');
this._id = data.id; this._id = data.id;
this._index = data.index; this._index = data.index;

View File

@ -11,7 +11,7 @@ export class SetType implements ISetType
constructor(data: IFigureDataSetType) constructor(data: IFigureDataSetType)
{ {
if (!data) throw new Error('invalid_data'); if(!data) throw new Error('invalid_data');
this._type = data.type; this._type = data.type;
this._paletteId = data.paletteId; this._paletteId = data.paletteId;
@ -25,7 +25,7 @@ export class SetType implements ISetType
public dispose(): void public dispose(): void
{ {
for (const set of this._partSets.getValues()) for(const set of this._partSets.getValues())
{ {
const partSet = set as FigurePartSet; const partSet = set as FigurePartSet;
@ -37,12 +37,12 @@ export class SetType implements ISetType
public cleanUp(data: IFigureDataSetType): void public cleanUp(data: IFigureDataSetType): void
{ {
for (const set of data.sets) for(const set of data.sets)
{ {
const setId = set.id.toString(); const setId = set.id.toString();
const partSet = (this._partSets.getValue(setId) as FigurePartSet); const partSet = (this._partSets.getValue(setId) as FigurePartSet);
if (partSet) if(partSet)
{ {
partSet.dispose(); partSet.dispose();
@ -53,18 +53,18 @@ export class SetType implements ISetType
public append(setType: IFigureDataSetType): void public append(setType: IFigureDataSetType): void
{ {
if (!setType || !setType.sets) return; if(!setType || !setType.sets) return;
for (const set of setType.sets) this._partSets.add(set.id.toString(), new FigurePartSet(this._type, set)); for(const set of setType.sets) this._partSets.add(set.id.toString(), new FigurePartSet(this._type, set));
} }
public getDefaultPartSet(gender: string): IFigurePartSet public getDefaultPartSet(gender: string): IFigurePartSet
{ {
for (const set of this._partSets.getValues()) for(const set of this._partSets.getValues())
{ {
if (!set) continue; if(!set) continue;
if ((set.clubLevel === 0) && ((set.gender === gender) || (set.gender === 'U'))) return set; if((set.clubLevel === 0) && ((set.gender === gender) || (set.gender === 'U'))) return set;
} }
return null; return null;

View File

@ -21,20 +21,20 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
public init(): void public init(): void
{ {
if (this._isLoaded) return; if(this._isLoaded) return;
this._isLoaded = true; this._isLoaded = true;
const imagesUrl = NitroConfiguration.getValue<string>('image.library.url') + 'Habbo-Stories/'; const imagesUrl = NitroConfiguration.getValue<string>('image.library.url') + 'Habbo-Stories/';
const effects = NitroConfiguration.getValue<{ name: string, colorMatrix?: ColorMatrix, minLevel: number, blendMode?: number, enabled: boolean }[]>('camera.available.effects'); const effects = NitroConfiguration.getValue<{ name: string, colorMatrix?: ColorMatrix, minLevel: number, blendMode?: number, enabled: boolean }[]>('camera.available.effects');
for (const effect of effects) for(const effect of effects)
{ {
if (!effect.enabled) continue; if(!effect.enabled) continue;
const cameraEffect = new RoomCameraWidgetEffect(effect.name, effect.minLevel); const cameraEffect = new RoomCameraWidgetEffect(effect.name, effect.minLevel);
if (effect.colorMatrix.length) if(effect.colorMatrix.length)
{ {
cameraEffect.colorMatrix = effect.colorMatrix; cameraEffect.colorMatrix = effect.colorMatrix;
} }
@ -57,22 +57,22 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
container.addChild(sprite); container.addChild(sprite);
if (isZoomed) sprite.scale.set(2); if(isZoomed) sprite.scale.set(2);
for (const selectedEffect of selectedEffects) for(const selectedEffect of selectedEffects)
{ {
const effect = selectedEffect.effect; const effect = selectedEffect.effect;
if (!effect) continue; if(!effect) continue;
if (effect.colorMatrix) if(effect.colorMatrix)
{ {
const filter = new ColorMatrixFilter(); const filter = new ColorMatrixFilter();
filter.matrix = effect.colorMatrix; filter.matrix = effect.colorMatrix;
filter.alpha = selectedEffect.alpha; filter.alpha = selectedEffect.alpha;
if (!sprite.filters) sprite.filters = []; if(!sprite.filters) sprite.filters = [];
sprite.filters.push(filter); sprite.filters.push(filter);
} }

View File

@ -35,7 +35,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (connection) if(connection)
{ {
connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent); connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent); connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
@ -50,7 +50,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (connection) if(connection)
{ {
connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent); connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent); connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
@ -68,13 +68,13 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (!connection) return; if(!connection) return;
this._didConnect = true; this._didConnect = true;
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection); this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
if (NitroConfiguration.getValue<boolean>('system.pong.manually', false)) this.startPonging(); if(NitroConfiguration.getValue<boolean>('system.pong.manually', false)) this.startPonging();
this.startHandshake(connection); this.startHandshake(connection);
@ -87,18 +87,18 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (!connection) return; if(!connection) return;
this.stopPonging(); 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 private onConnectionErrorEvent(event: CloseEvent): void
{ {
const connection = this._communication.connection; const connection = this._communication.connection;
if (!connection) return; if(!connection) return;
this.stopPonging(); this.stopPonging();
@ -107,9 +107,9 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
private tryAuthentication(connection: IConnection): void private tryAuthentication(connection: IConnection): void
{ {
if (!connection || !this.getSSO()) if(!connection || !this.getSSO())
{ {
if (!this.getSSO()) if(!this.getSSO())
{ {
NitroLogger.error('Login without an SSO ticket is not supported'); NitroLogger.error('Login without an SSO ticket is not supported');
} }
@ -124,14 +124,14 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
private onClientPingEvent(event: ClientPingEvent): void private onClientPingEvent(event: ClientPingEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
this.sendPong(event.connection); this.sendPong(event.connection);
} }
private onAuthenticatedEvent(event: AuthenticatedEvent): void private onAuthenticatedEvent(event: AuthenticatedEvent): void
{ {
if (!event || !event.connection) return; if(!event || !event.connection) return;
this.completeHandshake(event.connection); this.completeHandshake(event.connection);
@ -163,7 +163,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
private stopPonging(): void private stopPonging(): void
{ {
if (!this._pongInterval) return; if(!this._pongInterval) return;
clearInterval(this._pongInterval); clearInterval(this._pongInterval);
@ -174,7 +174,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
{ {
connection = ((connection || this._communication.connection) || null); connection = ((connection || this._communication.connection) || null);
if (!connection) return; if(!connection) return;
connection.send(new PongMessageComposer()); connection.send(new PongMessageComposer());
} }

View File

@ -31,7 +31,7 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
protected onInit(): void protected onInit(): void
{ {
if (this._connection) return; if(this._connection) return;
Nitro.instance.events.addEventListener(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, this.onConnectionAuthenticatedEvent); Nitro.instance.events.addEventListener(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, this.onConnectionAuthenticatedEvent);
@ -43,16 +43,16 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent); this._connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent); this._connection.addEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
if (this._demo) this._demo.init(); if(this._demo) this._demo.init();
this._connection.init(NitroConfiguration.getValue<string>('socket.url')); this._connection.init(NitroConfiguration.getValue<string>('socket.url'));
} }
protected onDispose(): void protected onDispose(): void
{ {
if (this._demo) this._demo.dispose(); if(this._demo) this._demo.dispose();
if (this._connection) if(this._connection)
{ {
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent); this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent); this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
@ -83,7 +83,7 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
{ {
NitroLogger.log('Connection Authenticated'); NitroLogger.log('Connection Authenticated');
if (this._connection) this._connection.authenticated(); if(this._connection) this._connection.authenticated();
} }
public connectionInit(socketUrl: string): void public connectionInit(socketUrl: string): void
@ -93,14 +93,14 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
public registerMessageEvent(event: IMessageEvent): IMessageEvent public registerMessageEvent(event: IMessageEvent): IMessageEvent
{ {
if (this._connection) this._connection.addMessageEvent(event); if(this._connection) this._connection.addMessageEvent(event);
return event; return event;
} }
public removeMessageEvent(event: IMessageEvent): void public removeMessageEvent(event: IMessageEvent): void
{ {
if (!this._connection) return; if(!this._connection) return;
this._connection.removeMessageEvent(event); this._connection.removeMessageEvent(event);
} }

View File

@ -18,7 +18,7 @@ export class FrontPageItem
constructor(wrapper: IMessageDataWrapper) constructor(wrapper: IMessageDataWrapper)
{ {
if (!wrapper) throw new Error('invalid_wrapper'); if(!wrapper) throw new Error('invalid_wrapper');
this.flush(); this.flush();
this.parse(wrapper); this.parse(wrapper);
@ -40,14 +40,14 @@ export class FrontPageItem
public parse(wrapper: IMessageDataWrapper): boolean public parse(wrapper: IMessageDataWrapper): boolean
{ {
if (!wrapper) return false; if(!wrapper) return false;
this._position = wrapper.readInt(); this._position = wrapper.readInt();
this._itemName = wrapper.readString(); this._itemName = wrapper.readString();
this._itemPromoImage = wrapper.readString(); this._itemPromoImage = wrapper.readString();
this._type = wrapper.readInt(); this._type = wrapper.readInt();
switch (this._type) switch(this._type)
{ {
case FrontPageItem.ITEM_CATALOGUE_PAGE: case FrontPageItem.ITEM_CATALOGUE_PAGE:
this._catalogPageLocation = wrapper.readString(); this._catalogPageLocation = wrapper.readString();

View File

@ -42,7 +42,7 @@ export class TargetedOfferData
let count = wrapper.readInt(); let count = wrapper.readInt();
while (count > 0) while(count > 0)
{ {
this._Str_11962.push(wrapper.readString()); this._Str_11962.push(wrapper.readString());
@ -53,7 +53,7 @@ export class TargetedOfferData
public populate(offerData: TargetedOfferData) public populate(offerData: TargetedOfferData)
{ {
if (!offerData) return; if(!offerData) return;
this._id = offerData.id; this._id = offerData.id;
this._identifier = offerData.identifier; this._identifier = offerData.identifier;

View File

@ -18,7 +18,7 @@ export class BadgesParser implements IMessageParser
public parse(wrapper: IMessageDataWrapper): boolean public parse(wrapper: IMessageDataWrapper): boolean
{ {
if (!wrapper) return false; if(!wrapper) return false;
this._allBadgeCodes = []; this._allBadgeCodes = [];
this._activeBadgeCodes = new AdvancedMap(); this._activeBadgeCodes = new AdvancedMap();
@ -26,7 +26,7 @@ export class BadgesParser implements IMessageParser
let count = wrapper.readInt(); let count = wrapper.readInt();
while (count > 0) while(count > 0)
{ {
const badgeId = wrapper.readInt(); const badgeId = wrapper.readInt();
const badgeCode = wrapper.readString(); const badgeCode = wrapper.readString();
@ -40,7 +40,7 @@ export class BadgesParser implements IMessageParser
count = wrapper.readInt(); count = wrapper.readInt();
while (count > 0) while(count > 0)
{ {
const badgeSlot = wrapper.readInt(); const badgeSlot = wrapper.readInt();
const badgeCode = wrapper.readString(); const badgeCode = wrapper.readString();

View File

@ -30,7 +30,7 @@ export class FurnitureListItemParser implements IFurnitureItemData
constructor(wrapper: IMessageDataWrapper) constructor(wrapper: IMessageDataWrapper)
{ {
if (!wrapper) throw new Error('invalid_wrapper'); if(!wrapper) throw new Error('invalid_wrapper');
this.flush(); this.flush();
this.parse(wrapper); this.parse(wrapper);
@ -63,7 +63,7 @@ export class FurnitureListItemParser implements IFurnitureItemData
public parse(wrapper: IMessageDataWrapper): boolean public parse(wrapper: IMessageDataWrapper): boolean
{ {
if (!wrapper) return false; if(!wrapper) return false;
this._itemId = wrapper.readInt(); this._itemId = wrapper.readInt();
this._furniType = wrapper.readString(); this._furniType = wrapper.readString();
@ -78,7 +78,7 @@ export class FurnitureListItemParser implements IFurnitureItemData
this._secondsToExpiration = wrapper.readInt(); this._secondsToExpiration = wrapper.readInt();
this._expirationTimeStamp = GetTickerTime(); this._expirationTimeStamp = GetTickerTime();
if (this.secondsToExpiration > -1) if(this.secondsToExpiration > -1)
{ {
this._rentable = true; this._rentable = true;
} }
@ -92,7 +92,7 @@ export class FurnitureListItemParser implements IFurnitureItemData
this._flatId = wrapper.readInt(); this._flatId = wrapper.readInt();
this._isWallItem = (this._furniType === FurnitureListItemParser.WALL_ITEM); this._isWallItem = (this._furniType === FurnitureListItemParser.WALL_ITEM);
if (this._furniType === FurnitureListItemParser.FLOOR_ITEM) if(this._furniType === FurnitureListItemParser.FLOOR_ITEM)
{ {
this._slotId = wrapper.readString(); this._slotId = wrapper.readString();
this._extra = wrapper.readInt(); this._extra = wrapper.readInt();

View File

@ -20,7 +20,7 @@ export class PetFigureDataParser implements IPetFigureData
let i = 0; let i = 0;
while (i < this._customPartCount) while(i < this._customPartCount)
{ {
this._customParts.push(wrapper.readInt()); this._customParts.push(wrapper.readInt());
this._customParts.push(wrapper.readInt()); this._customParts.push(wrapper.readInt());
@ -56,7 +56,7 @@ export class PetFigureDataParser implements IPetFigureData
figure = (figure + (' ' + this.custompartCount)); figure = (figure + (' ' + this.custompartCount));
for (const _local_2 of this.customParts) figure = (figure + (' ' + _local_2)); for(const _local_2 of this.customParts) figure = (figure + (' ' + _local_2));
return figure; return figure;
} }

View File

@ -133,11 +133,11 @@ export class IssueMessageData
public dispose(): void public dispose(): void
{ {
if (this.disposed) if(this.disposed)
{ {
return; return;
} }
for (const k of this._patterns) for(const k of this._patterns)
{ {
k.dispose(); k.dispose();
} }

View File

@ -14,18 +14,18 @@ export class UnseenItemsParser implements IMessageParser
public parse(wrapper: IMessageDataWrapper): boolean public parse(wrapper: IMessageDataWrapper): boolean
{ {
if (!wrapper) return false; if(!wrapper) return false;
let totalUnseen = wrapper.readInt(); let totalUnseen = wrapper.readInt();
while (totalUnseen > 0) while(totalUnseen > 0)
{ {
const category = wrapper.readInt(); const category = wrapper.readInt();
let totalItems = wrapper.readInt(); let totalItems = wrapper.readInt();
const itemIds: number[] = []; const itemIds: number[] = [];
while (totalItems > 0) while(totalItems > 0)
{ {
itemIds.push(wrapper.readInt()); itemIds.push(wrapper.readInt());

View File

@ -32,7 +32,7 @@ export class QuestionParser implements IMessageParser
this._question = { id: questionId, number: questionNumber, type: questionType, content: questionContent }; this._question = { id: questionId, number: questionNumber, type: questionType, content: questionContent };
if (((this._question.type == 1) || (this._question.type == 2))) if(((this._question.type == 1) || (this._question.type == 2)))
{ {
this._question.selection_min = wrapper.readInt(); this._question.selection_min = wrapper.readInt();
const count = wrapper.readInt(); const count = wrapper.readInt();
@ -41,7 +41,7 @@ export class QuestionParser implements IMessageParser
this._question.selection_count = count; this._question.selection_count = count;
this._question.selection_max = count; this._question.selection_max = count;
for (let i = 0; i < count; i++) for(let i = 0; i < count; i++)
{ {
this._question.selection_values.push(wrapper.readString()); this._question.selection_values.push(wrapper.readString());
this._question.selections.push(wrapper.readString()); this._question.selections.push(wrapper.readString());

View File

@ -15,7 +15,7 @@ export class UserSongDisksInventoryMessageParser implements IMessageParser
{ {
const count = wrapper.readInt(); const count = wrapper.readInt();
for (let i = 0; i < count; i++) for(let i = 0; i < count; i++)
{ {
this._songDiskInventory.add(wrapper.readInt(), wrapper.readInt()); this._songDiskInventory.add(wrapper.readInt(), wrapper.readInt());
} }
@ -24,7 +24,7 @@ export class UserSongDisksInventoryMessageParser implements IMessageParser
public getDiskId(k: number): number public getDiskId(k: number): number
{ {
if (((k >= 0) && (k < this._songDiskInventory.length))) if(((k >= 0) && (k < this._songDiskInventory.length)))
{ {
return this._songDiskInventory.getKey(k); return this._songDiskInventory.getKey(k);
} }
@ -33,7 +33,7 @@ export class UserSongDisksInventoryMessageParser implements IMessageParser
public getSongId(k: number): number public getSongId(k: number): number
{ {
if (((k >= 0) && (k < this._songDiskInventory.length))) if(((k >= 0) && (k < this._songDiskInventory.length)))
{ {
return this._songDiskInventory.getWithIndex(k); return this._songDiskInventory.getWithIndex(k);
} }

View File

@ -17,14 +17,14 @@ export class RelationshipStatusInfoMessageParser implements IMessageParser
public parse(wrapper: IMessageDataWrapper): boolean public parse(wrapper: IMessageDataWrapper): boolean
{ {
if (!wrapper) return false; if(!wrapper) return false;
this._userId = wrapper.readInt(); this._userId = wrapper.readInt();
this._relationshipStatusMap = new AdvancedMap(); this._relationshipStatusMap = new AdvancedMap();
const relationshipsCount = wrapper.readInt(); const relationshipsCount = wrapper.readInt();
for (let i = 0; i < relationshipsCount; i++) for(let i = 0; i < relationshipsCount; i++)
{ {
const relationship = new RelationshipStatusInfo(wrapper); const relationship = new RelationshipStatusInfo(wrapper);

View File

@ -31,12 +31,12 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
let urls: string[] = NitroConfiguration.getValue<string[]>('external.texts.url'); let urls: string[] = NitroConfiguration.getValue<string[]>('external.texts.url');
if (!Array.isArray(urls)) if(!Array.isArray(urls))
{ {
urls = [NitroConfiguration.getValue<string>('external.texts.url')]; urls = [NitroConfiguration.getValue<string>('external.texts.url')];
} }
for (let i = 0; i < urls.length; i++) urls[i] = NitroConfiguration.interpolate(urls[i]); for(let i = 0; i < urls.length; i++) urls[i] = NitroConfiguration.interpolate(urls[i]);
this._pendingUrls = urls; this._pendingUrls = urls;
@ -45,7 +45,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
private loadNextLocalization(): void private loadNextLocalization(): void
{ {
if (!this._pendingUrls.length) if(!this._pendingUrls.length)
{ {
this.events && this.events.dispatchEvent(new NitroLocalizationEvent(NitroLocalizationEvent.LOADED)); this.events && this.events.dispatchEvent(new NitroLocalizationEvent(NitroLocalizationEvent.LOADED));
@ -65,13 +65,13 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
private onLocalizationLoaded(data: { [index: string]: any }, url: string): void private onLocalizationLoaded(data: { [index: string]: any }, url: string): void
{ {
if (!data) return; if(!data) return;
if (!this.parseLocalization(data)) throw new Error(`Invalid json data for file ${url}`); if(!this.parseLocalization(data)) throw new Error(`Invalid json data for file ${url}`);
const index = this._pendingUrls.indexOf(url); const index = this._pendingUrls.indexOf(url);
if (index >= 0) this._pendingUrls.splice(index, 1); if(index >= 0) this._pendingUrls.splice(index, 1);
this.loadNextLocalization(); this.loadNextLocalization();
} }
@ -83,9 +83,9 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
private parseLocalization(data: { [index: string]: any }): boolean private parseLocalization(data: { [index: string]: any }): boolean
{ {
if (!data) return false; if(!data) return false;
for (const key in data) this._definitions.set(key, data[key]); for(const key in data) this._definitions.set(key, data[key]);
return true; return true;
} }
@ -94,7 +94,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
{ {
const parser = event.getParser(); const parser = event.getParser();
for (const data of parser.data) this.setBadgePointLimit(data.badgeId, data.limit); for(const data of parser.data) this.setBadgePointLimit(data.badgeId, data.limit);
} }
public getBadgePointLimit(badge: string): number public getBadgePointLimit(badge: string): number
@ -128,31 +128,31 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
public getValue(key: string, doParams: boolean = true): string public getValue(key: string, doParams: boolean = true): string
{ {
if (!key || !key.length) return null; if(!key || !key.length) return null;
const keys = key.match(/\$\{.[^}]*\}/g); const keys = key.match(/\$\{.[^}]*\}/g);
if (keys && keys.length) if(keys && keys.length)
{ {
for (const splitKey of keys) key = key.replace(splitKey, this.getValue(splitKey.slice(2, -1), doParams)); for(const splitKey of keys) key = key.replace(splitKey, this.getValue(splitKey.slice(2, -1), doParams));
} }
let value = (this._definitions.get(key) || null); let value = (this._definitions.get(key) || null);
if (!value) if(!value)
{ {
value = (NitroConfiguration.definitions.get(key) as any); value = (NitroConfiguration.definitions.get(key) as any);
if (value) return value; if(value) return value;
} }
if (value && doParams) if(value && doParams)
{ {
const parameters = this._parameters.get(key); const parameters = this._parameters.get(key);
if (parameters) if(parameters)
{ {
for (const [parameter, replacement] of parameters) for(const [parameter, replacement] of parameters)
{ {
value = value.replace('%' + parameter + '%', replacement); value = value.replace('%' + parameter + '%', replacement);
} }
@ -168,7 +168,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
const replacedValue = value.replace('%' + parameter + '%', replacement); const replacedValue = value.replace('%' + parameter + '%', replacement);
if (value.startsWith('%{')) if(value.startsWith('%{'))
{ {
// This adds support for multi-optioned texts like // This adds support for multi-optioned texts like
// catalog.vip.item.header.months=%{NUM_MONTHS|0 months|1 month|%% months} // catalog.vip.item.header.months=%{NUM_MONTHS|0 months|1 month|%% months}
@ -180,13 +180,13 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
const regex = new RegExp('%{' + parameter.toUpperCase() + '\\|([^|]*)\\|([^|]*)\\|([^|]*)}'); const regex = new RegExp('%{' + parameter.toUpperCase() + '\\|([^|]*)\\|([^|]*)\\|([^|]*)}');
const result = value.match(regex); const result = value.match(regex);
if (!result) return replacedValue; if(!result) return replacedValue;
let indexKey = -1; let indexKey = -1;
const replacementAsNumber = Number.parseInt(replacement); const replacementAsNumber = Number.parseInt(replacement);
let replace = false; let replace = false;
switch (replacementAsNumber) switch(replacementAsNumber)
{ {
case 0: case 0:
indexKey = 1; indexKey = 1;
@ -202,14 +202,14 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
} }
if (indexKey == -1 || typeof result[indexKey] == 'undefined') if(indexKey == -1 || typeof result[indexKey] == 'undefined')
{ {
return replacedValue; return replacedValue;
} }
const valueFromResults = result[indexKey]; const valueFromResults = result[indexKey];
if (valueFromResults) if(valueFromResults)
{ {
return valueFromResults.replace('%%', replacement); return valueFromResults.replace('%%', replacement);
} }
@ -222,30 +222,30 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
{ {
let value = this.getValue(key, false); let value = this.getValue(key, false);
if (parameters) if(parameters)
{ {
for (let i = 0; i < parameters.length; i++) for(let i = 0; i < parameters.length; i++)
{ {
const parameter = parameters[i]; const parameter = parameters[i];
const replacement = replacements[i]; const replacement = replacements[i];
if (replacement === undefined) continue; if(replacement === undefined) continue;
value = value.replace('%' + parameter + '%', replacement); value = value.replace('%' + parameter + '%', replacement);
if (value.startsWith('%{')) if(value.startsWith('%{'))
{ {
const regex = new RegExp('%{' + parameter.toUpperCase() + '\\|([^|]*)\\|([^|]*)\\|([^|]*)}'); const regex = new RegExp('%{' + parameter.toUpperCase() + '\\|([^|]*)\\|([^|]*)\\|([^|]*)}');
const result = value.match(regex); const result = value.match(regex);
if (!result) continue; if(!result) continue;
const replacementAsNumber = parseInt(replacement); const replacementAsNumber = parseInt(replacement);
let indexKey = -1; let indexKey = -1;
let replace = false; let replace = false;
switch (replacementAsNumber) switch(replacementAsNumber)
{ {
case 0: case 0:
indexKey = 1; indexKey = 1;
@ -261,11 +261,11 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
} }
if ((indexKey === -1) || (typeof result[indexKey] === 'undefined')) continue; if((indexKey === -1) || (typeof result[indexKey] === 'undefined')) continue;
const valueFromResults = result[indexKey]; const valueFromResults = result[indexKey];
if (valueFromResults) if(valueFromResults)
{ {
value = valueFromResults.replace('%%', replacement); value = valueFromResults.replace('%%', replacement);
} }
@ -283,11 +283,11 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
public registerParameter(key: string, parameter: string, value: string): void public registerParameter(key: string, parameter: string, value: string): void
{ {
if (!key || (key.length === 0) || !parameter || (parameter.length === 0)) return; if(!key || (key.length === 0) || !parameter || (parameter.length === 0)) return;
let existing = this._parameters.get(key); let existing = this._parameters.get(key);
if (!existing) if(!existing)
{ {
existing = new Map(); existing = new Map();
@ -318,7 +318,7 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
const limit = this.getBadgePointLimit(key); const limit = this.getBadgePointLimit(key);
if (limit > -1) desc = desc.replace('%limit%', limit.toString()); if(limit > -1) desc = desc.replace('%limit%', limit.toString());
desc = desc.replace('%roman%', this.getRomanNumeral(badge.level)); desc = desc.replace('%roman%', this.getRomanNumeral(badge.level));
@ -327,10 +327,10 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
private getExistingKey(keys: string[]): string private getExistingKey(keys: string[]): string
{ {
for (const entry of keys) for(const entry of keys)
{ {
const item = this.getValue(entry); const item = this.getValue(entry);
if (item != entry) return item; if(item != entry) return item;
} }
return ''; return '';

View File

@ -80,7 +80,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
this.setFurnitureData(); this.setFurnitureData();
for (const [index, name] of NitroConfiguration.getValue<string[]>('pet.types').entries()) this._pets[name] = index; for(const [index, name] of NitroConfiguration.getValue<string[]>('pet.types').entries()) this._pets[name] = index;
} }
public dispose(): void public dispose(): void
@ -92,7 +92,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
this._sessionDataManager = sessionData; this._sessionDataManager = sessionData;
if (this._waitingForSessionDataManager) if(this._waitingForSessionDataManager)
{ {
this._waitingForSessionDataManager = false; this._waitingForSessionDataManager = false;
@ -107,7 +107,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
private setFurnitureData(): void private setFurnitureData(): void
{ {
if (!this._sessionDataManager) if(!this._sessionDataManager)
{ {
this._waitingForSessionDataManager = true; this._waitingForSessionDataManager = true;
@ -116,7 +116,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
const furnitureData = this._sessionDataManager.getAllFurnitureData(this); const furnitureData = this._sessionDataManager.getAllFurnitureData(this);
if (!furnitureData) return; if(!furnitureData) return;
this._sessionDataManager.removePendingFurniDataListener(this); this._sessionDataManager.removePendingFurniDataListener(this);
@ -127,42 +127,42 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
private processFurnitureData(furnitureData: IFurnitureData[]): void 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; const id = furniture.id;
let className = furniture.className; let className = furniture.className;
if (furniture.hasIndexedColor) className = ((className + '*') + furniture.colorIndex); if(furniture.hasIndexedColor) className = ((className + '*') + furniture.colorIndex);
const revision = furniture.revision; const revision = furniture.revision;
const adUrl = furniture.adUrl; 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; let name = furniture.className;
if (furniture.type === FurnitureType.FLOOR) if(furniture.type === FurnitureType.FLOOR)
{ {
this._activeObjectTypes.set(id, className); this._activeObjectTypes.set(id, className);
this._activeObjectTypeIds.set(className, id); 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'; className = 'post_it';
name = 'post_it'; name = 'post_it';
} }
if (name === 'post.it.vd') if(name === 'post.it.vd')
{ {
className = 'post_it_vd'; className = 'post_it_vd';
name = 'post_id_vd'; name = 'post_id_vd';
@ -171,12 +171,12 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
this._wallItemTypes.set(id, className); this._wallItemTypes.set(id, className);
this._wallItemTypeIds.set(className, id); 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); const existingRevision = this._furniRevisions.get(name);
if (revision > existingRevision) if(revision > existingRevision)
{ {
this._furniRevisions.delete(name); this._furniRevisions.delete(name);
this._furniRevisions.set(name, revision); this._furniRevisions.set(name, revision);
@ -195,7 +195,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
let type = this._wallItemTypes.get(typeId); 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); return this.removeColorIndex(type);
} }
@ -204,7 +204,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const type = this._activeObjectTypes.get(typeId); const type = this._activeObjectTypes.get(typeId);
if (!type) return -1; if(!type) return -1;
return this.getColorIndexFromName(type); return this.getColorIndexFromName(type);
} }
@ -213,29 +213,29 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const type = this._wallItemTypes.get(typeId); const type = this._wallItemTypes.get(typeId);
if (!type) return -1; if(!type) return -1;
return this.getColorIndexFromName(type); return this.getColorIndexFromName(type);
} }
private getColorIndexFromName(name: string): number private getColorIndexFromName(name: string): number
{ {
if (!name) return -1; if(!name) return -1;
const index = name.indexOf('*'); const index = name.indexOf('*');
if (index === -1) return 0; if(index === -1) return 0;
return parseInt(name.substr(index + 1)); return parseInt(name.substr(index + 1));
} }
private removeColorIndex(name: string): string private removeColorIndex(name: string): string
{ {
if (!name) return null; if(!name) return null;
const index = name.indexOf('*'); const index = name.indexOf('*');
if (index === -1) return name; if(index === -1) return name;
return name.substr(0, index); return name.substr(0, index);
} }
@ -244,7 +244,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const value = this._objectTypeAdUrls.get(type); const value = this._objectTypeAdUrls.get(type);
if (!value) return ''; if(!value) return '';
return value; return value;
} }
@ -253,7 +253,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const colorResults = this._petColors.get(petIndex); const colorResults = this._petColors.get(petIndex);
if (!colorResults) return null; if(!colorResults) return null;
return colorResults.get(paletteIndex); return colorResults.get(paletteIndex);
} }
@ -263,11 +263,11 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
const colorResults = this._petColors.get(petIndex); const colorResults = this._petColors.get(petIndex);
const results: IPetColorResult[] = []; const results: IPetColorResult[] = [];
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);
} }
} }
@ -276,15 +276,15 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
public getCollection(name: string): IGraphicAssetCollection public getCollection(name: string): IGraphicAssetCollection
{ {
if (!name) return null; if(!name) return null;
const existing = this._collections.get(name); const existing = this._collections.get(name);
if (!existing) if(!existing)
{ {
const globalCollection = Nitro.instance.core.asset.getCollection(name); const globalCollection = Nitro.instance.core.asset.getCollection(name);
if (globalCollection) if(globalCollection)
{ {
this._collections.set(name, globalCollection); this._collections.set(name, globalCollection);
@ -299,18 +299,18 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
public getGifCollection(name: string): IGraphicAssetGifCollection public getGifCollection(name: string): IGraphicAssetGifCollection
{ {
if (!name) return null; if(!name) return null;
return this._gifCollections.get(name) || null; return this._gifCollections.get(name) || null;
} }
public getImage(name: string): HTMLImageElement public getImage(name: string): HTMLImageElement
{ {
if (!name) return null; if(!name) return null;
const existing = this._images.get(name); const existing = this._images.get(name);
if (!existing) return null; if(!existing) return null;
const image = new Image(); const image = new Image();
@ -323,14 +323,14 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const collection = this.getCollection(collectionName); const collection = this.getCollection(collectionName);
if (!collection) return false; if(!collection) return false;
return collection.addAsset(assetName, texture, override, 0, 0, false, false); return collection.addAsset(assetName, texture, override, 0, 0, false, false);
} }
public createGifCollection(collectionName: string, textures: Texture<Resource>[], durations: number[]): GraphicAssetGifCollection 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); const collection = new GraphicAssetGifCollection(collectionName, textures, durations);
@ -341,7 +341,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
private createCollection(data: IAssetData, spritesheet: Spritesheet): GraphicAssetCollection private createCollection(data: IAssetData, spritesheet: Spritesheet): GraphicAssetCollection
{ {
if (!data || !spritesheet) return null; if(!data || !spritesheet) return null;
const collection = new GraphicAssetCollection(data, spritesheet); const collection = new GraphicAssetCollection(data, spritesheet);
@ -349,12 +349,12 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
const petIndex = this._pets[collection.name]; const petIndex = this._pets[collection.name];
if (petIndex !== undefined) if(petIndex !== undefined)
{ {
const keys = collection.getPaletteNames(); const keys = collection.getPaletteNames();
const palettes: Map<number, IPetColorResult> = new Map(); const palettes: Map<number, IPetColorResult> = new Map();
for (const key of keys) for(const key of keys)
{ {
const palette = collection.getPalette(key); const palette = collection.getPalette(key);
const paletteData = data.palettes[key]; const paletteData = data.palettes[key];
@ -377,14 +377,14 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const category = this.getCategoryForType(type); const category = this.getCategoryForType(type);
switch (category) switch(category)
{ {
case RoomObjectCategory.FLOOR: case RoomObjectCategory.FLOOR:
return RoomContentLoader.PLACE_HOLDER; return RoomContentLoader.PLACE_HOLDER;
case RoomObjectCategory.WALL: case RoomObjectCategory.WALL:
return RoomContentLoader.PLACE_HOLDER_WALL; return RoomContentLoader.PLACE_HOLDER_WALL;
default: 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; return RoomContentLoader.PLACE_HOLDER_DEFAULT;
} }
@ -392,27 +392,27 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
public getCategoryForType(type: string): number 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; return RoomObjectCategory.MINIMUM;
} }
@ -426,7 +426,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
type = RoomObjectUserType.getRealType(type); type = RoomObjectUserType.getRealType(type);
if (type === RoomObjectVisualizationType.USER) return false; if(type === RoomObjectVisualizationType.USER) return false;
return true; return true;
} }
@ -436,13 +436,13 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
let typeName: string = null; let typeName: string = null;
let assetUrls: string[] = []; let assetUrls: string[] = [];
if (type && (type.indexOf(',') >= 0)) if(type && (type.indexOf(',') >= 0))
{ {
typeName = type; typeName = type;
type = typeName.split(',')[0]; type = typeName.split(',')[0];
} }
if (typeName) if(typeName)
{ {
assetUrls = this.getAssetUrls(typeName, param, true); assetUrls = this.getAssetUrls(typeName, param, true);
} }
@ -451,7 +451,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
assetUrls = this.getAssetUrls(type, param, true); assetUrls = this.getAssetUrls(type, param, true);
} }
if (assetUrls && assetUrls.length) if(assetUrls && assetUrls.length)
{ {
const url = assetUrls[0]; const url = assetUrls[0];
@ -487,18 +487,18 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const assetUrls: string[] = this.getAssetUrls(type); 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._pendingContentTypes.push(type);
this._events.set(type, events); this._events.set(type, events);
const loader = new Loader(); 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 loader
.add({ .add({
@ -513,7 +513,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
const onDownloaded = (status: boolean, url: string) => const onDownloaded = (status: boolean, url: string) =>
{ {
if (!status) if(!status)
{ {
NitroLogger.error('Failed to download asset', url); NitroLogger.error('Failed to download asset', url);
@ -526,13 +526,13 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
remaining--; remaining--;
if (!remaining) if(!remaining)
{ {
loader.destroy(); loader.destroy();
const events = this._events.get(type); const events = this._events.get(type);
if (!events) return; if(!events) return;
events.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type)); events.dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type));
@ -542,11 +542,11 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
loader.load((loader, resources) => loader.load((loader, resources) =>
{ {
for (const key in resources) for(const key in resources)
{ {
const resource = resources[key]; const resource = resources[key];
if (!resource || resource.error || !resource.xhr) if(!resource || resource.error || !resource.xhr)
{ {
onDownloaded(false, resource.url); onDownloaded(false, resource.url);
@ -555,7 +555,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
const resourceType = (resource.xhr.getResponseHeader('Content-Type') || 'application/octet-stream'); 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); const nitroBundle = new NitroBundle(resource.data);
@ -574,7 +574,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const spritesheetData = data.spritesheet; const spritesheetData = data.spritesheet;
if (!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length) if(!baseTexture || !spritesheetData || !Object.keys(spritesheetData).length)
{ {
this.createCollection(data, null); this.createCollection(data, null);
@ -595,7 +595,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
}); });
}; };
if (baseTexture.valid) if(baseTexture.valid)
{ {
createAsset(); createAsset();
} }
@ -615,7 +615,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const existing = this._objectAliases.get(name); const existing = this._objectAliases.get(name);
if (!existing) return name; if(!existing) return name;
return existing; return existing;
} }
@ -624,14 +624,14 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const existing = this._objectOriginalNames.get(name); const existing = this._objectOriginalNames.get(name);
if (!existing) return name; if(!existing) return name;
return existing; return existing;
} }
public getAssetUrls(type: string, param: string = null, icon: boolean = false): string[] public getAssetUrls(type: string, param: string = null, icon: boolean = false): string[]
{ {
switch (type) switch(type)
{ {
case RoomContentLoader.PLACE_HOLDER: case RoomContentLoader.PLACE_HOLDER:
return [this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER)]; return [this.getAssetUrlWithGenericBase(RoomContentLoader.PLACE_HOLDER)];
@ -648,13 +648,13 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
default: { default: {
const category = this.getCategoryForType(type); const category = this.getCategoryForType(type);
if ((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL)) if((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL))
{ {
const name = this.getAssetAliasName(type); const name = this.getAssetAliasName(type);
let assetUrl = (icon ? this.getAssetUrlWithFurniIconBase(name) : this.getAssetUrlWithFurniBase(type)); let assetUrl = (icon ? this.getAssetUrlWithFurniIconBase(name) : this.getAssetUrlWithFurniBase(type));
if (icon) if(icon)
{ {
const active = (param && (param !== '') && (this._activeObjectTypeIds.has((name + '*' + param)))); const active = (param && (param !== '') && (this._activeObjectTypeIds.has((name + '*' + param))));
@ -664,7 +664,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
return [assetUrl]; return [assetUrl];
} }
if (category === RoomObjectCategory.UNIT) if(category === RoomObjectCategory.UNIT)
{ {
return [this.getAssetUrlWithPetBase(type)]; return [this.getAssetUrlWithPetBase(type)];
} }
@ -679,14 +679,14 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
let assetName: string = null; let assetName: string = null;
let assetUrls: string[] = []; let assetUrls: string[] = [];
if (type && (type.indexOf(',') >= 0)) if(type && (type.indexOf(',') >= 0))
{ {
assetName = type; assetName = type;
type = assetName.split(',')[0]; type = assetName.split(',')[0];
} }
if (assetName) if(assetName)
{ {
assetUrls = this.getAssetUrls(assetName, colorIndex, true); assetUrls = this.getAssetUrls(assetName, colorIndex, true);
} }
@ -695,7 +695,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
assetUrls = this.getAssetUrls(type, colorIndex, true); assetUrls = this.getAssetUrls(type, colorIndex, true);
} }
if (assetUrls && assetUrls.length) return assetUrls[0]; if(assetUrls && assetUrls.length) return assetUrls[0];
return null; return null;
} }
@ -724,7 +724,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const model = object && object.model; const model = object && object.model;
if (!model) return; if(!model) return;
model.setValue(RoomObjectVariable.OBJECT_ROOM_ID, roomId); model.setValue(RoomObjectVariable.OBJECT_ROOM_ID, roomId);
} }
@ -733,7 +733,7 @@ export class RoomContentLoader implements IFurnitureDataListener, IRoomContentLo
{ {
const existing = this._events.get(type); const existing = this._events.get(type);
if (remove) this._events.delete(type); if(remove) this._events.delete(type);
return existing; return existing;
} }

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ export class RoomMessageHandler extends Disposable
this._roomCreator = null; this._roomCreator = null;
this._latestEntryTileEvent = null; this._latestEntryTileEvent = null;
if (this._planeParser) if(this._planeParser)
{ {
this._planeParser.dispose(); this._planeParser.dispose();
@ -52,7 +52,7 @@ export class RoomMessageHandler extends Disposable
public setConnection(connection: IConnection) public setConnection(connection: IConnection)
{ {
if (this._connection || !connection) return; if(this._connection || !connection) return;
this._connection = connection; this._connection = connection;
@ -104,9 +104,9 @@ export class RoomMessageHandler extends Disposable
public setRoomId(id: number): void public setRoomId(id: number): void
{ {
if (this._currentRoomId !== 0) if(this._currentRoomId !== 0)
{ {
if (this._roomCreator) this._roomCreator.destroyRoom(this._currentRoomId); if(this._roomCreator) this._roomCreator.destroyRoom(this._currentRoomId);
} }
this._currentRoomId = id; this._currentRoomId = id;
@ -121,11 +121,11 @@ export class RoomMessageHandler extends Disposable
private onUserInfoEvent(event: UserInfoEvent): void private onUserInfoEvent(event: UserInfoEvent): void
{ {
if (!(event instanceof UserInfoEvent) || !event.connection) return; if(!(event instanceof UserInfoEvent) || !event.connection) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._ownUserId = parser.userInfo.userId; this._ownUserId = parser.userInfo.userId;
} }
@ -134,17 +134,17 @@ export class RoomMessageHandler extends Disposable
{ {
const parser = event.getParser(); const parser = event.getParser();
if (this._currentRoomId !== parser.roomId) if(this._currentRoomId !== parser.roomId)
{ {
this.setRoomId(parser.roomId); this.setRoomId(parser.roomId);
} }
if (this._roomCreator) if(this._roomCreator)
{ {
this._roomCreator.setRoomInstanceModelName(parser.roomId, parser.name); this._roomCreator.setRoomInstanceModelName(parser.roomId, parser.name);
} }
if (this._initialConnection) if(this._initialConnection)
{ {
event.connection.send(new FurnitureAliasesComposer()); event.connection.send(new FurnitureAliasesComposer());
@ -158,17 +158,17 @@ export class RoomMessageHandler extends Disposable
private onRoomPaintEvent(event: RoomPaintEvent): void private onRoomPaintEvent(event: RoomPaintEvent): void
{ {
if (!(event instanceof RoomPaintEvent)) return; if(!(event instanceof RoomPaintEvent)) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const floorType = parser.floorType; const floorType = parser.floorType;
const wallType = parser.wallType; const wallType = parser.wallType;
const landscapeType = parser.landscapeType; const landscapeType = parser.landscapeType;
if (this._roomCreator) if(this._roomCreator)
{ {
this._roomCreator.updateRoomInstancePlaneType(this._currentRoomId, floorType, wallType, landscapeType); this._roomCreator.updateRoomInstancePlaneType(this._currentRoomId, floorType, wallType, landscapeType);
} }
@ -176,15 +176,15 @@ export class RoomMessageHandler extends Disposable
private onRoomModelEvent(event: FloorHeightMapEvent): void private onRoomModelEvent(event: FloorHeightMapEvent): void
{ {
if (!(event instanceof FloorHeightMapEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FloorHeightMapEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const wallGeometry = this._roomCreator.getLegacyWallGeometry(this._currentRoomId); const wallGeometry = this._roomCreator.getLegacyWallGeometry(this._currentRoomId);
if (!wallGeometry) return; if(!wallGeometry) return;
this._planeParser.reset(); this._planeParser.reset();
@ -195,7 +195,7 @@ export class RoomMessageHandler extends Disposable
let entryTile: RoomEntryTileMessageParser = null; let entryTile: RoomEntryTileMessageParser = null;
if (this._latestEntryTileEvent) entryTile = this._latestEntryTileEvent.getParser(); if(this._latestEntryTileEvent) entryTile = this._latestEntryTileEvent.getParser();
let doorX = -1; let doorX = -1;
let doorY = -1; let doorY = -1;
@ -204,17 +204,17 @@ export class RoomMessageHandler extends Disposable
let y = 0; let y = 0;
while (y < height) while(y < height)
{ {
let x = 0; let x = 0;
while (x < width) while(x < width)
{ {
const tileHeight = parser.getHeight(x, y); const tileHeight = parser.getHeight(x, y);
if (((((y > 0) && (y < (height - 1))) || ((x > 0) && (x < (width - 1)))) && (!(tileHeight == RoomPlaneParser.TILE_BLOCKED))) && ((entryTile == null) || ((x == entryTile.x) && (y == entryTile.y)))) if(((((y > 0) && (y < (height - 1))) || ((x > 0) && (x < (width - 1)))) && (!(tileHeight == RoomPlaneParser.TILE_BLOCKED))) && ((entryTile == null) || ((x == entryTile.x) && (y == entryTile.y))))
{ {
if (((parser.getHeight(x, (y - 1)) == RoomPlaneParser.TILE_BLOCKED) && (parser.getHeight((x - 1), y) == RoomPlaneParser.TILE_BLOCKED)) && (parser.getHeight(x, (y + 1)) == RoomPlaneParser.TILE_BLOCKED)) if(((parser.getHeight(x, (y - 1)) == RoomPlaneParser.TILE_BLOCKED) && (parser.getHeight((x - 1), y) == RoomPlaneParser.TILE_BLOCKED)) && (parser.getHeight(x, (y + 1)) == RoomPlaneParser.TILE_BLOCKED))
{ {
doorX = (x + 0.5); doorX = (x + 0.5);
doorY = y; doorY = y;
@ -222,7 +222,7 @@ export class RoomMessageHandler extends Disposable
doorDirection = 90; doorDirection = 90;
} }
if (((parser.getHeight(x, (y - 1)) == RoomPlaneParser.TILE_BLOCKED) && (parser.getHeight((x - 1), y) == RoomPlaneParser.TILE_BLOCKED)) && (parser.getHeight((x + 1), y) == RoomPlaneParser.TILE_BLOCKED)) if(((parser.getHeight(x, (y - 1)) == RoomPlaneParser.TILE_BLOCKED) && (parser.getHeight((x - 1), y) == RoomPlaneParser.TILE_BLOCKED)) && (parser.getHeight((x + 1), y) == RoomPlaneParser.TILE_BLOCKED))
{ {
doorX = x; doorX = x;
doorY = (y + 0.5); doorY = (y + 0.5);
@ -243,7 +243,7 @@ export class RoomMessageHandler extends Disposable
this._planeParser.initializeFromTileData(parser.wallHeight); this._planeParser.initializeFromTileData(parser.wallHeight);
this._planeParser.setTileHeight(Math.floor(doorX), Math.floor(doorY), (doorZ + this._planeParser.wallHeight)); this._planeParser.setTileHeight(Math.floor(doorX), Math.floor(doorY), (doorZ + this._planeParser.wallHeight));
if (parser.scale === 64) if(parser.scale === 64)
{ {
this._planeParser.restrictsDragging = true; this._planeParser.restrictsDragging = true;
this._planeParser.restrictsScaling = true; this._planeParser.restrictsScaling = true;
@ -261,11 +261,11 @@ export class RoomMessageHandler extends Disposable
let heightIterator = (parser.height - 1); let heightIterator = (parser.height - 1);
while (heightIterator >= 0) while(heightIterator >= 0)
{ {
let widthIterator = (parser.width - 1); let widthIterator = (parser.width - 1);
while (widthIterator >= 0) while(widthIterator >= 0)
{ {
wallGeometry.setHeight(widthIterator, heightIterator, this._planeParser.getTileHeight(widthIterator, heightIterator)); wallGeometry.setHeight(widthIterator, heightIterator, this._planeParser.getTileHeight(widthIterator, heightIterator));
widthIterator--; widthIterator--;
@ -288,11 +288,11 @@ export class RoomMessageHandler extends Disposable
private onRoomHeightMapEvent(event: RoomHeightMapEvent): void private onRoomHeightMapEvent(event: RoomHeightMapEvent): void
{ {
if (!(event instanceof RoomHeightMapEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomHeightMapEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const width = parser.width; const width = parser.width;
const height = parser.height; const height = parser.height;
@ -300,11 +300,11 @@ export class RoomMessageHandler extends Disposable
let y = 0; let y = 0;
while (y < height) while(y < height)
{ {
let x = 0; let x = 0;
while (x < width) while(x < width)
{ {
heightMap.setTileHeight(x, y, parser.getTileHeight(x, y)); heightMap.setTileHeight(x, y, parser.getTileHeight(x, y));
heightMap.setStackingBlocked(x, y, parser.getStackingBlocked(x, y)); heightMap.setStackingBlocked(x, y, parser.getStackingBlocked(x, y));
@ -321,17 +321,17 @@ export class RoomMessageHandler extends Disposable
private onRoomHeightMapUpdateEvent(event: RoomHeightMapUpdateEvent): void private onRoomHeightMapUpdateEvent(event: RoomHeightMapUpdateEvent): void
{ {
if (!(event instanceof RoomHeightMapUpdateEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomHeightMapUpdateEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const heightMap = this._roomCreator.getFurnitureStackingHeightMap(this._currentRoomId); const heightMap = this._roomCreator.getFurnitureStackingHeightMap(this._currentRoomId);
if (!heightMap) return; if(!heightMap) return;
while (parser.next()) while(parser.next())
{ {
heightMap.setTileHeight(parser.x, parser.y, parser.tileHeight()); heightMap.setTileHeight(parser.x, parser.y, parser.tileHeight());
heightMap.setStackingBlocked(parser.x, parser.y, parser.isStackingBlocked()); heightMap.setStackingBlocked(parser.x, parser.y, parser.isStackingBlocked());
@ -343,18 +343,18 @@ export class RoomMessageHandler extends Disposable
private onRoomThicknessEvent(event: RoomVisualizationSettingsEvent): void private onRoomThicknessEvent(event: RoomVisualizationSettingsEvent): void
{ {
if (!(event instanceof RoomVisualizationSettingsEvent)) return; if(!(event instanceof RoomVisualizationSettingsEvent)) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const visibleWall = !parser.hideWalls; const visibleWall = !parser.hideWalls;
const visibleFloor = true; const visibleFloor = true;
const thicknessWall = parser.thicknessWall; const thicknessWall = parser.thicknessWall;
const thicknessFloor = parser.thicknessFloor; const thicknessFloor = parser.thicknessFloor;
if (this._roomCreator) if(this._roomCreator)
{ {
this._roomCreator.updateRoomInstancePlaneVisibility(this._currentRoomId, visibleWall, visibleFloor); this._roomCreator.updateRoomInstancePlaneVisibility(this._currentRoomId, visibleWall, visibleFloor);
this._roomCreator.updateRoomInstancePlaneThickness(this._currentRoomId, thicknessWall, thicknessFloor); this._roomCreator.updateRoomInstancePlaneThickness(this._currentRoomId, thicknessWall, thicknessFloor);
@ -363,14 +363,14 @@ export class RoomMessageHandler extends Disposable
private onRoomDoorEvent(event: RoomEntryTileMessageEvent): void private onRoomDoorEvent(event: RoomEntryTileMessageEvent): void
{ {
if (!(event instanceof RoomEntryTileMessageEvent)) return; if(!(event instanceof RoomEntryTileMessageEvent)) return;
this._latestEntryTileEvent = event; this._latestEntryTileEvent = event;
} }
private onRoomRollingEvent(event: ObjectsRollingEvent): void private onRoomRollingEvent(event: ObjectsRollingEvent): void
{ {
if (!(event instanceof ObjectsRollingEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof ObjectsRollingEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
@ -379,11 +379,11 @@ export class RoomMessageHandler extends Disposable
const furnitureRolling = parser.itemsRolling; const furnitureRolling = parser.itemsRolling;
if (furnitureRolling && furnitureRolling.length) if(furnitureRolling && furnitureRolling.length)
{ {
for (const rollData of furnitureRolling) for(const rollData of furnitureRolling)
{ {
if (!rollData) continue; if(!rollData) continue;
this._roomCreator.rollRoomObjectFloor(this._currentRoomId, rollData.id, rollData.location, rollData.targetLocation); this._roomCreator.rollRoomObjectFloor(this._currentRoomId, rollData.id, rollData.location, rollData.targetLocation);
} }
@ -391,17 +391,17 @@ export class RoomMessageHandler extends Disposable
const unitRollData = parser.unitRolling; const unitRollData = parser.unitRolling;
if (unitRollData) if(unitRollData)
{ {
this._roomCreator.updateRoomObjectUserLocation(this._currentRoomId, unitRollData.id, unitRollData.location, unitRollData.targetLocation); this._roomCreator.updateRoomObjectUserLocation(this._currentRoomId, unitRollData.id, unitRollData.location, unitRollData.targetLocation);
const object = this._roomCreator.getRoomObjectUser(this._currentRoomId, unitRollData.id); const object = this._roomCreator.getRoomObjectUser(this._currentRoomId, unitRollData.id);
if (object && object.type !== RoomObjectUserType.MONSTER_PLANT) if(object && object.type !== RoomObjectUserType.MONSTER_PLANT)
{ {
let posture = 'std'; let posture = 'std';
switch (unitRollData.movementType) switch(unitRollData.movementType)
{ {
case ObjectRolling.MOVE: case ObjectRolling.MOVE:
posture = 'mv'; posture = 'mv';
@ -418,13 +418,13 @@ export class RoomMessageHandler extends Disposable
private onObjectsDataUpdateEvent(event: ObjectsDataUpdateEvent): void private onObjectsDataUpdateEvent(event: ObjectsDataUpdateEvent): void
{ {
if (!(event instanceof ObjectsDataUpdateEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof ObjectsDataUpdateEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
for (const object of parser.objects) for(const object of parser.objects)
{ {
this._roomCreator.updateRoomObjectFloor(this._currentRoomId, object.id, null, null, object.state, object.data); this._roomCreator.updateRoomObjectFloor(this._currentRoomId, object.id, null, null, object.state, object.data);
} }
@ -432,7 +432,7 @@ export class RoomMessageHandler extends Disposable
private onFurnitureAliasesEvent(event: FurnitureAliasesEvent): void private onFurnitureAliasesEvent(event: FurnitureAliasesEvent): void
{ {
if (!(event instanceof FurnitureAliasesEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureAliasesEvent) || !event.connection || !this._roomCreator) return;
const alises = event.getParser().aliases; const alises = event.getParser().aliases;
@ -441,32 +441,32 @@ export class RoomMessageHandler extends Disposable
private onFurnitureFloorAddEvent(event: FurnitureFloorAddEvent): void private onFurnitureFloorAddEvent(event: FurnitureFloorAddEvent): void
{ {
if (!(event instanceof FurnitureFloorAddEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureFloorAddEvent) || !event.connection || !this._roomCreator) return;
const item = event.getParser().item; const item = event.getParser().item;
if (!item) return; if(!item) return;
this.addRoomObjectFurnitureFloor(this._currentRoomId, item); this.addRoomObjectFurnitureFloor(this._currentRoomId, item);
} }
private onFurnitureFloorEvent(event: FurnitureFloorEvent): void private onFurnitureFloorEvent(event: FurnitureFloorEvent): void
{ {
if (!(event instanceof FurnitureFloorEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureFloorEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const totalObjects = parser.items.length; const totalObjects = parser.items.length;
let iterator = 0; let iterator = 0;
while (iterator < totalObjects) while(iterator < totalObjects)
{ {
const object = parser.items[iterator]; const object = parser.items[iterator];
if (object) this.addRoomObjectFurnitureFloor(this._currentRoomId, object); if(object) this.addRoomObjectFurnitureFloor(this._currentRoomId, object);
iterator++; iterator++;
} }
@ -474,13 +474,13 @@ export class RoomMessageHandler extends Disposable
private onFurnitureFloorRemoveEvent(event: FurnitureFloorRemoveEvent): void private onFurnitureFloorRemoveEvent(event: FurnitureFloorRemoveEvent): void
{ {
if (!(event instanceof FurnitureFloorRemoveEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureFloorRemoveEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
if (parser.delay > 0) if(parser.delay > 0)
{ {
setTimeout(() => setTimeout(() =>
{ {
@ -495,11 +495,11 @@ export class RoomMessageHandler extends Disposable
private onFurnitureFloorUpdateEvent(event: FurnitureFloorUpdateEvent): void private onFurnitureFloorUpdateEvent(event: FurnitureFloorUpdateEvent): void
{ {
if (!(event instanceof FurnitureFloorUpdateEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureFloorUpdateEvent) || !event.connection || !this._roomCreator) return;
const item = event.getParser().item; const item = event.getParser().item;
if (!item) return; if(!item) return;
const location: IVector3D = new Vector3d(item.x, item.y, item.z); const location: IVector3D = new Vector3d(item.x, item.y, item.z);
const direction: IVector3D = new Vector3d(item.direction); const direction: IVector3D = new Vector3d(item.direction);
@ -511,32 +511,32 @@ export class RoomMessageHandler extends Disposable
private onFurnitureWallAddEvent(event: FurnitureWallAddEvent): void private onFurnitureWallAddEvent(event: FurnitureWallAddEvent): void
{ {
if (!(event instanceof FurnitureWallAddEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureWallAddEvent) || !event.connection || !this._roomCreator) return;
const data = event.getParser().item; const data = event.getParser().item;
if (!data) return; if(!data) return;
this.addRoomObjectFurnitureWall(this._currentRoomId, data); this.addRoomObjectFurnitureWall(this._currentRoomId, data);
} }
private onFurnitureWallEvent(event: FurnitureWallEvent): void private onFurnitureWallEvent(event: FurnitureWallEvent): void
{ {
if (!(event instanceof FurnitureWallEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureWallEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const totalObjects = parser.items.length; const totalObjects = parser.items.length;
let iterator = 0; let iterator = 0;
while (iterator < totalObjects) while(iterator < totalObjects)
{ {
const data = parser.items[iterator]; const data = parser.items[iterator];
if (data) this.addRoomObjectFurnitureWall(this._currentRoomId, data); if(data) this.addRoomObjectFurnitureWall(this._currentRoomId, data);
iterator++; iterator++;
} }
@ -544,26 +544,26 @@ export class RoomMessageHandler extends Disposable
private onFurnitureWallRemoveEvent(event: FurnitureWallRemoveEvent): void private onFurnitureWallRemoveEvent(event: FurnitureWallRemoveEvent): void
{ {
if (!(event instanceof FurnitureWallRemoveEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureWallRemoveEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._roomCreator.removeRoomObjectWall(this._currentRoomId, parser.itemId, parser.userId); this._roomCreator.removeRoomObjectWall(this._currentRoomId, parser.itemId, parser.userId);
} }
private onFurnitureWallUpdateEvent(event: FurnitureWallUpdateEvent): void private onFurnitureWallUpdateEvent(event: FurnitureWallUpdateEvent): void
{ {
if (!(event instanceof FurnitureWallUpdateEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureWallUpdateEvent) || !event.connection || !this._roomCreator) return;
const wallGeometry = this._roomCreator.getLegacyWallGeometry(this._currentRoomId); const wallGeometry = this._roomCreator.getLegacyWallGeometry(this._currentRoomId);
if (!wallGeometry) return; if(!wallGeometry) return;
const item = event.getParser().item; const item = event.getParser().item;
if (!item) return; if(!item) return;
const location = wallGeometry.getLocation(item.width, item.height, item.localX, item.localY, item.direction); const location = wallGeometry.getLocation(item.width, item.height, item.localX, item.localY, item.direction);
const direction = new Vector3d(wallGeometry.getDirection(item.direction)); const direction = new Vector3d(wallGeometry.getDirection(item.direction));
@ -574,7 +574,7 @@ export class RoomMessageHandler extends Disposable
private onFurnitureDataEvent(event: FurnitureDataEvent): void private onFurnitureDataEvent(event: FurnitureDataEvent): void
{ {
if (!(event instanceof FurnitureDataEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof FurnitureDataEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
@ -583,7 +583,7 @@ export class RoomMessageHandler extends Disposable
private onItemDataUpdateMessageEvent(event: ItemDataUpdateMessageEvent): void private onItemDataUpdateMessageEvent(event: ItemDataUpdateMessageEvent): void
{ {
if (!(event instanceof ItemDataUpdateMessageEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof ItemDataUpdateMessageEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
@ -592,7 +592,7 @@ export class RoomMessageHandler extends Disposable
private onOneWayDoorStatusMessageEvent(event: OneWayDoorStatusMessageEvent): void private onOneWayDoorStatusMessageEvent(event: OneWayDoorStatusMessageEvent): void
{ {
if (!(event instanceof OneWayDoorStatusMessageEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof OneWayDoorStatusMessageEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
@ -601,7 +601,7 @@ export class RoomMessageHandler extends Disposable
private onDiceValueMessageEvent(event: DiceValueMessageEvent): void private onDiceValueMessageEvent(event: DiceValueMessageEvent): void
{ {
if (!(event instanceof DiceValueMessageEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof DiceValueMessageEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
@ -610,36 +610,36 @@ export class RoomMessageHandler extends Disposable
private onRoomUnitDanceEvent(event: RoomUnitDanceEvent): void private onRoomUnitDanceEvent(event: RoomUnitDanceEvent): void
{ {
if (!(event instanceof RoomUnitDanceEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitDanceEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_DANCE, event.getParser().danceId); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_DANCE, event.getParser().danceId);
} }
private onRoomUnitEffectEvent(event: RoomUnitEffectEvent): void private onRoomUnitEffectEvent(event: RoomUnitEffectEvent): void
{ {
if (!(event instanceof RoomUnitEffectEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitEffectEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.updateRoomObjectUserEffect(this._currentRoomId, event.getParser().unitId, event.getParser().effectId, event.getParser().delay); this._roomCreator.updateRoomObjectUserEffect(this._currentRoomId, event.getParser().unitId, event.getParser().effectId, event.getParser().delay);
} }
private onRoomUnitEvent(event: RoomUnitEvent): void private onRoomUnitEvent(event: RoomUnitEvent): void
{ {
if (!(event instanceof RoomUnitEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitEvent) || !event.connection || !this._roomCreator) return;
const users = event.getParser().users; const users = event.getParser().users;
if (!users || !users.length) return; if(!users || !users.length) return;
for (const user of users) for(const user of users)
{ {
if (!user) continue; if(!user) continue;
const location = new Vector3d(user.x, user.y, user.z); const location = new Vector3d(user.x, user.y, user.z);
const direction = new Vector3d(user.dir); const direction = new Vector3d(user.dir);
this._roomCreator.addRoomObjectUser(this._currentRoomId, user.roomIndex, location, direction, user.dir, user.userType, user.figure); this._roomCreator.addRoomObjectUser(this._currentRoomId, user.roomIndex, location, direction, user.dir, user.userType, user.figure);
if (user.webID === this._ownUserId) if(user.webID === this._ownUserId)
{ {
this._roomCreator.setRoomSessionOwnUser(this._currentRoomId, user.roomIndex); this._roomCreator.setRoomSessionOwnUser(this._currentRoomId, user.roomIndex);
this._roomCreator.updateRoomObjectUserOwn(this._currentRoomId, user.roomIndex); this._roomCreator.updateRoomObjectUserOwn(this._currentRoomId, user.roomIndex);
@ -647,9 +647,9 @@ export class RoomMessageHandler extends Disposable
this._roomCreator.updateRoomObjectUserFigure(this._currentRoomId, user.roomIndex, user.figure, user.sex, user.subType, user.isRiding); this._roomCreator.updateRoomObjectUserFigure(this._currentRoomId, user.roomIndex, user.figure, user.sex, user.subType, user.isRiding);
if (RoomObjectUserType.getTypeString(user.userType) === RoomObjectUserType.PET) if(RoomObjectUserType.getTypeString(user.userType) === RoomObjectUserType.PET)
{ {
if (this._roomCreator.getPetTypeId(user.figure) === PetType.MONSTERPLANT) if(this._roomCreator.getPetTypeId(user.figure) === PetType.MONSTERPLANT)
{ {
this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, user.roomIndex, user.petPosture); this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, user.roomIndex, user.petPosture);
} }
@ -663,46 +663,46 @@ export class RoomMessageHandler extends Disposable
private onRoomUnitExpressionEvent(event: RoomUnitExpressionEvent): void private onRoomUnitExpressionEvent(event: RoomUnitExpressionEvent): void
{ {
if (!(event instanceof RoomUnitExpressionEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitExpressionEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_EXPRESSION, event.getParser().expression); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_EXPRESSION, event.getParser().expression);
} }
private onRoomUnitHandItemEvent(event: RoomUnitHandItemEvent): void private onRoomUnitHandItemEvent(event: RoomUnitHandItemEvent): void
{ {
if (!(event instanceof RoomUnitHandItemEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitHandItemEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_CARRY_OBJECT, event.getParser().handId); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_CARRY_OBJECT, event.getParser().handId);
} }
private onRoomUnitIdleEvent(event: RoomUnitIdleEvent): void private onRoomUnitIdleEvent(event: RoomUnitIdleEvent): void
{ {
if (!(event instanceof RoomUnitIdleEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitIdleEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_SLEEP, (event.getParser().isIdle ? 1 : 0)); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_SLEEP, (event.getParser().isIdle ? 1 : 0));
} }
private onRoomUnitInfoEvent(event: RoomUnitInfoEvent): void private onRoomUnitInfoEvent(event: RoomUnitInfoEvent): void
{ {
if (!(event instanceof RoomUnitInfoEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitInfoEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.updateRoomObjectUserFigure(this._currentRoomId, event.getParser().unitId, event.getParser().figure, event.getParser().gender); this._roomCreator.updateRoomObjectUserFigure(this._currentRoomId, event.getParser().unitId, event.getParser().figure, event.getParser().gender);
} }
private onRoomUnitNumberEvent(event: RoomUnitNumberEvent): void private onRoomUnitNumberEvent(event: RoomUnitNumberEvent): void
{ {
if (!(event instanceof RoomUnitNumberEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitNumberEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, parser.unitId, RoomObjectVariable.FIGURE_NUMBER_VALUE, parser.value); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, parser.unitId, RoomObjectVariable.FIGURE_NUMBER_VALUE, parser.value);
} }
private onRoomUnitRemoveEvent(event: RoomUnitRemoveEvent): void private onRoomUnitRemoveEvent(event: RoomUnitRemoveEvent): void
{ {
if (!(event instanceof RoomUnitRemoveEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitRemoveEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.removeRoomObjectUser(this._currentRoomId, event.getParser().unitId); this._roomCreator.removeRoomObjectUser(this._currentRoomId, event.getParser().unitId);
@ -711,32 +711,32 @@ export class RoomMessageHandler extends Disposable
private onRoomUnitStatusEvent(event: RoomUnitStatusEvent): void private onRoomUnitStatusEvent(event: RoomUnitStatusEvent): void
{ {
if (!(event instanceof RoomUnitStatusEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitStatusEvent) || !event.connection || !this._roomCreator) return;
const statuses = event.getParser().statuses; const statuses = event.getParser().statuses;
if (!statuses || !statuses.length) return; if(!statuses || !statuses.length) return;
const roomInstance = this._roomCreator.getRoomInstance(this._currentRoomId); const roomInstance = this._roomCreator.getRoomInstance(this._currentRoomId);
if (!roomInstance) return; if(!roomInstance) return;
const zScale = (roomInstance.model.getValue<number>(RoomVariableEnum.ROOM_Z_SCALE) || 1); const zScale = (roomInstance.model.getValue<number>(RoomVariableEnum.ROOM_Z_SCALE) || 1);
for (const status of statuses) for(const status of statuses)
{ {
if (!status) continue; if(!status) continue;
let height = status.height; let height = status.height;
if (height) height = (height / zScale); if(height) height = (height / zScale);
const location = new Vector3d(status.x, status.y, (status.z + height)); const location = new Vector3d(status.x, status.y, (status.z + height));
const direction = new Vector3d(status.direction); const direction = new Vector3d(status.direction);
let goal: IVector3D = null; let goal: IVector3D = null;
if (status.didMove) goal = new Vector3d(status.targetX, status.targetY, status.targetZ); if(status.didMove) goal = new Vector3d(status.targetX, status.targetY, status.targetZ);
this._roomCreator.updateRoomObjectUserLocation(this._currentRoomId, status.id, location, goal, status.canStandUp, height, direction, status.headDirection); this._roomCreator.updateRoomObjectUserLocation(this._currentRoomId, status.id, location, goal, status.canStandUp, height, direction, status.headDirection);
this._roomCreator.updateRoomObjectUserFlatControl(this._currentRoomId, status.id, null); this._roomCreator.updateRoomObjectUserFlatControl(this._currentRoomId, status.id, null);
@ -746,24 +746,24 @@ export class RoomMessageHandler extends Disposable
let postureType = RoomObjectVariable.STD; let postureType = RoomObjectVariable.STD;
let parameter = ''; let parameter = '';
if (status.actions && status.actions.length) if(status.actions && status.actions.length)
{ {
for (const action of status.actions) for(const action of status.actions)
{ {
if (!action) continue; if(!action) continue;
switch (action.action) switch(action.action)
{ {
case 'flatctrl': case 'flatctrl':
this._roomCreator.updateRoomObjectUserFlatControl(this._currentRoomId, status.id, action.value); this._roomCreator.updateRoomObjectUserFlatControl(this._currentRoomId, status.id, action.value);
break; break;
case 'sign': case 'sign':
if (status.actions.length === 1) isPosture = false; if(status.actions.length === 1) isPosture = false;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, status.id, RoomObjectVariable.FIGURE_SIGN, parseInt(action.value)); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, status.id, RoomObjectVariable.FIGURE_SIGN, parseInt(action.value));
break; break;
case 'gst': case 'gst':
if (status.actions.length === 1) isPosture = false; if(status.actions.length === 1) isPosture = false;
this._roomCreator.updateRoomObjectUserPetGesture(this._currentRoomId, status.id, action.value); this._roomCreator.updateRoomObjectUserPetGesture(this._currentRoomId, status.id, action.value);
break; break;
@ -783,8 +783,8 @@ export class RoomMessageHandler extends Disposable
} }
} }
if (postureUpdate) this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, status.id, postureType, parameter); if(postureUpdate) this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, status.id, postureType, parameter);
else if (isPosture) this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, status.id, RoomObjectVariable.STD, ''); else if(isPosture) this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, status.id, RoomObjectVariable.STD, '');
} }
this.updateGuideMarker(); this.updateGuideMarker();
@ -792,11 +792,11 @@ export class RoomMessageHandler extends Disposable
private onRoomUnitChatEvent(event: RoomUnitChatEvent): void private onRoomUnitChatEvent(event: RoomUnitChatEvent): void
{ {
if (!event.connection || !this._roomCreator) return; if(!event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._roomCreator.updateRoomObjectUserGesture(this._currentRoomId, parser.roomIndex, parser.gesture); this._roomCreator.updateRoomObjectUserGesture(this._currentRoomId, parser.roomIndex, parser.gesture);
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, parser.roomIndex, RoomObjectVariable.FIGURE_TALK, (parser.message.length / 10)); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, parser.roomIndex, RoomObjectVariable.FIGURE_TALK, (parser.message.length / 10));
@ -804,18 +804,18 @@ export class RoomMessageHandler extends Disposable
private onRoomUnitTypingEvent(event: RoomUnitTypingEvent): void private onRoomUnitTypingEvent(event: RoomUnitTypingEvent): void
{ {
if (!(event instanceof RoomUnitTypingEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof RoomUnitTypingEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_IS_TYPING, event.getParser().isTyping ? 1 : 0); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, event.getParser().unitId, RoomObjectVariable.FIGURE_IS_TYPING, event.getParser().isTyping ? 1 : 0);
} }
private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void
{ {
if (!(event instanceof PetFigureUpdateEvent) || !event.connection || !this._roomCreator) return; if(!(event instanceof PetFigureUpdateEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._roomCreator.updateRoomObjectUserFigure(this._currentRoomId, parser.roomIndex, parser.figureData.figuredata, '', '', parser.isRiding); this._roomCreator.updateRoomObjectUserFigure(this._currentRoomId, parser.roomIndex, parser.figureData.figuredata, '', '', parser.isRiding);
} }
@ -824,30 +824,30 @@ export class RoomMessageHandler extends Disposable
{ {
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, parser.roomIndex, RoomObjectVariable.FIGURE_GAINED_EXPERIENCE, parser.gainedExperience); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, parser.roomIndex, RoomObjectVariable.FIGURE_GAINED_EXPERIENCE, parser.gainedExperience);
} }
private onYouArePlayingGameEvent(event: YouArePlayingGameEvent): void private onYouArePlayingGameEvent(event: YouArePlayingGameEvent): void
{ {
if (!event) return; if(!event) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
this._roomCreator.setRoomEngineGameMode(this._currentRoomId, parser.isPlaying); this._roomCreator.setRoomEngineGameMode(this._currentRoomId, parser.isPlaying);
} }
private addRoomObjectFurnitureFloor(roomId: number, data: FurnitureFloorDataParser): void private addRoomObjectFurnitureFloor(roomId: number, data: FurnitureFloorDataParser): void
{ {
if (!data || !this._roomCreator) return; if(!data || !this._roomCreator) return;
const location = new Vector3d(data.x, data.y, data.z); const location = new Vector3d(data.x, data.y, data.z);
const direction = new Vector3d(data.direction); const direction = new Vector3d(data.direction);
if (data.spriteName) if(data.spriteName)
{ {
this._roomCreator.addFurnitureFloorByTypeName(roomId, data.itemId, data.spriteName, location, direction, data.state, data.data, data.extra, data.expires, data.usagePolicy, data.userId, data.username, true, true, data.stackHeight); this._roomCreator.addFurnitureFloorByTypeName(roomId, data.itemId, data.spriteName, location, direction, data.state, data.data, data.extra, data.expires, data.usagePolicy, data.userId, data.username, true, true, data.stackHeight);
} }
@ -859,15 +859,15 @@ export class RoomMessageHandler extends Disposable
private addRoomObjectFurnitureWall(roomId: number, data: FurnitureWallDataParser): void private addRoomObjectFurnitureWall(roomId: number, data: FurnitureWallDataParser): void
{ {
if (!data || !this._roomCreator) return; if(!data || !this._roomCreator) return;
const wallGeometry = this._roomCreator.getLegacyWallGeometry(roomId); const wallGeometry = this._roomCreator.getLegacyWallGeometry(roomId);
if (!wallGeometry) return; if(!wallGeometry) return;
let location: IVector3D = null; let location: IVector3D = null;
if (!data.isOldFormat) if(!data.isOldFormat)
{ {
location = wallGeometry.getLocation(data.width, data.height, data.localX, data.localY, data.direction); location = wallGeometry.getLocation(data.width, data.height, data.localX, data.localY, data.direction);
} }
@ -883,21 +883,21 @@ export class RoomMessageHandler extends Disposable
private onIgnoreResultEvent(event: IgnoreResultEvent): void private onIgnoreResultEvent(event: IgnoreResultEvent): void
{ {
if (!event) return; if(!event) return;
const parser = event.getParser(); const parser = event.getParser();
if (!parser) return; if(!parser) return;
const roomSession = this._roomCreator.roomSessionManager.getSession(this._currentRoomId); const roomSession = this._roomCreator.roomSessionManager.getSession(this._currentRoomId);
if (!roomSession) return; if(!roomSession) return;
const userData = roomSession.userDataManager.getUserDataByName(parser.name); const userData = roomSession.userDataManager.getUserDataByName(parser.name);
if (!userData) return; if(!userData) return;
switch (parser.result) switch(parser.result)
{ {
case 1: case 1:
case 2: case 2:
@ -948,15 +948,15 @@ export class RoomMessageHandler extends Disposable
private setUserGuideStatus(userId: number, status: number): void private setUserGuideStatus(userId: number, status: number): void
{ {
if (!this._roomCreator || !this._roomCreator.roomSessionManager) return; if(!this._roomCreator || !this._roomCreator.roomSessionManager) return;
const roomSession = this._roomCreator.roomSessionManager.getSession(this._currentRoomId); const roomSession = this._roomCreator.roomSessionManager.getSession(this._currentRoomId);
if (!roomSession) return; if(!roomSession) return;
const userData = roomSession.userDataManager.getDataByType(userId, RoomObjectType.USER); const userData = roomSession.userDataManager.getDataByType(userId, RoomObjectType.USER);
if (!userData) return; if(!userData) return;
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, userData.roomIndex, RoomObjectVariable.FIGURE_GUIDE_STATUS, status); this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, userData.roomIndex, RoomObjectVariable.FIGURE_GUIDE_STATUS, status);
} }

File diff suppressed because it is too large Load Diff

View File

@ -24,23 +24,23 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
{ {
const logic = this.getLogicType(type); const logic = this.getLogicType(type);
if (!logic) return null; if(!logic) return null;
const instance = (new logic() as IRoomObjectEventHandler); const instance = (new logic() as IRoomObjectEventHandler);
if (!instance) return null; if(!instance) return null;
instance.eventDispatcher = this._events; instance.eventDispatcher = this._events;
if (!this._cachedEvents.get(type)) if(!this._cachedEvents.get(type))
{ {
this._cachedEvents.set(type, true); this._cachedEvents.set(type, true);
const eventTypes = instance.getEventTypes(); const eventTypes = instance.getEventTypes();
for (const eventType of eventTypes) for(const eventType of eventTypes)
{ {
if (!eventType) continue; if(!eventType) continue;
this.registerEventType(eventType); this.registerEventType(eventType);
} }
@ -51,13 +51,13 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
private registerEventType(type: string): void private registerEventType(type: string): void
{ {
if (this._registeredEvents.get(type)) return; if(this._registeredEvents.get(type)) return;
this._registeredEvents.set(type, true); 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); this._events.addEventListener(type, func);
} }
@ -65,15 +65,15 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public registerEventFunction(func: Function): void 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); 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); this._events.addEventListener(eventType, func);
} }
@ -81,17 +81,17 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public removeEventFunction(func: Function): void public removeEventFunction(func: Function): void
{ {
if (!func) return; if(!func) return;
const index = this._functions.indexOf(func); const index = this._functions.indexOf(func);
if (index === -1) return; if(index === -1) return;
this._functions.splice(index, 1); 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); this._events.removeEventListener(event, func);
} }
@ -99,11 +99,11 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
public getLogicType(type: string): typeof RoomObjectLogicBase public getLogicType(type: string): typeof RoomObjectLogicBase
{ {
if (!type) return null; if(!type) return null;
let logic: typeof RoomObjectLogicBase = null; let logic: typeof RoomObjectLogicBase = null;
switch (type) switch(type)
{ {
case RoomObjectLogicType.ROOM: case RoomObjectLogicType.ROOM:
logic = RoomLogic; logic = RoomLogic;
@ -307,7 +307,7 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
break; break;
} }
if (!logic) if(!logic)
{ {
NitroLogger.warn('Unknown Logic', type); NitroLogger.warn('Unknown Logic', type);

View File

@ -18,18 +18,18 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
{ {
const visualization = this.getVisualizationType(type); const visualization = this.getVisualizationType(type);
if (!visualization) return null; if(!visualization) return null;
return new visualization(); return new visualization();
} }
public getVisualizationType(type: string): typeof RoomObjectSpriteVisualization public getVisualizationType(type: string): typeof RoomObjectSpriteVisualization
{ {
if (!type) return null; if(!type) return null;
let visualization: typeof RoomObjectSpriteVisualization = null; let visualization: typeof RoomObjectSpriteVisualization = null;
switch (type) switch(type)
{ {
case RoomObjectVisualizationType.ROOM: case RoomObjectVisualizationType.ROOM:
visualization = RoomVisualization; visualization = RoomVisualization;
@ -140,7 +140,7 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
break; break;
} }
if (!visualization) if(!visualization)
{ {
NitroLogger.log('Unknown Visualization', type); NitroLogger.log('Unknown Visualization', type);
@ -154,11 +154,11 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
{ {
const existing = this._visualizationDatas.get(type); const existing = this._visualizationDatas.get(type);
if (existing) return existing; if(existing) return existing;
let visualizationData: IObjectVisualizationData = null; let visualizationData: IObjectVisualizationData = null;
switch (visualization) switch(visualization)
{ {
case RoomObjectVisualizationType.FURNITURE_STATIC: case RoomObjectVisualizationType.FURNITURE_STATIC:
case RoomObjectVisualizationType.FURNITURE_GIFT_WRAPPED: case RoomObjectVisualizationType.FURNITURE_GIFT_WRAPPED:
@ -210,21 +210,21 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
break; break;
} }
if (!visualizationData) return null; if(!visualizationData) return null;
if (!visualizationData.initialize(asset)) if(!visualizationData.initialize(asset))
{ {
visualizationData.dispose(); visualizationData.dispose();
return null; return null;
} }
if ((visualizationData instanceof AvatarVisualizationData) || (visualizationData instanceof FurnitureMannequinVisualizationData)) if((visualizationData instanceof AvatarVisualizationData) || (visualizationData instanceof FurnitureMannequinVisualizationData))
{ {
visualizationData.avatarManager = Nitro.instance.avatar; 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; return visualizationData;
} }

View File

@ -64,9 +64,9 @@ export class AvatarLogic extends MovingObjectLogic
public dispose(): void public dispose(): void
{ {
if (this._selected && this.object) if(this._selected && this.object)
{ {
if (this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectMoveEvent(RoomObjectMoveEvent.OBJECT_REMOVED, this.object)); if(this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectMoveEvent(RoomObjectMoveEvent.OBJECT_REMOVED, this.object));
} }
super.dispose(); super.dispose();
@ -78,15 +78,15 @@ export class AvatarLogic extends MovingObjectLogic
{ {
super.update(time); super.update(time);
if (this._selected && this.object) if(this._selected && this.object)
{ {
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
const location = this.object.getLocation(); const location = this.object.getLocation();
if (((!this._reportedLocation || (this._reportedLocation.x !== location.x)) || (this._reportedLocation.y !== location.y)) || (this._reportedLocation.z !== location.z)) if(((!this._reportedLocation || (this._reportedLocation.x !== location.x)) || (this._reportedLocation.y !== location.y)) || (this._reportedLocation.z !== location.z))
{ {
if (!this._reportedLocation) this._reportedLocation = new Vector3d(); if(!this._reportedLocation) this._reportedLocation = new Vector3d();
this._reportedLocation.assign(location); this._reportedLocation.assign(location);
@ -97,14 +97,14 @@ export class AvatarLogic extends MovingObjectLogic
const model = this.object && this.object.model; const model = this.object && this.object.model;
if (model) this.updateModel(this.time, model); if(model) this.updateModel(this.time, model);
} }
private updateModel(time: number, model: IRoomObjectModel): void private updateModel(time: number, model: IRoomObjectModel): void
{ {
if (this._talkingEndTimestamp > 0) if(this._talkingEndTimestamp > 0)
{ {
if (time > this._talkingEndTimestamp) if(time > this._talkingEndTimestamp)
{ {
model.setValue(RoomObjectVariable.FIGURE_TALK, 0); model.setValue(RoomObjectVariable.FIGURE_TALK, 0);
@ -114,14 +114,14 @@ export class AvatarLogic extends MovingObjectLogic
} }
else else
{ {
if (!this._talkingPauseEndTimestamp && !this._talkingPauseStartTimestamp) if(!this._talkingPauseEndTimestamp && !this._talkingPauseStartTimestamp)
{ {
this._talkingPauseStartTimestamp = time + this.randomTalkingPauseStartTimestamp(); this._talkingPauseStartTimestamp = time + this.randomTalkingPauseStartTimestamp();
this._talkingPauseEndTimestamp = this._talkingPauseStartTimestamp + this.randomTalkingPauseEndTimestamp(); this._talkingPauseEndTimestamp = this._talkingPauseStartTimestamp + this.randomTalkingPauseEndTimestamp();
} }
else else
{ {
if ((this._talkingPauseStartTimestamp > 0) && (time > this._talkingPauseStartTimestamp)) if((this._talkingPauseStartTimestamp > 0) && (time > this._talkingPauseStartTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_TALK, 0); model.setValue(RoomObjectVariable.FIGURE_TALK, 0);
@ -129,7 +129,7 @@ export class AvatarLogic extends MovingObjectLogic
} }
else else
{ {
if ((this._talkingPauseEndTimestamp > 0) && (time > this._talkingPauseEndTimestamp)) if((this._talkingPauseEndTimestamp > 0) && (time > this._talkingPauseEndTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_TALK, 1); model.setValue(RoomObjectVariable.FIGURE_TALK, 1);
@ -140,30 +140,30 @@ export class AvatarLogic extends MovingObjectLogic
} }
} }
if ((this._animationEndTimestamp > 0) && (time > this._animationEndTimestamp)) if((this._animationEndTimestamp > 0) && (time > this._animationEndTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_EXPRESSION, 0); model.setValue(RoomObjectVariable.FIGURE_EXPRESSION, 0);
this._animationEndTimestamp = 0; this._animationEndTimestamp = 0;
} }
if ((this._gestureEndTimestamp > 0) && (time > this._gestureEndTimestamp)) if((this._gestureEndTimestamp > 0) && (time > this._gestureEndTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_GESTURE, 0); model.setValue(RoomObjectVariable.FIGURE_GESTURE, 0);
this._gestureEndTimestamp = 0; this._gestureEndTimestamp = 0;
} }
if ((this._signEndTimestamp > 0) && (time > this._signEndTimestamp)) if((this._signEndTimestamp > 0) && (time > this._signEndTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_SIGN, -1); model.setValue(RoomObjectVariable.FIGURE_SIGN, -1);
this._signEndTimestamp = 0; this._signEndTimestamp = 0;
} }
if (this._carryObjectEndTimestamp > 0) if(this._carryObjectEndTimestamp > 0)
{ {
if (time > this._carryObjectEndTimestamp) if(time > this._carryObjectEndTimestamp)
{ {
model.setValue(RoomObjectVariable.FIGURE_CARRY_OBJECT, 0); model.setValue(RoomObjectVariable.FIGURE_CARRY_OBJECT, 0);
model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, 0); model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, 0);
@ -174,11 +174,11 @@ export class AvatarLogic extends MovingObjectLogic
} }
} }
if (this._allowUseCarryObject) if(this._allowUseCarryObject)
{ {
if ((time - this._carryObjectStartTimestamp) > 5000) if((time - this._carryObjectStartTimestamp) > 5000)
{ {
if (((time - this._carryObjectStartTimestamp) % 10000) < 1000) if(((time - this._carryObjectStartTimestamp) % 10000) < 1000)
{ {
model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, 1); model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, 1);
} }
@ -189,7 +189,7 @@ export class AvatarLogic extends MovingObjectLogic
} }
} }
if ((this._blinkingStartTimestamp > -1) && (time > this._blinkingStartTimestamp)) if((this._blinkingStartTimestamp > -1) && (time > this._blinkingStartTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_BLINK, 1); model.setValue(RoomObjectVariable.FIGURE_BLINK, 1);
@ -197,21 +197,21 @@ export class AvatarLogic extends MovingObjectLogic
this._blinkingEndTimestamp = time + this.randomBlinkEndTimestamp(); this._blinkingEndTimestamp = time + this.randomBlinkEndTimestamp();
} }
if ((this._blinkingEndTimestamp > 0) && (time > this._blinkingEndTimestamp)) if((this._blinkingEndTimestamp > 0) && (time > this._blinkingEndTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_BLINK, 0); model.setValue(RoomObjectVariable.FIGURE_BLINK, 0);
this._blinkingEndTimestamp = 0; this._blinkingEndTimestamp = 0;
} }
if ((this._effectChangeTimeStamp > 0) && (time > this._effectChangeTimeStamp)) if((this._effectChangeTimeStamp > 0) && (time > this._effectChangeTimeStamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_EFFECT, this._newEffect); model.setValue(RoomObjectVariable.FIGURE_EFFECT, this._newEffect);
this._effectChangeTimeStamp = 0; this._effectChangeTimeStamp = 0;
} }
if ((this._numberValueEndTimestamp > 0) && (time > this._numberValueEndTimestamp)) if((this._numberValueEndTimestamp > 0) && (time > this._numberValueEndTimestamp))
{ {
model.setValue(RoomObjectVariable.FIGURE_NUMBER_VALUE, 0); model.setValue(RoomObjectVariable.FIGURE_NUMBER_VALUE, 0);
@ -221,15 +221,15 @@ export class AvatarLogic extends MovingObjectLogic
public processUpdateMessage(message: RoomObjectUpdateMessage): void public processUpdateMessage(message: RoomObjectUpdateMessage): void
{ {
if (!message || !this.object) return; if(!message || !this.object) return;
super.processUpdateMessage(message); super.processUpdateMessage(message);
const model = this.object && this.object.model; const model = this.object && this.object.model;
if (!model) return; if(!model) return;
if (message instanceof ObjectAvatarPostureUpdateMessage) if(message instanceof ObjectAvatarPostureUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_POSTURE, message.postureType); model.setValue(RoomObjectVariable.FIGURE_POSTURE, message.postureType);
model.setValue(RoomObjectVariable.FIGURE_POSTURE_PARAMETER, message.parameter); model.setValue(RoomObjectVariable.FIGURE_POSTURE_PARAMETER, message.parameter);
@ -237,7 +237,7 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarChatUpdateMessage) if(message instanceof ObjectAvatarChatUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_TALK, 1); model.setValue(RoomObjectVariable.FIGURE_TALK, 1);
@ -246,28 +246,28 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarTypingUpdateMessage) if(message instanceof ObjectAvatarTypingUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_IS_TYPING, message.isTyping ? 1 : 0); model.setValue(RoomObjectVariable.FIGURE_IS_TYPING, message.isTyping ? 1 : 0);
return; return;
} }
if (message instanceof ObjectAvatarMutedUpdateMessage) if(message instanceof ObjectAvatarMutedUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_IS_MUTED, (message.isMuted ? 1 : 0)); model.setValue(RoomObjectVariable.FIGURE_IS_MUTED, (message.isMuted ? 1 : 0));
return; return;
} }
if (message instanceof ObjectAvatarPlayingGameUpdateMessage) if(message instanceof ObjectAvatarPlayingGameUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_IS_PLAYING_GAME, (message.isPlayingGame ? 1 : 0)); model.setValue(RoomObjectVariable.FIGURE_IS_PLAYING_GAME, (message.isPlayingGame ? 1 : 0));
return; return;
} }
if (message instanceof ObjectAvatarUpdateMessage) if(message instanceof ObjectAvatarUpdateMessage)
{ {
model.setValue(RoomObjectVariable.HEAD_DIRECTION, message.headDirection); model.setValue(RoomObjectVariable.HEAD_DIRECTION, message.headDirection);
model.setValue(RoomObjectVariable.FIGURE_CAN_STAND_UP, message.canStandUp); model.setValue(RoomObjectVariable.FIGURE_CAN_STAND_UP, message.canStandUp);
@ -276,7 +276,7 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarGestureUpdateMessage) if(message instanceof ObjectAvatarGestureUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_GESTURE, message.gesture); model.setValue(RoomObjectVariable.FIGURE_GESTURE, message.gesture);
@ -285,35 +285,35 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarExpressionUpdateMessage) if(message instanceof ObjectAvatarExpressionUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_EXPRESSION, message.expressionType); model.setValue(RoomObjectVariable.FIGURE_EXPRESSION, message.expressionType);
this._animationEndTimestamp = AvatarAction.getExpressionTimeout(model.getValue<number>(RoomObjectVariable.FIGURE_EXPRESSION)); this._animationEndTimestamp = AvatarAction.getExpressionTimeout(model.getValue<number>(RoomObjectVariable.FIGURE_EXPRESSION));
if (this._animationEndTimestamp > -1) this._animationEndTimestamp += this.time; if(this._animationEndTimestamp > -1) this._animationEndTimestamp += this.time;
return; return;
} }
if (message instanceof ObjectAvatarDanceUpdateMessage) if(message instanceof ObjectAvatarDanceUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_DANCE, message.danceStyle); model.setValue(RoomObjectVariable.FIGURE_DANCE, message.danceStyle);
return; return;
} }
if (message instanceof ObjectAvatarSleepUpdateMessage) if(message instanceof ObjectAvatarSleepUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_SLEEP, message.isSleeping ? 1 : 0); model.setValue(RoomObjectVariable.FIGURE_SLEEP, message.isSleeping ? 1 : 0);
if (message.isSleeping) this._blinkingStartTimestamp = -1; if(message.isSleeping) this._blinkingStartTimestamp = -1;
else this._blinkingStartTimestamp = (this.time + this.randomBlinkStartTimestamp()); else this._blinkingStartTimestamp = (this.time + this.randomBlinkStartTimestamp());
return; return;
} }
if (message instanceof ObjectAvatarPlayerValueUpdateMessage) if(message instanceof ObjectAvatarPlayerValueUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_NUMBER_VALUE, message.value); model.setValue(RoomObjectVariable.FIGURE_NUMBER_VALUE, message.value);
@ -322,19 +322,19 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarEffectUpdateMessage) if(message instanceof ObjectAvatarEffectUpdateMessage)
{ {
this.updateAvatarEffect(message.effect, message.delayMilliseconds, model); this.updateAvatarEffect(message.effect, message.delayMilliseconds, model);
return; return;
} }
if (message instanceof ObjectAvatarCarryObjectUpdateMessage) if(message instanceof ObjectAvatarCarryObjectUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_CARRY_OBJECT, message.itemType); model.setValue(RoomObjectVariable.FIGURE_CARRY_OBJECT, message.itemType);
model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, 0); model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, 0);
if (message.itemType === 0) if(message.itemType === 0)
{ {
this._carryObjectStartTimestamp = 0; this._carryObjectStartTimestamp = 0;
this._carryObjectEndTimestamp = 0; this._carryObjectEndTimestamp = 0;
@ -344,7 +344,7 @@ export class AvatarLogic extends MovingObjectLogic
{ {
this._carryObjectStartTimestamp = this.time; this._carryObjectStartTimestamp = this.time;
if (message.itemType < AvatarLogic.MAX_HAND_ID) if(message.itemType < AvatarLogic.MAX_HAND_ID)
{ {
this._carryObjectEndTimestamp = 0; this._carryObjectEndTimestamp = 0;
this._allowUseCarryObject = message.itemType <= AvatarLogic.MAX_HAND_USE_ID; this._allowUseCarryObject = message.itemType <= AvatarLogic.MAX_HAND_USE_ID;
@ -359,14 +359,14 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarUseObjectUpdateMessage) if(message instanceof ObjectAvatarUseObjectUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, message.itemType); model.setValue(RoomObjectVariable.FIGURE_USE_OBJECT, message.itemType);
return; return;
} }
if (message instanceof ObjectAvatarSignUpdateMessage) if(message instanceof ObjectAvatarSignUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_SIGN, message.signType); model.setValue(RoomObjectVariable.FIGURE_SIGN, message.signType);
@ -375,14 +375,14 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarFlatControlUpdateMessage) if(message instanceof ObjectAvatarFlatControlUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE_FLAT_CONTROL, message.level); model.setValue(RoomObjectVariable.FIGURE_FLAT_CONTROL, message.level);
return; return;
} }
if (message instanceof ObjectAvatarFigureUpdateMessage) if(message instanceof ObjectAvatarFigureUpdateMessage)
{ {
model.setValue(RoomObjectVariable.FIGURE, message.figure); model.setValue(RoomObjectVariable.FIGURE, message.figure);
model.setValue(RoomObjectVariable.GENDER, message.gender); model.setValue(RoomObjectVariable.GENDER, message.gender);
@ -390,7 +390,7 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarSelectedMessage) if(message instanceof ObjectAvatarSelectedMessage)
{ {
this._selected = message.selected; this._selected = message.selected;
this._reportedLocation = null; this._reportedLocation = null;
@ -398,7 +398,7 @@ export class AvatarLogic extends MovingObjectLogic
return; return;
} }
if (message instanceof ObjectAvatarOwnMessage) if(message instanceof ObjectAvatarOwnMessage)
{ {
model.setValue(RoomObjectVariable.OWN_USER, 1); model.setValue(RoomObjectVariable.OWN_USER, 1);
@ -408,19 +408,19 @@ export class AvatarLogic extends MovingObjectLogic
private updateAvatarEffect(effect: number, delay: number, model: IRoomObjectModel): void private updateAvatarEffect(effect: number, delay: number, model: IRoomObjectModel): void
{ {
if (effect === AvatarLogic.EFFECT_TYPE_SPLASH) if(effect === AvatarLogic.EFFECT_TYPE_SPLASH)
{ {
this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH); this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH);
this._newEffect = AvatarLogic.EFFECT_TYPE_SWIM; this._newEffect = AvatarLogic.EFFECT_TYPE_SWIM;
} }
else if (effect === AvatarLogic.EFFECT_TYPE_SPLASH_DARK) else if(effect === AvatarLogic.EFFECT_TYPE_SPLASH_DARK)
{ {
this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH); this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH);
this._newEffect = AvatarLogic.EFFECT_TYPE_SWIM_DARK; this._newEffect = AvatarLogic.EFFECT_TYPE_SWIM_DARK;
} }
else if (model.getValue<number>(RoomObjectVariable.FIGURE_EFFECT) === AvatarLogic.EFFECT_TYPE_SWIM) else if(model.getValue<number>(RoomObjectVariable.FIGURE_EFFECT) === AvatarLogic.EFFECT_TYPE_SWIM)
{ {
this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH); this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH);
this._newEffect = effect; this._newEffect = effect;
@ -428,7 +428,7 @@ export class AvatarLogic extends MovingObjectLogic
effect = AvatarLogic.EFFECT_TYPE_SPLASH; effect = AvatarLogic.EFFECT_TYPE_SPLASH;
} }
else if (model.getValue<number>(RoomObjectVariable.FIGURE_EFFECT) === AvatarLogic.EFFECT_TYPE_SWIM_DARK) else if(model.getValue<number>(RoomObjectVariable.FIGURE_EFFECT) === AvatarLogic.EFFECT_TYPE_SWIM_DARK)
{ {
this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH); this._effectChangeTimeStamp = (GetTickerTime() + AvatarLogic.EFFECT_SPLASH_LENGTH);
this._newEffect = effect; this._newEffect = effect;
@ -436,7 +436,7 @@ export class AvatarLogic extends MovingObjectLogic
effect = AvatarLogic.EFFECT_TYPE_SPLASH_DARK; effect = AvatarLogic.EFFECT_TYPE_SPLASH_DARK;
} }
else if (delay === 0) else if(delay === 0)
{ {
this._effectChangeTimeStamp = 0; this._effectChangeTimeStamp = 0;
} }
@ -456,7 +456,7 @@ export class AvatarLogic extends MovingObjectLogic
{ {
let eventType: string = null; let eventType: string = null;
switch (event.type) switch(event.type)
{ {
case MouseEventType.MOUSE_CLICK: case MouseEventType.MOUSE_CLICK:
eventType = RoomObjectMouseEvent.CLICK; eventType = RoomObjectMouseEvent.CLICK;
@ -464,20 +464,20 @@ export class AvatarLogic extends MovingObjectLogic
case MouseEventType.ROLL_OVER: case MouseEventType.ROLL_OVER:
eventType = RoomObjectMouseEvent.MOUSE_ENTER; eventType = RoomObjectMouseEvent.MOUSE_ENTER;
if (this.object.model) this.object.model.setValue(RoomObjectVariable.FIGURE_HIGHLIGHT, 1); if(this.object.model) this.object.model.setValue(RoomObjectVariable.FIGURE_HIGHLIGHT, 1);
if (this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_BUTTON, this.object)); if(this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_BUTTON, this.object));
break; break;
case MouseEventType.ROLL_OUT: case MouseEventType.ROLL_OUT:
eventType = RoomObjectMouseEvent.MOUSE_LEAVE; eventType = RoomObjectMouseEvent.MOUSE_LEAVE;
if (this.object.model) this.object.model.setValue(RoomObjectVariable.FIGURE_HIGHLIGHT, 0); if(this.object.model) this.object.model.setValue(RoomObjectVariable.FIGURE_HIGHLIGHT, 0);
if (this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_ARROW, this.object)); if(this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_ARROW, this.object));
break; break;
} }
if (eventType && this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectMouseEvent(eventType, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown)); if(eventType && this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectMouseEvent(eventType, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown));
} }
private randomTalkingPauseStartTimestamp(): number private randomTalkingPauseStartTimestamp(): number

View File

@ -24,17 +24,17 @@ export class FurnitureAchievementResolutionLogic extends FurnitureBadgeDisplayLo
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (message instanceof ObjectGroupBadgeUpdateMessage) if(message instanceof ObjectGroupBadgeUpdateMessage)
{ {
if (message.assetName !== 'loading_icon') if(message.assetName !== 'loading_icon')
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_VISIBLE_IN_STATE, FurnitureAchievementResolutionLogic.BADGE_VISIBLE_IN_STATE); this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_VISIBLE_IN_STATE, FurnitureAchievementResolutionLogic.BADGE_VISIBLE_IN_STATE);
} }
} }
if (message instanceof ObjectSelectedMessage) if(message instanceof ObjectSelectedMessage)
{ {
if (!this.eventDispatcher || !this.object) return; if(!this.eventDispatcher || !this.object) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object));
} }
@ -42,11 +42,11 @@ export class FurnitureAchievementResolutionLogic extends FurnitureBadgeDisplayLo
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
let event: RoomObjectEvent = null; let event: RoomObjectEvent = null;
switch (this.object.getState(0)) switch(this.object.getState(0))
{ {
case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_NOT_STARTED: case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_NOT_STARTED:
case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_IN_PROGRESS: case FurnitureAchievementResolutionLogic.STATE_RESOLUTION_IN_PROGRESS:
@ -60,12 +60,12 @@ export class FurnitureAchievementResolutionLogic extends FurnitureBadgeDisplayLo
break; break;
} }
if (event) this.eventDispatcher.dispatchEvent(event); if(event) this.eventDispatcher.dispatchEvent(event);
} }
protected updateBadge(badgeId: string): void protected updateBadge(badgeId: string): void
{ {
if (badgeId === FurnitureAchievementResolutionLogic.ACH_NOT_SET) return; if(badgeId === FurnitureAchievementResolutionLogic.ACH_NOT_SET) return;
super.updateBadge(badgeId); super.updateBadge(badgeId);
} }

View File

@ -18,20 +18,20 @@ export class FurnitureBadgeDisplayLogic extends FurnitureLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (!this.object) return; if(!this.object) return;
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
const data = message.data; const data = message.data;
if (data instanceof StringDataType) this.updateBadge(data.getValue(1)); if(data instanceof StringDataType) this.updateBadge(data.getValue(1));
return; return;
} }
if (message instanceof ObjectGroupBadgeUpdateMessage) if(message instanceof ObjectGroupBadgeUpdateMessage)
{ {
if (message.assetName !== 'loading_icon') if(message.assetName !== 'loading_icon')
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_ASSET_NAME, message.assetName); this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_ASSET_NAME, message.assetName);
this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_IMAGE_STATUS, 1); this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_IMAGE_STATUS, 1);
@ -45,16 +45,16 @@ export class FurnitureBadgeDisplayLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.BADGE_DISPLAY_ENGRAVING, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.BADGE_DISPLAY_ENGRAVING, this.object));
} }
protected updateBadge(badgeId: string): void protected updateBadge(badgeId: string): void
{ {
if (badgeId === '') return; if(badgeId === '') return;
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_IMAGE_STATUS, -1); this.object.model.setValue(RoomObjectVariable.FURNITURE_BADGE_IMAGE_STATUS, -1);

View File

@ -15,33 +15,33 @@ export class FurnitureChangeStateWhenStepOnLogic extends FurnitureLogic
{ {
super.initialize(asset); super.initialize(asset);
if (this.eventDispatcher) this.eventDispatcher.addEventListener(RoomToObjectOwnAvatarMoveEvent.ROAME_MOVE_TO, this.onRoomToObjectOwnAvatarMoveEvent); if(this.eventDispatcher) this.eventDispatcher.addEventListener(RoomToObjectOwnAvatarMoveEvent.ROAME_MOVE_TO, this.onRoomToObjectOwnAvatarMoveEvent);
} }
public tearDown(): void public tearDown(): void
{ {
if (this.eventDispatcher) this.eventDispatcher.removeEventListener(RoomToObjectOwnAvatarMoveEvent.ROAME_MOVE_TO, this.onRoomToObjectOwnAvatarMoveEvent); if(this.eventDispatcher) this.eventDispatcher.removeEventListener(RoomToObjectOwnAvatarMoveEvent.ROAME_MOVE_TO, this.onRoomToObjectOwnAvatarMoveEvent);
super.tearDown(); super.tearDown();
} }
private onRoomToObjectOwnAvatarMoveEvent(event: RoomToObjectOwnAvatarMoveEvent): void private onRoomToObjectOwnAvatarMoveEvent(event: RoomToObjectOwnAvatarMoveEvent): void
{ {
if (!event || !this.object) return; if(!event || !this.object) return;
const location = this.object.getLocation(); const location = this.object.getLocation();
const targetLocation = event.targetLocation; const targetLocation = event.targetLocation;
if (!targetLocation) return; if(!targetLocation) return;
let sizeX = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_X); let sizeX = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_X);
let sizeY = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_Y); let sizeY = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_Y);
const direction = (((Math.floor(this.object.getDirection().x) + 45) % 360) / 90); const direction = (((Math.floor(this.object.getDirection().x) + 45) % 360) / 90);
if ((direction === 1) || (direction === 3)) [sizeX, sizeY] = [sizeY, sizeX]; if((direction === 1) || (direction === 3)) [sizeX, sizeY] = [sizeY, sizeX];
if (((targetLocation.x >= location.x) && (targetLocation.x < (location.x + sizeX))) && ((targetLocation.y >= location.y) && (targetLocation.y < (location.y + sizeY)))) if(((targetLocation.x >= location.x) && (targetLocation.x < (location.x + sizeX))) && ((targetLocation.y >= location.y) && (targetLocation.y < (location.y + sizeY))))
{ {
this.object.setState(1, 0); this.object.setState(1, 0);
} }

View File

@ -26,22 +26,22 @@ export class FurnitureClothingChangeLogic extends FurnitureLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (message instanceof ObjectDataUpdateMessage) message.data && this.updateClothingData(message.data.getLegacyString()); if(message instanceof ObjectDataUpdateMessage) message.data && this.updateClothingData(message.data.getLegacyString());
} }
private updateClothingData(furnitureData: string): void private updateClothingData(furnitureData: string): void
{ {
if (!furnitureData || !furnitureData.length) return; if(!furnitureData || !furnitureData.length) return;
const [boyClothing, girlClothing] = furnitureData.split(','); const [boyClothing, girlClothing] = furnitureData.split(',');
if (boyClothing && boyClothing.length) this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_CLOTHING_BOY, boyClothing); if(boyClothing && boyClothing.length) this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_CLOTHING_BOY, boyClothing);
if (girlClothing && girlClothing.length) this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_CLOTHING_GIRL, girlClothing); if(girlClothing && girlClothing.length) this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_CLOTHING_GIRL, girlClothing);
} }
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOTHING_CHANGE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOTHING_CHANGE, this.object));
} }

View File

@ -14,14 +14,14 @@ export class FurnitureCounterClockLogic extends FurnitureLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry || !this.object) return; if(!event || !geometry || !this.object) return;
let objectEvent: RoomObjectEvent = null; let objectEvent: RoomObjectEvent = null;
switch (event.type) switch(event.type)
{ {
case MouseEventType.DOUBLE_CLICK: case MouseEventType.DOUBLE_CLICK:
switch (event.spriteTag) switch(event.spriteTag)
{ {
case 'start_stop': case 'start_stop':
objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 1); objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 1);
@ -31,7 +31,7 @@ export class FurnitureCounterClockLogic extends FurnitureLogic
break; break;
} }
if (this.eventDispatcher && objectEvent) if(this.eventDispatcher && objectEvent)
{ {
this.eventDispatcher.dispatchEvent(objectEvent); this.eventDispatcher.dispatchEvent(objectEvent);
@ -45,7 +45,7 @@ export class FurnitureCounterClockLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 1)); this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 1));
} }

View File

@ -8,9 +8,9 @@ export class FurnitureCrackableLogic extends FurnitureLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (!this.object) return; if(!this.object) return;
if (this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1) if(this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1)
{ {
this.object.model.setValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM, RoomWidgetEnumItemExtradataParameter.CRACKABLE_FURNI); this.object.model.setValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM, RoomWidgetEnumItemExtradataParameter.CRACKABLE_FURNI);
} }

View File

@ -19,9 +19,9 @@ export class FurnitureCreditLogic extends FurnitureLogic
let creditValue = 0; let creditValue = 0;
if (asset.logic) if(asset.logic)
{ {
if (asset.logic.credits && (asset.logic.credits !== '') && (asset.logic.credits.length > 0)) creditValue = parseInt(asset.logic.credits); if(asset.logic.credits && (asset.logic.credits !== '') && (asset.logic.credits.length > 0)) creditValue = parseInt(asset.logic.credits);
} }
this.object.model.setValue(RoomObjectVariable.FURNITURE_CREDIT_VALUE, creditValue); this.object.model.setValue(RoomObjectVariable.FURNITURE_CREDIT_VALUE, creditValue);
@ -29,7 +29,7 @@ export class FurnitureCreditLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CREDITFURNI, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CREDITFURNI, this.object));

View File

@ -18,9 +18,9 @@ export class FurnitureCuckooClockLogic extends FurnitureMultiStateLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
if ((this._state !== -1) && (message.state !== this._state)) if((this._state !== -1) && (message.state !== this._state))
{ {
this.dispatchSoundEvent(this.object.location.z); this.dispatchSoundEvent(this.object.location.z);
} }

View File

@ -17,12 +17,12 @@ export class FurnitureCustomStackHeightLogic extends FurnitureMultiStateLogic
{ {
super.initialize(asset); super.initialize(asset);
if (this.object && this.object.model) this.object.model.setValue(RoomObjectVariable.FURNITURE_ALWAYS_STACKABLE, 1); if(this.object && this.object.model) this.object.model.setValue(RoomObjectVariable.FURNITURE_ALWAYS_STACKABLE, 1);
} }
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.STACK_HEIGHT, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.STACK_HEIGHT, this.object));

View File

@ -25,16 +25,16 @@ export class FurnitureDiceLogic extends FurnitureLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry || !this.object) return; if(!event || !geometry || !this.object) return;
let objectEvent: RoomObjectEvent = null; let objectEvent: RoomObjectEvent = null;
switch (event.type) switch(event.type)
{ {
case MouseEventType.DOUBLE_CLICK: case MouseEventType.DOUBLE_CLICK:
if (this._noTags) if(this._noTags)
{ {
if (((!(this._noTagsLastStateActivate)) || (this.object.getState(0) === 0)) || (this.object.getState(0) === 100)) if(((!(this._noTagsLastStateActivate)) || (this.object.getState(0) === 0)) || (this.object.getState(0) === 100))
{ {
objectEvent = new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.DICE_ACTIVATE, this.object); objectEvent = new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.DICE_ACTIVATE, this.object);
@ -49,18 +49,18 @@ export class FurnitureDiceLogic extends FurnitureLogic
} }
else else
{ {
if (((event.spriteTag === 'activate') || (this.object.getState(0) === 0)) || (this.object.getState(0) === 100)) if(((event.spriteTag === 'activate') || (this.object.getState(0) === 0)) || (this.object.getState(0) === 100))
{ {
objectEvent = new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.DICE_ACTIVATE, this.object); objectEvent = new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.DICE_ACTIVATE, this.object);
} }
else if (event.spriteTag === 'deactivate') else if(event.spriteTag === 'deactivate')
{ {
objectEvent = new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.DICE_OFF, this.object); objectEvent = new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.DICE_OFF, this.object);
} }
} }
if (objectEvent && this.eventDispatcher) this.eventDispatcher.dispatchEvent(objectEvent); if(objectEvent && this.eventDispatcher) this.eventDispatcher.dispatchEvent(objectEvent);
return; return;
} }

View File

@ -14,7 +14,7 @@ export class FurnitureEcotronBoxLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.ECOTRONBOX, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.ECOTRONBOX, this.object));
} }

View File

@ -27,11 +27,11 @@ export class FurnitureEditableInternalLinkLogic extends FurnitureLogic
{ {
super.initialize(asset); super.initialize(asset);
if (asset.logic) if(asset.logic)
{ {
if (asset.logic.action) if(asset.logic.action)
{ {
if (asset.logic.action.startState === 1) this._showStateOnceRendered = true; if(asset.logic.action.startState === 1) this._showStateOnceRendered = true;
} }
} }
} }
@ -40,11 +40,11 @@ export class FurnitureEditableInternalLinkLogic extends FurnitureLogic
{ {
super.update(time); super.update(time);
if (!this._showStateOnceRendered) return; if(!this._showStateOnceRendered) return;
this._updateCount++; this._updateCount++;
if (this._showStateOnceRendered && (this._updateCount > 20)) if(this._showStateOnceRendered && (this._updateCount > 20))
{ {
this.setAutomaticStateIndex(1); this.setAutomaticStateIndex(1);
@ -54,9 +54,9 @@ export class FurnitureEditableInternalLinkLogic extends FurnitureLogic
private setAutomaticStateIndex(state: number): void private setAutomaticStateIndex(state: number): void
{ {
if (!this.object) return; if(!this.object) return;
if (this.object.model) if(this.object.model)
{ {
this.object.model.setValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX, state); this.object.model.setValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX, state);
} }
@ -64,9 +64,9 @@ export class FurnitureEditableInternalLinkLogic extends FurnitureLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry) return; if(!event || !geometry) return;
if (event.type === MouseEventType.DOUBLE_CLICK) if(event.type === MouseEventType.DOUBLE_CLICK)
{ {
this.setAutomaticStateIndex(0); this.setAutomaticStateIndex(0);
} }
@ -76,7 +76,7 @@ export class FurnitureEditableInternalLinkLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.INERNAL_LINK, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.INERNAL_LINK, this.object));
} }

View File

@ -17,11 +17,11 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
{ {
super.initialize(asset); super.initialize(asset);
if (asset.logic) if(asset.logic)
{ {
if (asset.logic.action) if(asset.logic.action)
{ {
if (asset.logic.action.link && (asset.logic.action.link !== '') && (asset.logic.action.link.length > 0)) if(asset.logic.action.link && (asset.logic.action.link !== '') && (asset.logic.action.link.length > 0))
{ {
(this.object && this.object.model && this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.logic.action.link)); (this.object && this.object.model && this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.logic.action.link));
} }
@ -31,7 +31,7 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
protected onDispose(): void protected onDispose(): void
{ {
if (this._timer) if(this._timer)
{ {
clearTimeout(this._timer); clearTimeout(this._timer);
@ -43,9 +43,9 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
private setAutomaticStateIndex(state: number): void private setAutomaticStateIndex(state: number): void
{ {
if (!this.object) return; if(!this.object) return;
if (this.object.model) if(this.object.model)
{ {
this.object.model.setValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX, state); this.object.model.setValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX, state);
} }
@ -55,7 +55,7 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
{ {
this.setAutomaticStateIndex(1); this.setAutomaticStateIndex(1);
if (this._timer) if(this._timer)
{ {
clearTimeout(this._timer); clearTimeout(this._timer);
@ -69,7 +69,7 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
this._timer = null; this._timer = null;
}, 2500); }, 2500);
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.ROOM_LINK, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.ROOM_LINK, this.object));
} }

View File

@ -15,7 +15,7 @@ export class FurnitureEffectBoxLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.EFFECTBOX_OPEN_DIALOG, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.EFFECTBOX_OPEN_DIALOG, this.object));
} }

View File

@ -17,15 +17,15 @@ export class FurnitureExternalImageLogic extends FurnitureMultiStateLogic
{ {
super.initialize(asset); super.initialize(asset);
if (!asset) return; if(!asset) return;
if (this.object && this.object.model) if(this.object && this.object.model)
{ {
let maskType = ''; let maskType = '';
if (asset.logic) if(asset.logic)
{ {
if (asset.logic.maskType && (asset.logic.maskType !== '') && (asset.logic.maskType.length > 0)) maskType = asset.logic.maskType; if(asset.logic.maskType && (asset.logic.maskType !== '') && (asset.logic.maskType.length > 0)) maskType = asset.logic.maskType;
} }
this.object.model.setValue(RoomObjectVariable.FURNITURE_USES_PLANE_MASK, 0); this.object.model.setValue(RoomObjectVariable.FURNITURE_USES_PLANE_MASK, 0);
@ -35,7 +35,7 @@ export class FurnitureExternalImageLogic extends FurnitureMultiStateLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.EXTERNAL_IMAGE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.EXTERNAL_IMAGE, this.object));

View File

@ -16,9 +16,9 @@ export class FurnitureFireworksLogic extends FurnitureLogic
{ {
super.initialize(asset); super.initialize(asset);
if (asset.logic) if(asset.logic)
{ {
if (asset.logic.particleSystems && asset.logic.particleSystems.length) if(asset.logic.particleSystems && asset.logic.particleSystems.length)
{ {
this.object.model.setValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA, asset.logic.particleSystems); this.object.model.setValue<IParticleSystem[]>(RoomObjectVariable.FURNITURE_FIREWORKS_DATA, asset.logic.particleSystems);
} }
@ -27,14 +27,14 @@ export class FurnitureFireworksLogic extends FurnitureLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry || !this.object) return; if(!event || !geometry || !this.object) return;
let objectEvent: RoomObjectEvent = null; let objectEvent: RoomObjectEvent = null;
switch (event.type) switch(event.type)
{ {
case MouseEventType.DOUBLE_CLICK: case MouseEventType.DOUBLE_CLICK:
switch (event.spriteTag) switch(event.spriteTag)
{ {
case 'start_stop': case 'start_stop':
objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 1); objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 1);
@ -44,7 +44,7 @@ export class FurnitureFireworksLogic extends FurnitureLogic
break; break;
} }
if (this.eventDispatcher && objectEvent) if(this.eventDispatcher && objectEvent)
{ {
this.eventDispatcher.dispatchEvent(objectEvent); this.eventDispatcher.dispatchEvent(objectEvent);
@ -58,7 +58,7 @@ export class FurnitureFireworksLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 0)); this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 0));
} }

View File

@ -28,7 +28,7 @@ export class FurnitureFloorHoleLogic extends FurnitureMultiStateLogic
protected onDispose(): void protected onDispose(): void
{ {
if (this._currentState === FurnitureFloorHoleLogic.STATE_HOLE) if(this._currentState === FurnitureFloorHoleLogic.STATE_HOLE)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.REMOVE_HOLE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.REMOVE_HOLE, this.object));
} }
@ -47,26 +47,26 @@ export class FurnitureFloorHoleLogic extends FurnitureMultiStateLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (!this.object) return; if(!this.object) return;
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
this.handleStateUpdate(this.object.getState(0)); this.handleStateUpdate(this.object.getState(0));
} }
const location = this.object.getLocation(); const location = this.object.getLocation();
if (!this._currentLocation) if(!this._currentLocation)
{ {
this._currentLocation = new Vector3d(); this._currentLocation = new Vector3d();
} }
else else
{ {
if ((location.x !== this._currentLocation.x) || (location.y !== this._currentLocation.y)) if((location.x !== this._currentLocation.x) || (location.y !== this._currentLocation.y))
{ {
if (this._currentState === FurnitureFloorHoleLogic.STATE_HOLE) if(this._currentState === FurnitureFloorHoleLogic.STATE_HOLE)
{ {
if (this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.ADD_HOLE, this.object)); if(this.eventDispatcher) this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.ADD_HOLE, this.object));
} }
} }
} }
@ -76,16 +76,16 @@ export class FurnitureFloorHoleLogic extends FurnitureMultiStateLogic
private handleStateUpdate(state: number): void private handleStateUpdate(state: number): void
{ {
if (state === this._currentState) return; if(state === this._currentState) return;
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
if (state === FurnitureFloorHoleLogic.STATE_HOLE) if(state === FurnitureFloorHoleLogic.STATE_HOLE)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.ADD_HOLE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.ADD_HOLE, this.object));
} }
else if (this._currentState === FurnitureFloorHoleLogic.STATE_HOLE) else if(this._currentState === FurnitureFloorHoleLogic.STATE_HOLE)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.REMOVE_HOLE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFloorHoleEvent(RoomObjectFloorHoleEvent.REMOVE_HOLE, this.object));
} }
@ -96,14 +96,14 @@ export class FurnitureFloorHoleLogic extends FurnitureMultiStateLogic
private handleAutomaticStateUpdate(): void private handleAutomaticStateUpdate(): void
{ {
if (!this.object) return; if(!this.object) return;
const model = this.object.model; const model = this.object.model;
if (!model) return; if(!model) return;
const stateIndex = model.getValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX); const stateIndex = model.getValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX);
if (!isNaN(stateIndex)) this.handleStateUpdate((stateIndex % 2)); if(!isNaN(stateIndex)) this.handleStateUpdate((stateIndex % 2));
} }
} }

View File

@ -16,16 +16,16 @@ export class FurnitureFriendFurniLogic extends FurnitureMultiStateLogic
{ {
super.initialize(asset); super.initialize(asset);
if (this.object) this.object.model.setValue(RoomObjectVariable.FURNITURE_FRIENDFURNI_ENGRAVING, this.engravingDialogType); if(this.object) this.object.model.setValue(RoomObjectVariable.FURNITURE_FRIENDFURNI_ENGRAVING, this.engravingDialogType);
} }
public processUpdateMessage(message: RoomObjectUpdateMessage): void public processUpdateMessage(message: RoomObjectUpdateMessage): void
{ {
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
const data = (message.data as StringDataType); const data = (message.data as StringDataType);
if (data) if(data)
{ {
this._state = data.state; this._state = data.state;
} }
@ -47,9 +47,9 @@ export class FurnitureFriendFurniLogic extends FurnitureMultiStateLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
if (this._state === FurnitureFriendFurniLogic.STATE_LOCKED) if(this._state === FurnitureFriendFurniLogic.STATE_LOCKED)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.FRIEND_FURNITURE_ENGRAVING, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.FRIEND_FURNITURE_ENGRAVING, this.object));
} }

View File

@ -22,7 +22,7 @@ export class FurnitureGroupForumTerminalLogic extends FurnitureGuildCustomizedLo
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.INERNAL_LINK, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.INERNAL_LINK, this.object));

View File

@ -27,11 +27,11 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
const data = message.data; const data = message.data;
if (data instanceof StringDataType) if(data instanceof StringDataType)
{ {
this.updateGroupId(data.getValue(FurnitureGuildCustomizedLogic.GROUPID_KEY)); this.updateGroupId(data.getValue(FurnitureGuildCustomizedLogic.GROUPID_KEY));
this.updateBadge(data.getValue(FurnitureGuildCustomizedLogic.BADGE_KEY)); this.updateBadge(data.getValue(FurnitureGuildCustomizedLogic.BADGE_KEY));
@ -39,9 +39,9 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
} }
} }
else if (message instanceof ObjectGroupBadgeUpdateMessage) else if(message instanceof ObjectGroupBadgeUpdateMessage)
{ {
if (message.assetName !== 'loading_icon') if(message.assetName !== 'loading_icon')
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME, message.assetName); this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME, message.assetName);
@ -49,9 +49,9 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
} }
} }
else if (message instanceof ObjectSelectedMessage) else if(message instanceof ObjectSelectedMessage)
{ {
if (!message.selected) if(!message.selected)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object));
} }
@ -76,9 +76,9 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry || !this.object) return; if(!event || !geometry || !this.object) return;
switch (event.type) switch(event.type)
{ {
case MouseEventType.MOUSE_CLICK: case MouseEventType.MOUSE_CLICK:
this.openContextMenu(); this.openContextMenu();

View File

@ -12,7 +12,7 @@ export class FurnitureHabboWheelLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.USE_HABBOWHEEL, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.USE_HABBOWHEEL, this.object));
} }

View File

@ -17,7 +17,7 @@ export class FurnitureHighScoreLogic extends FurnitureLogic
public tearDown(): void public tearDown(): void
{ {
if (this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1) if(this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.HIDE_HIGH_SCORE_DISPLAY, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.HIDE_HIGH_SCORE_DISPLAY, this.object));
} }
@ -29,11 +29,11 @@ export class FurnitureHighScoreLogic extends FurnitureLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) !== 1) return; if(this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) !== 1) return;
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
if (message.state === FurnitureHighScoreLogic.SHOW_WIDGET_IN_STATE) if(message.state === FurnitureHighScoreLogic.SHOW_WIDGET_IN_STATE)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.HIGH_SCORE_DISPLAY, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.HIGH_SCORE_DISPLAY, this.object));
} }

View File

@ -14,14 +14,14 @@ export class FurnitureHockeyScoreLogic extends FurnitureLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry || !this.object) return; if(!event || !geometry || !this.object) return;
let objectEvent: RoomObjectEvent = null; let objectEvent: RoomObjectEvent = null;
switch (event.type) switch(event.type)
{ {
case MouseEventType.DOUBLE_CLICK: case MouseEventType.DOUBLE_CLICK:
switch (event.spriteTag) switch(event.spriteTag)
{ {
case 'off': case 'off':
objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 3); objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 3);
@ -29,7 +29,7 @@ export class FurnitureHockeyScoreLogic extends FurnitureLogic
} }
break; break;
case MouseEventType.MOUSE_CLICK: case MouseEventType.MOUSE_CLICK:
switch (event.spriteTag) switch(event.spriteTag)
{ {
case 'inc': case 'inc':
objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 2); objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 2);
@ -41,7 +41,7 @@ export class FurnitureHockeyScoreLogic extends FurnitureLogic
break; break;
} }
if (this.eventDispatcher && objectEvent) if(this.eventDispatcher && objectEvent)
{ {
this.eventDispatcher.dispatchEvent(objectEvent); this.eventDispatcher.dispatchEvent(objectEvent);
@ -53,7 +53,7 @@ export class FurnitureHockeyScoreLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 3)); this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, 3));
} }

View File

@ -21,13 +21,13 @@ export class FurnitureInternalLinkLogic extends FurnitureLogic
{ {
super.initialize(asset); super.initialize(asset);
if (asset.logic) if(asset.logic)
{ {
if (asset.logic.action) if(asset.logic.action)
{ {
this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.logic.action.link); this.object.model.setValue<string>(RoomObjectVariable.FURNITURE_INTERNAL_LINK, asset.logic.action.link);
if (asset.logic.action.startState === 1) this._showStateOnceRendered = true; if(asset.logic.action.startState === 1) this._showStateOnceRendered = true;
} }
} }
} }
@ -36,11 +36,11 @@ export class FurnitureInternalLinkLogic extends FurnitureLogic
{ {
super.update(time); super.update(time);
if (!this._showStateOnceRendered) return; if(!this._showStateOnceRendered) return;
this._updateCount++; this._updateCount++;
if (this._showStateOnceRendered && (this._updateCount === 20)) if(this._showStateOnceRendered && (this._updateCount === 20))
{ {
this.setAutomaticStateIndex(1); this.setAutomaticStateIndex(1);
@ -50,9 +50,9 @@ export class FurnitureInternalLinkLogic extends FurnitureLogic
private setAutomaticStateIndex(state: number): void private setAutomaticStateIndex(state: number): void
{ {
if (!this.object) return; if(!this.object) return;
if (this.object.model) if(this.object.model)
{ {
this.object.model.setValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX, state); this.object.model.setValue<number>(RoomObjectVariable.FURNITURE_AUTOMATIC_STATE_INDEX, state);
} }
@ -60,9 +60,9 @@ export class FurnitureInternalLinkLogic extends FurnitureLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry) return; if(!event || !geometry) return;
if ((event.type === MouseEventType.DOUBLE_CLICK) && this._showStateOnceRendered) if((event.type === MouseEventType.DOUBLE_CLICK) && this._showStateOnceRendered)
{ {
this.setAutomaticStateIndex(0); this.setAutomaticStateIndex(0);
} }
@ -72,7 +72,7 @@ export class FurnitureInternalLinkLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.INERNAL_LINK, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.INERNAL_LINK, this.object));
} }

View File

@ -34,29 +34,29 @@ export class FurnitureJukeboxLogic extends FurnitureMultiStateLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) !== 1) return; if(this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) !== 1) return;
if (!this._isInitialized) this.requestInit(); if(!this._isInitialized) this.requestInit();
this.object.model.setValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM, RoomWidgetEnumItemExtradataParameter.JUKEBOX); this.object.model.setValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM, RoomWidgetEnumItemExtradataParameter.JUKEBOX);
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
const state = this.object.getState(0); const state = this.object.getState(0);
if (state !== this._currentState) if(state !== this._currentState)
{ {
this._currentState = state; this._currentState = state;
if (state === 1) this.requestPlayList(); if(state === 1) this.requestPlayList();
else if (state === 0) this.requestStopPlaying(); else if(state === 0) this.requestStopPlaying();
} }
} }
} }
private requestInit(): void private requestInit(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this._disposeEventsAllowed = true; this._disposeEventsAllowed = true;
@ -67,7 +67,7 @@ export class FurnitureJukeboxLogic extends FurnitureMultiStateLogic
private requestPlayList(): void private requestPlayList(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this._disposeEventsAllowed = true; this._disposeEventsAllowed = true;
@ -76,21 +76,21 @@ export class FurnitureJukeboxLogic extends FurnitureMultiStateLogic
private requestStopPlaying(): void private requestStopPlaying(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.JUKEBOX_MACHINE_STOP, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.JUKEBOX_MACHINE_STOP, this.object));
} }
private requestDispose(): void private requestDispose(): void
{ {
if (!this._disposeEventsAllowed || !this.object || !this.eventDispatcher) return; if(!this._disposeEventsAllowed || !this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.JUKEBOX_DISPOSE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.JUKEBOX_DISPOSE, this.object));
} }
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.JUKEBOX_PLAYLIST_EDITOR, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.JUKEBOX_PLAYLIST_EDITOR, this.object));
this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, -1)); this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object, -1));

View File

@ -45,12 +45,12 @@ export class FurnitureLogic extends MovingObjectLogic
this._storedRotateMessage = null; this._storedRotateMessage = null;
this._directionInitialized = false; this._directionInitialized = false;
if (FurnitureLogic.BOUNCING_STEPS === -1) if(FurnitureLogic.BOUNCING_STEPS === -1)
{ {
FurnitureLogic.BOUNCING_STEPS = NitroConfiguration.getValue<number>('furni.rotation.bounce.steps', 8); FurnitureLogic.BOUNCING_STEPS = NitroConfiguration.getValue<number>('furni.rotation.bounce.steps', 8);
} }
if (FurnitureLogic.BOUNCING_Z === -1) if(FurnitureLogic.BOUNCING_Z === -1)
{ {
FurnitureLogic.BOUNCING_Z = NitroConfiguration.getValue<number>('furni.rotation.bounce.height', 0.0625); FurnitureLogic.BOUNCING_Z = NitroConfiguration.getValue<number>('furni.rotation.bounce.height', 0.0625);
} }
@ -68,28 +68,28 @@ export class FurnitureLogic extends MovingObjectLogic
RoomObjectRoomAdEvent.ROOM_AD_FURNI_DOUBLE_CLICK, RoomObjectRoomAdEvent.ROOM_AD_FURNI_DOUBLE_CLICK,
RoomObjectRoomAdEvent.ROOM_AD_FURNI_CLICK]; RoomObjectRoomAdEvent.ROOM_AD_FURNI_CLICK];
if (this.widget) types.push(RoomObjectWidgetRequestEvent.OPEN_WIDGET, RoomObjectWidgetRequestEvent.CLOSE_WIDGET); if(this.widget) types.push(RoomObjectWidgetRequestEvent.OPEN_WIDGET, RoomObjectWidgetRequestEvent.CLOSE_WIDGET);
if (this.contextMenu) types.push(RoomObjectWidgetRequestEvent.OPEN_FURNI_CONTEXT_MENU, RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU); if(this.contextMenu) types.push(RoomObjectWidgetRequestEvent.OPEN_FURNI_CONTEXT_MENU, RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU);
return this.mergeTypes(super.getEventTypes(), types); return this.mergeTypes(super.getEventTypes(), types);
} }
public initialize(asset: IAssetData): void public initialize(asset: IAssetData): void
{ {
if (!asset) return; if(!asset) return;
const model = this.object && this.object.model; const model = this.object && this.object.model;
if (!model) return; if(!model) return;
if (asset.logic) if(asset.logic)
{ {
if (asset.logic.model) if(asset.logic.model)
{ {
const dimensions = asset.logic.model.dimensions; const dimensions = asset.logic.model.dimensions;
if (dimensions) if(dimensions)
{ {
this._sizeX = dimensions.x; this._sizeX = dimensions.x;
this._sizeY = dimensions.y; this._sizeY = dimensions.y;
@ -102,19 +102,19 @@ export class FurnitureLogic extends MovingObjectLogic
const directions = asset.logic.model.directions; const directions = asset.logic.model.directions;
if (directions && directions.length) if(directions && directions.length)
{ {
for (const direction of directions) this._directions.push(direction); for(const direction of directions) this._directions.push(direction);
this._directions.sort((a, b) => (a - b)); this._directions.sort((a, b) => (a - b));
} }
} }
if (asset.logic.customVars) if(asset.logic.customVars)
{ {
const variables = asset.logic.customVars.variables; const variables = asset.logic.customVars.variables;
if (variables && variables.length) if(variables && variables.length)
{ {
model.setValue(RoomObjectVariable.FURNITURE_CUSTOM_VARIABLES, variables); model.setValue(RoomObjectVariable.FURNITURE_CUSTOM_VARIABLES, variables);
} }
@ -143,7 +143,7 @@ export class FurnitureLogic extends MovingObjectLogic
{ {
super.setObject(object); super.setObject(object);
if (object && object.getLocation().length) this._directionInitialized = true; if(object && object.getLocation().length) this._directionInitialized = true;
} }
protected getAdClickUrl(model: IRoomObjectModel): string protected getAdClickUrl(model: IRoomObjectModel): string
@ -153,7 +153,7 @@ export class FurnitureLogic extends MovingObjectLogic
protected handleAdClick(objectId: number, objectType: string, clickUrl: string): void protected handleAdClick(objectId: number, objectType: string, clickUrl: string): void
{ {
if (!this.eventDispatcher) return; if(!this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_FURNI_CLICK, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_FURNI_CLICK, this.object));
} }
@ -162,31 +162,31 @@ export class FurnitureLogic extends MovingObjectLogic
{ {
super.update(time); super.update(time);
if (this._bouncingStep > 0) if(this._bouncingStep > 0)
{ {
this._bouncingStep++; this._bouncingStep++;
if (this._bouncingStep > FurnitureLogic.BOUNCING_STEPS) this._bouncingStep = 0; if(this._bouncingStep > FurnitureLogic.BOUNCING_STEPS) this._bouncingStep = 0;
} }
} }
public processUpdateMessage(message: RoomObjectUpdateMessage): void public processUpdateMessage(message: RoomObjectUpdateMessage): void
{ {
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
this.processDataUpdateMessage(message); this.processDataUpdateMessage(message);
return; return;
} }
if (message instanceof ObjectHeightUpdateMessage) if(message instanceof ObjectHeightUpdateMessage)
{ {
this.processObjectHeightUpdateMessage(message); this.processObjectHeightUpdateMessage(message);
return; return;
} }
if (message instanceof ObjectItemDataUpdateMessage) if(message instanceof ObjectItemDataUpdateMessage)
{ {
this.processItemDataUpdateMessage(message); this.processItemDataUpdateMessage(message);
@ -195,16 +195,16 @@ export class FurnitureLogic extends MovingObjectLogic
this._mouseOver = false; this._mouseOver = false;
if (message.location && message.direction) if(message.location && message.direction)
{ {
if (!(message instanceof ObjectMoveUpdateMessage)) if(!(message instanceof ObjectMoveUpdateMessage))
{ {
const direction = this.object.getDirection(); const direction = this.object.getDirection();
const location = this.object.getLocation(); const location = this.object.getLocation();
if ((direction.x !== message.direction.x) && this._directionInitialized) if((direction.x !== message.direction.x) && this._directionInitialized)
{ {
if ((location.x === message.location.x) && (location.y === message.location.y) && (location.z === message.location.z)) if((location.x === message.location.x) && (location.y === message.location.y) && (location.z === message.location.z))
{ {
this._bouncingStep = 1; this._bouncingStep = 1;
this._storedRotateMessage = new RoomObjectUpdateMessage(message.location, message.direction); this._storedRotateMessage = new RoomObjectUpdateMessage(message.location, message.direction);
@ -217,9 +217,9 @@ export class FurnitureLogic extends MovingObjectLogic
this._directionInitialized = true; this._directionInitialized = true;
} }
if (message instanceof ObjectSelectedMessage) if(message instanceof ObjectSelectedMessage)
{ {
if (this.contextMenu && this.eventDispatcher && this.object) if(this.contextMenu && this.eventDispatcher && this.object)
{ {
const eventType = (message.selected) ? RoomObjectWidgetRequestEvent.OPEN_FURNI_CONTEXT_MENU : RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU; const eventType = (message.selected) ? RoomObjectWidgetRequestEvent.OPEN_FURNI_CONTEXT_MENU : RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU;
@ -232,27 +232,27 @@ export class FurnitureLogic extends MovingObjectLogic
private processDataUpdateMessage(message: ObjectDataUpdateMessage): void private processDataUpdateMessage(message: ObjectDataUpdateMessage): void
{ {
if (!message) return; if(!message) return;
this.object.setState(message.state, 0); this.object.setState(message.state, 0);
if (message.data) message.data.writeRoomObjectModel(this.object.model); if(message.data) message.data.writeRoomObjectModel(this.object.model);
if (message.extra !== null) this.object.model.setValue(RoomObjectVariable.FURNITURE_EXTRAS, message.extra.toString()); if(message.extra !== null) this.object.model.setValue(RoomObjectVariable.FURNITURE_EXTRAS, message.extra.toString());
this.object.model.setValue(RoomObjectVariable.FURNITURE_STATE_UPDATE_TIME, this.lastUpdateTime); this.object.model.setValue(RoomObjectVariable.FURNITURE_STATE_UPDATE_TIME, this.lastUpdateTime);
} }
private processObjectHeightUpdateMessage(message: ObjectHeightUpdateMessage): void private processObjectHeightUpdateMessage(message: ObjectHeightUpdateMessage): void
{ {
if (!message) return; if(!message) return;
this.object.model.setValue(RoomObjectVariable.FURNITURE_SIZE_Z, message.height); this.object.model.setValue(RoomObjectVariable.FURNITURE_SIZE_Z, message.height);
} }
private processItemDataUpdateMessage(message: ObjectItemDataUpdateMessage): void private processItemDataUpdateMessage(message: ObjectItemDataUpdateMessage): void
{ {
if (!message) return; if(!message) return;
this.object.model.setValue(RoomObjectVariable.FURNITURE_ITEMDATA, message.data); this.object.model.setValue(RoomObjectVariable.FURNITURE_ITEMDATA, message.data);
} }
@ -261,10 +261,10 @@ export class FurnitureLogic extends MovingObjectLogic
{ {
const adUrl = this.getAdClickUrl(this.object.model); const adUrl = this.getAdClickUrl(this.object.model);
switch (event.type) switch(event.type)
{ {
case MouseEventType.MOUSE_MOVE: case MouseEventType.MOUSE_MOVE:
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_MOVE, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown); const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_MOVE, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown);
@ -277,11 +277,11 @@ export class FurnitureLogic extends MovingObjectLogic
} }
return; return;
case MouseEventType.ROLL_OVER: case MouseEventType.ROLL_OVER:
if (!this._mouseOver) if(!this._mouseOver)
{ {
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
if (adUrl && (adUrl.indexOf('http') === 0)) if(adUrl && (adUrl.indexOf('http') === 0))
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_SHOW, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_SHOW, this.object));
} }
@ -300,11 +300,11 @@ export class FurnitureLogic extends MovingObjectLogic
} }
return; return;
case MouseEventType.ROLL_OUT: case MouseEventType.ROLL_OUT:
if (this._mouseOver) if(this._mouseOver)
{ {
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
if (adUrl && (adUrl.indexOf('http') === 0)) if(adUrl && (adUrl.indexOf('http') === 0))
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_HIDE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_HIDE, this.object));
} }
@ -326,7 +326,7 @@ export class FurnitureLogic extends MovingObjectLogic
this.useObject(); this.useObject();
return; return;
case MouseEventType.MOUSE_CLICK: case MouseEventType.MOUSE_CLICK:
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.CLICK, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown); const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.CLICK, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown);
@ -337,16 +337,16 @@ export class FurnitureLogic extends MovingObjectLogic
this.eventDispatcher.dispatchEvent(mouseEvent); this.eventDispatcher.dispatchEvent(mouseEvent);
if (adUrl && (adUrl.indexOf('http') === 0)) if(adUrl && (adUrl.indexOf('http') === 0))
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_HIDE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_HIDE, this.object));
} }
if (adUrl && adUrl.length) this.handleAdClick(this.object.id, this.object.type, adUrl); if(adUrl && adUrl.length) this.handleAdClick(this.object.id, this.object.type, adUrl);
} }
return; return;
case MouseEventType.MOUSE_DOWN: case MouseEventType.MOUSE_DOWN:
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_DOWN, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown); const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_DOWN, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown);
@ -354,7 +354,7 @@ export class FurnitureLogic extends MovingObjectLogic
} }
return; return;
case MouseEventType.MOUSE_DOWN_LONG: case MouseEventType.MOUSE_DOWN_LONG:
if (this.eventDispatcher) if(this.eventDispatcher)
{ {
const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_DOWN_LONG, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown); const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_DOWN_LONG, this.object, event.eventId, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown);
@ -366,20 +366,20 @@ export class FurnitureLogic extends MovingObjectLogic
protected getLocationOffset(): IVector3D protected getLocationOffset(): IVector3D
{ {
if (this._bouncingStep <= 0) return null; if(this._bouncingStep <= 0) return null;
this._locationOffset.x = 0; this._locationOffset.x = 0;
this._locationOffset.y = 0; this._locationOffset.y = 0;
if (this._bouncingStep <= (FurnitureLogic.BOUNCING_STEPS / 2)) if(this._bouncingStep <= (FurnitureLogic.BOUNCING_STEPS / 2))
{ {
this._locationOffset.z = FurnitureLogic.BOUNCING_Z * this._bouncingStep; this._locationOffset.z = FurnitureLogic.BOUNCING_Z * this._bouncingStep;
} }
else else
{ {
if (this._bouncingStep <= FurnitureLogic.BOUNCING_STEPS) if(this._bouncingStep <= FurnitureLogic.BOUNCING_STEPS)
{ {
if (this._storedRotateMessage) if(this._storedRotateMessage)
{ {
super.processUpdateMessage(this._storedRotateMessage); super.processUpdateMessage(this._storedRotateMessage);
@ -395,27 +395,27 @@ export class FurnitureLogic extends MovingObjectLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
const clickUrl = this.getAdClickUrl(this.object.model); const clickUrl = this.getAdClickUrl(this.object.model);
if (clickUrl && clickUrl.length) if(clickUrl && clickUrl.length)
{ {
this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_FURNI_DOUBLE_CLICK, this.object, null, clickUrl)); this.eventDispatcher.dispatchEvent(new RoomObjectRoomAdEvent(RoomObjectRoomAdEvent.ROOM_AD_FURNI_DOUBLE_CLICK, this.object, null, clickUrl));
} }
if (this.widget) this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.OPEN_WIDGET, this.object)); if(this.widget) this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.OPEN_WIDGET, this.object));
this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object));
} }
public tearDown(): void public tearDown(): void
{ {
if (this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1) if(this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1)
{ {
if (this.widget) this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_WIDGET, this.object)); if(this.widget) this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_WIDGET, this.object));
if (this.contextMenu) this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object)); if(this.contextMenu) this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object));
} }
super.tearDown(); super.tearDown();

View File

@ -21,7 +21,7 @@ export class FurnitureMannequinLogic extends FurnitureLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (message instanceof ObjectDataUpdateMessage) if(message instanceof ObjectDataUpdateMessage)
{ {
message.data.writeRoomObjectModel(this.object.model); message.data.writeRoomObjectModel(this.object.model);
@ -31,7 +31,7 @@ export class FurnitureMannequinLogic extends FurnitureLogic
private processObjectData(): void private processObjectData(): void
{ {
if (!this.object || !this.object.model) return; if(!this.object || !this.object.model) return;
const data = new MapDataType(); const data = new MapDataType();
@ -44,7 +44,7 @@ export class FurnitureMannequinLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MANNEQUIN, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MANNEQUIN, this.object));
} }

View File

@ -13,7 +13,7 @@ export class FurnitureMonsterplantSeedLogic extends FurnitureMultiStateLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, this.object));
} }

View File

@ -14,9 +14,9 @@ export class FurnitureMultiStateLogic extends FurnitureLogic
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
if (!event || !geometry || !this.object) return; if(!event || !geometry || !this.object) return;
switch (event.type) switch(event.type)
{ {
case MouseEventType.ROLL_OVER: case MouseEventType.ROLL_OVER:
this.eventDispatcher && this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_BUTTON, this.object)); this.eventDispatcher && this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_BUTTON, this.object));

View File

@ -13,7 +13,7 @@ export class FurnitureMysteryBoxLogic extends FurnitureMultiStateLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MYSTERYBOX_OPEN_DIALOG, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MYSTERYBOX_OPEN_DIALOG, this.object));
} }

View File

@ -13,7 +13,7 @@ export class FurnitureMysteryTrophyLogic extends FurnitureMultiStateLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MYSTERYTROPHY_OPEN_DIALOG, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.MYSTERYTROPHY_OPEN_DIALOG, this.object));
} }

View File

@ -12,7 +12,7 @@ export class FurnitureOneWayDoorLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.ENTER_ONEWAYDOOR, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.ENTER_ONEWAYDOOR, this.object));
} }

View File

@ -16,9 +16,9 @@ export class FurniturePetCustomizationLogic extends FurnitureLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if (!this.object) return; if(!this.object) return;
if (this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1) if(this.object.model.getValue(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1)
{ {
this.object.model.setValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM, RoomWidgetEnumItemExtradataParameter.USABLE_PRODUCT); this.object.model.setValue(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM, RoomWidgetEnumItemExtradataParameter.USABLE_PRODUCT);
} }
@ -26,7 +26,7 @@ export class FurniturePetCustomizationLogic extends FurnitureLogic
public useObject(): void public useObject(): void
{ {
if (!this.object || !this.eventDispatcher) return; if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.PET_PRODUCT_MENU, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.PET_PRODUCT_MENU, this.object));
} }

Some files were not shown because too many files have changed in this diff Show More