Update assets api

This commit is contained in:
Bill 2022-10-29 21:32:38 -04:00
parent d918e0c587
commit d8fca7188f
145 changed files with 1912 additions and 1893 deletions

View File

@ -1,9 +1,9 @@
import { Resource, Texture } from '@pixi/core'; import { Resource, Texture } from '@pixi/core';
import { Spritesheet } from '@pixi/spritesheet'; import { Spritesheet } from '@pixi/spritesheet';
import { IGraphicAsset } from '../../room/object/visualization/utils/IGraphicAsset'; import { IAssetData } from './IAssetData';
import { IGraphicAssetCollection } from '../../room/object/visualization/utils/IGraphicAssetCollection'; import { IGraphicAsset } from './IGraphicAsset';
import { IAssetData } from './interfaces'; import { IGraphicAssetCollection } from './IGraphicAssetCollection';
export interface IAssetManager export interface IAssetManager
{ {

View File

@ -1,7 +1,7 @@
import { BaseTexture, Resource, Texture } from '@pixi/core'; import { BaseTexture, Resource, Texture } from '@pixi/core';
import { IAssetData } from '../../../../core/asset/interfaces'; import { IAssetData } from './IAssetData';
import { GraphicAssetPalette } from './GraphicAssetPalette';
import { IGraphicAsset } from './IGraphicAsset'; import { IGraphicAsset } from './IGraphicAsset';
import { IGraphicAssetPalette } from './IGraphicAssetPalette';
export interface IGraphicAssetCollection export interface IGraphicAssetCollection
{ {
@ -14,7 +14,7 @@ export interface IGraphicAssetCollection
getTexture(name: string): Texture<Resource>; getTexture(name: string): Texture<Resource>;
getPaletteNames(): string[]; getPaletteNames(): string[];
getPaletteColors(paletteName: string): number[]; getPaletteColors(paletteName: string): number[];
getPalette(name: string): GraphicAssetPalette; getPalette(name: string): IGraphicAssetPalette;
addAsset(name: string, texture: Texture<Resource>, override: boolean, x?: number, y?: number, flipH?: boolean, flipV?: boolean): boolean; addAsset(name: string, texture: Texture<Resource>, override: boolean, x?: number, y?: number, flipH?: boolean, flipV?: boolean): boolean;
disposeAsset(name: string): void; disposeAsset(name: string): void;
referenceCount: number; referenceCount: number;

View File

@ -0,0 +1,9 @@
import { Resource, Texture } from '@pixi/core';
export interface IGraphicAssetPalette
{
dispose: () => void;
applyPalette(texture: Texture<Resource>): Texture<Resource>;
primaryColor: number;
secondaryColor: number;
}

18
src/api/asset/index.ts Normal file
View File

@ -0,0 +1,18 @@
export * from './animation';
export * from './IAsset';
export * from './IAssetAlias';
export * from './IAssetData';
export * from './IAssetManager';
export * from './IAssetPalette';
export * from './IGraphicAsset';
export * from './IGraphicAssetCollection';
export * from './IGraphicAssetPalette';
export * from './logic';
export * from './logic/model';
export * from './logic/particlesystem';
export * from './spritesheet';
export * from './visualization';
export * from './visualization/animation';
export * from './visualization/color';
export * from './visualization/gestures';
export * from './visualization/postures';

11
src/api/index.ts Normal file
View File

@ -0,0 +1,11 @@
export * from './asset';
export * from './asset/animation';
export * from './asset/logic';
export * from './asset/logic/model';
export * from './asset/logic/particlesystem';
export * from './asset/spritesheet';
export * from './asset/visualization';
export * from './asset/visualization/animation';
export * from './asset/visualization/color';
export * from './asset/visualization/gestures';
export * from './asset/visualization/postures';

View File

@ -1,4 +1,4 @@
import { IAssetManager } from './asset/IAssetManager'; import { IAssetManager } from '../api';
import { IDisposable } from './common/disposable/IDisposable'; import { IDisposable } from './common/disposable/IDisposable';
import { ICommunicationManager } from './communication/ICommunicationManager'; import { ICommunicationManager } from './communication/ICommunicationManager';
import { IConfigurationManager } from './configuration/IConfigurationManager'; import { IConfigurationManager } from './configuration/IConfigurationManager';

View File

@ -1,5 +1,5 @@
import { IAssetManager } from '../api';
import { AssetManager } from './asset/AssetManager'; import { AssetManager } from './asset/AssetManager';
import { IAssetManager } from './asset/IAssetManager';
import { Disposable } from './common/disposable/Disposable'; import { Disposable } from './common/disposable/Disposable';
import { CommunicationManager } from './communication/CommunicationManager'; import { CommunicationManager } from './communication/CommunicationManager';
import { ICommunicationManager } from './communication/ICommunicationManager'; import { ICommunicationManager } from './communication/ICommunicationManager';
@ -27,14 +27,14 @@ export class NitroCore extends Disposable implements INitroCore
protected onDispose(): void protected onDispose(): void
{ {
if(this._asset) if (this._asset)
{ {
this._asset.dispose(); this._asset.dispose();
this._asset = null; this._asset = null;
} }
if(this._communication) if (this._communication)
{ {
this._communication.dispose(); this._communication.dispose();

View File

@ -1,15 +1,12 @@
import { BaseTexture, Resource, Texture } from '@pixi/core'; import { BaseTexture, Resource, Texture } from '@pixi/core';
import { Loader, LoaderResource } from '@pixi/loaders'; import { Loader, LoaderResource } from '@pixi/loaders';
import { Spritesheet } from '@pixi/spritesheet'; import { Spritesheet } from '@pixi/spritesheet';
import { IGraphicAsset } from '../../room/object/visualization/utils'; import { IAssetData, IAssetManager, IGraphicAsset, IGraphicAssetCollection } from '../../api';
import { GraphicAssetCollection } from '../../room/object/visualization/utils/GraphicAssetCollection'; import { GraphicAssetCollection } from '../../room/object/visualization/utils/GraphicAssetCollection';
import { IGraphicAssetCollection } from '../../room/object/visualization/utils/IGraphicAssetCollection';
import { Disposable } from '../common/disposable/Disposable'; import { Disposable } from '../common/disposable/Disposable';
import { INitroLogger } from '../common/logger/INitroLogger'; import { INitroLogger } from '../common/logger/INitroLogger';
import { NitroLogger } from '../common/logger/NitroLogger'; import { NitroLogger } from '../common/logger/NitroLogger';
import { ArrayBufferToBase64 } from '../utils'; import { ArrayBufferToBase64 } from '../utils';
import { IAssetManager } from './IAssetManager';
import { IAssetData } from './interfaces';
import { NitroBundle } from './NitroBundle'; import { NitroBundle } from './NitroBundle';
export class AssetManager extends Disposable implements IAssetManager export class AssetManager extends Disposable implements IAssetManager
@ -34,33 +31,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;
} }
@ -70,24 +67,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);
} }
@ -102,7 +99,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);
@ -111,9 +108,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({
@ -128,7 +125,7 @@ export class AssetManager extends Disposable implements IAssetManager
const onDownloaded = (status: boolean, url: string) => const onDownloaded = (status: boolean, url: string) =>
{ {
if(!status) if (!status)
{ {
this._logger.error('Failed to download asset', url); this._logger.error('Failed to download asset', url);
@ -141,7 +138,7 @@ export class AssetManager extends Disposable implements IAssetManager
remaining--; remaining--;
if(!remaining) if (!remaining)
{ {
loader.destroy(); loader.destroy();
@ -153,11 +150,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);
@ -166,7 +163,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);
@ -178,12 +175,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);
@ -215,7 +212,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);
@ -236,7 +233,7 @@ export class AssetManager extends Disposable implements IAssetManager
}); });
}; };
if(baseTexture.valid) if (baseTexture.valid)
{ {
createAsset(); createAsset();
} }

View File

@ -1,4 +1,2 @@
export * from './AssetManager'; export * from './AssetManager';
export * from './IAssetManager';
export * from './interfaces';
export * from './NitroBundle'; export * from './NitroBundle';

View File

@ -1,8 +0,0 @@
export * from './animation';
export * from './IAsset';
export * from './IAssetAlias';
export * from './IAssetData';
export * from './IAssetPalette';
export * from './logic';
export * from './spritesheet';
export * from './visualization';

View File

@ -1,3 +1,4 @@
export * from './api';
export * from './core'; export * from './core';
export * from './nitro'; export * from './nitro';
export * from './room'; export * from './room';

View File

@ -1,4 +1,4 @@
import { IAssetManager } from '../../core/asset/IAssetManager'; import { IAssetManager } from '../../api';
import { EventDispatcher } from '../../core/events/EventDispatcher'; import { EventDispatcher } from '../../core/events/EventDispatcher';
import { AvatarRenderLibraryEvent } from './events/AvatarRenderLibraryEvent'; import { AvatarRenderLibraryEvent } from './events/AvatarRenderLibraryEvent';
@ -31,16 +31,16 @@ export class AvatarAssetDownloadLibrary extends EventDispatcher
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
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

@ -1,4 +1,4 @@
import { IAssetManager } from '../../core/asset/IAssetManager'; import { IAssetManager } from '../../api';
import { EventDispatcher } from '../../core/events/EventDispatcher'; import { EventDispatcher } from '../../core/events/EventDispatcher';
import { NitroEvent } from '../../core/events/NitroEvent'; import { NitroEvent } from '../../core/events/NitroEvent';
import { Nitro } from '../Nitro'; import { Nitro } from '../Nitro';
@ -66,7 +66,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);
@ -94,16 +94,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);
@ -111,7 +111,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);
@ -119,7 +119,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);
@ -130,9 +130,9 @@ export class AvatarAssetDownloadManager extends EventDispatcher
private onAvatarRenderReady(event: NitroEvent): void private onAvatarRenderReady(event: NitroEvent): void
{ {
if(!event) return; if (!event) return;
for(const [container, listener] of this._pendingContainers) for (const [container, listener] of this._pendingContainers)
{ {
this.downloadAvatarFigure(container, listener); this.downloadAvatarFigure(container, listener);
} }
@ -142,34 +142,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);
} }
@ -181,22 +181,22 @@ export class AvatarAssetDownloadManager extends EventDispatcher
} }
} }
for(const figure of loadedFigures) for (const figure of loadedFigures)
{ {
if(!figure) continue; if (!figure) continue;
this._incompleteFigures.delete(figure); 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++;
@ -207,19 +207,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;
} }
@ -233,38 +233,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);
} }
@ -276,7 +276,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]);
@ -286,13 +286,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 = [];
@ -304,24 +304,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);
@ -330,7 +330,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

@ -3,10 +3,10 @@ import { Container } from '@pixi/display';
import { ColorMatrixFilter } from '@pixi/filter-color-matrix'; import { ColorMatrixFilter } from '@pixi/filter-color-matrix';
import { Rectangle } from '@pixi/math'; import { Rectangle } from '@pixi/math';
import { Sprite } from '@pixi/sprite'; import { Sprite } from '@pixi/sprite';
import { IGraphicAsset } from '../../api';
import { NitroContainer, NitroSprite } from '../../core'; import { NitroContainer, NitroSprite } from '../../core';
import { AdvancedMap } from '../../core/utils/AdvancedMap'; import { AdvancedMap } from '../../core/utils/AdvancedMap';
import { PaletteMapFilter } from '../../core/utils/PaletteMapFilter'; import { PaletteMapFilter } from '../../core/utils/PaletteMapFilter';
import { IGraphicAsset } from '../../room/object/visualization/utils/IGraphicAsset';
import { TextureUtils } from '../../room/utils/TextureUtils'; import { TextureUtils } from '../../room/utils/TextureUtils';
import { Nitro } from '../Nitro'; import { Nitro } from '../Nitro';
import { ActiveActionData } from './actions/ActiveActionData'; import { ActiveActionData } from './actions/ActiveActionData';
@ -92,11 +92,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-');
} }
@ -120,7 +120,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;
@ -129,22 +129,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;
} }
@ -178,24 +178,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;
} }
@ -241,34 +241,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);
} }
@ -280,7 +280,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;
@ -293,18 +293,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);
@ -314,19 +314,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);
@ -346,16 +346,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
@ -368,7 +368,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;
@ -380,7 +380,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);
@ -392,13 +392,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);
@ -406,12 +406,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)
{ {
Nitro.instance.renderer.render(container, { Nitro.instance.renderer.render(container, {
renderTexture: this._reusableTexture, renderTexture: this._reusableTexture,
@ -423,7 +423,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)
@ -448,35 +448,35 @@ 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);
data[ i + 2] = (paletteColor & 0xFF); data[i + 2] = (paletteColor & 0xFF);
} }
} }
@ -494,13 +494,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();
@ -513,16 +513,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
@ -533,7 +533,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;
@ -559,29 +559,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
@ -592,7 +592,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;
@ -604,7 +604,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);
@ -620,7 +620,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;
} }
@ -629,9 +629,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);
@ -648,18 +648,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);
@ -690,15 +690,15 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
public endActionAppends(): void public endActionAppends(): void
{ {
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);
} }
} }
@ -712,14 +712,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:
@ -732,11 +732,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);
} }
@ -755,7 +755,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:
@ -779,9 +779,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;
} }
@ -792,7 +792,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;
} }
@ -801,16 +801,16 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
return true; return true;
} }
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;
} }
@ -843,14 +843,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;
} }
@ -862,7 +862,7 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
{ {
let _local_2: boolean; let _local_2: boolean;
let _local_3: boolean; let _local_3: boolean;
let _local_4:ActiveActionData; let _local_4: ActiveActionData;
let _local_5: number; let _local_5: number;
let k: boolean; let k: boolean;
@ -870,11 +870,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;
@ -885,15 +885,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;
@ -901,16 +901,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;
@ -925,60 +925,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 = Nitro.instance.time; const _local_3: number = Nitro.instance.time;
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;
} }
} }
} }
@ -987,15 +987,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);
@ -1006,11 +1006,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);
@ -1032,7 +1032,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;
@ -1100,7 +1100,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();
@ -1108,7 +1108,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

@ -1,7 +1,6 @@
import { IAssetManager } from '../../core/asset/IAssetManager'; import { IAssetManager, IGraphicAsset } from '../../api';
import { NitroManager } from '../../core/common/NitroManager'; import { NitroManager } from '../../core/common/NitroManager';
import { NitroEvent } from '../../core/events/NitroEvent'; import { NitroEvent } from '../../core/events/NitroEvent';
import { IGraphicAsset } from '../../room/object/visualization/utils/IGraphicAsset';
import { Nitro } from '../Nitro'; import { Nitro } from '../Nitro';
import { FigureDataContainer } from '../utils/FigureDataContainer'; import { FigureDataContainer } from '../utils/FigureDataContainer';
import { AssetAliasCollection } from './alias/AssetAliasCollection'; import { AssetAliasCollection } from './alias/AssetAliasCollection';
@ -86,7 +85,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);
@ -94,7 +93,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);
@ -107,14 +106,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);
@ -124,7 +123,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);
@ -135,7 +134,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);
@ -148,7 +147,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const defaultActions = Nitro.instance.getConfiguration<string>('avatar.default.actions'); const defaultActions = Nitro.instance.getConfiguration<string>('avatar.default.actions');
if(defaultActions) this._structure.initActions(Nitro.instance.core.asset, defaultActions); if (defaultActions) this._structure.initActions(Nitro.instance.core.asset, defaultActions);
const request = new XMLHttpRequest(); const request = new XMLHttpRequest();
@ -160,7 +159,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));
@ -183,7 +182,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);
@ -196,14 +195,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
const defaultFigureData = Nitro.instance.getConfiguration<IFigureData>('avatar.default.figuredata'); const defaultFigureData = Nitro.instance.getConfiguration<IFigureData>('avatar.default.figuredata');
if(!defaultFigureData || (typeof defaultFigureData === 'string')) if (!defaultFigureData || (typeof defaultFigureData === 'string'))
{ {
this.logger.error('XML figuredata is no longer supported'); this.logger.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(Nitro.instance.getConfiguration<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData)); const structureDownloader = new AvatarStructureDownload(Nitro.instance.getConfiguration<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData));
@ -221,7 +220,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaderReady(event: NitroEvent): void private onAvatarAssetDownloaderReady(event: NitroEvent): void
{ {
if(!event) return; if (!event) return;
this._figureMapReady = true; this._figureMapReady = true;
@ -230,14 +229,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onAvatarAssetDownloaded(event: NitroEvent): void private onAvatarAssetDownloaded(event: NitroEvent): void
{ {
if(!event) return; if (!event) return;
this._aliasCollection.reset(); this._aliasCollection.reset();
} }
private onEffectAssetDownloaderReady(event: NitroEvent): void private onEffectAssetDownloaderReady(event: NitroEvent): void
{ {
if(!event) return; if (!event) return;
this._effectMapReady = true; this._effectMapReady = true;
@ -246,20 +245,20 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private onEffectAssetDownloaded(event: NitroEvent): void private onEffectAssetDownloaded(event: NitroEvent): 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
@ -269,25 +268,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);
@ -296,7 +295,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);
} }
@ -307,17 +306,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]);
@ -328,15 +327,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]);
@ -353,49 +352,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;
@ -417,7 +416,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));
} }
@ -430,11 +429,11 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
const structure = this.structureData; const structure = this.structureData;
const partSets: IFigurePartSet[] = []; const partSets: IFigurePartSet[] = [];
for(const _local_4 of k) for (const _local_4 of k)
{ {
const partSet = structure.getFigurePartSet(_local_4); const partSet = structure.getFigurePartSet(_local_4);
if(partSet) partSets.push(partSet); if (partSet) partSets.push(partSet);
} }
return partSets; return partSets;
@ -442,7 +441,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);
} }
@ -469,7 +468,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

@ -1,6 +1,5 @@
import { Point } from '@pixi/math'; import { Point } from '@pixi/math';
import { IAssetManager } from '../../core/asset/IAssetManager'; import { IAssetAnimation, IAssetManager } from '../../api';
import { IAssetAnimation } from '../../core/asset/interfaces';
import { EventDispatcher } from '../../core/events/EventDispatcher'; import { EventDispatcher } from '../../core/events/EventDispatcher';
import { ActionDefinition } from './actions/ActionDefinition'; import { ActionDefinition } from './actions/ActionDefinition';
import { AvatarActionManager } from './actions/AvatarActionManager'; import { AvatarActionManager } from './actions/AvatarActionManager';
@ -61,7 +60,7 @@ export class AvatarStructure extends EventDispatcher
public dispose(): void public dispose(): void
{ {
if(this.disposed) return; if (this.disposed) return;
super.dispose(); super.dispose();
@ -74,14 +73,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();
@ -96,9 +95,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;
@ -111,14 +110,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);
} }
@ -132,11 +131,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;
@ -156,15 +155,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]);
} }
@ -203,7 +202,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));
} }
@ -212,12 +211,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];
} }
@ -254,16 +253,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: '',
@ -281,11 +280,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);
@ -295,30 +294,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);
} }
} }
@ -337,48 +336,48 @@ export class AvatarStructure extends EventDispatcher
return this._geometry.getBodyPartsAtAngle(k, _local_4, _arg_2); return this._geometry.getBodyPartsAtAngle(k, _local_4, _arg_2);
} }
public getFrameBodyPartOffset(k:IActiveActionData, _arg_2: number, _arg_3: number, _arg_4: string): Point public getFrameBodyPartOffset(k: IActiveActionData, _arg_2: number, _arg_3: number, _arg_4: string): Point
{ {
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;
} }
public getParts(k: string, _arg_2:IAvatarFigureContainer, _arg_3:IActiveActionData, _arg_4: string, _arg_5: number, removes: string[], _arg_7: IAvatarImage, _arg_8: Map<string, string> = null): AvatarImagePartContainer[] public getParts(k: string, _arg_2: IAvatarFigureContainer, _arg_3: IActiveActionData, _arg_4: string, _arg_5: number, removes: string[], _arg_7: IAvatarImage, _arg_8: Map<string, string> = null): AvatarImagePartContainer[]
{ {
const _local_10: Animation = null; const _local_10: Animation = null;
let _local_34: IActionDefinition = null; let _local_34: IActionDefinition = null;
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);
} }
@ -391,11 +390,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);
@ -404,27 +403,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;
} }
@ -440,15 +439,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)]);
} }
@ -466,18 +465,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;
} }
@ -485,31 +484,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;
} }
@ -529,11 +528,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)
{ {
// //
} }
@ -544,36 +543,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;
} }
@ -606,7 +605,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);
@ -618,13 +617,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

@ -1,5 +1,4 @@
import { IAssetManager } from '../../core/asset/IAssetManager'; import { IAssetAnimation, IAssetManager } from '../../api';
import { IAssetAnimation } from '../../core/asset/interfaces';
import { EventDispatcher } from '../../core/events/EventDispatcher'; import { EventDispatcher } from '../../core/events/EventDispatcher';
import { AvatarRenderEffectLibraryEvent } from './events/AvatarRenderEffectLibraryEvent'; import { AvatarRenderEffectLibraryEvent } from './events/AvatarRenderEffectLibraryEvent';
@ -34,16 +33,16 @@ export class EffectAssetDownloadLibrary extends EventDispatcher
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;
@ -56,13 +55,13 @@ export class EffectAssetDownloadLibrary extends EventDispatcher
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

@ -1,4 +1,4 @@
import { IAssetManager } from '../../core/asset/IAssetManager'; import { IAssetManager } from '../../api';
import { EventDispatcher } from '../../core/events/EventDispatcher'; import { EventDispatcher } from '../../core/events/EventDispatcher';
import { NitroEvent } from '../../core/events/NitroEvent'; import { NitroEvent } from '../../core/events/NitroEvent';
import { Nitro } from '../Nitro'; import { Nitro } from '../Nitro';
@ -65,7 +65,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);
@ -93,17 +93,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);
@ -113,7 +113,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);
@ -123,7 +123,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]);
@ -132,13 +132,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);
@ -147,24 +147,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: NitroEvent): void private onAvatarRenderReady(event: NitroEvent): void
{ {
if(!event) return; if (!event) return;
for(const [id, listener] of this._initDownloadBuffer) for (const [id, listener] of this._initDownloadBuffer)
{ {
this.downloadAvatarEffect(id, listener); this.downloadAvatarEffect(id, listener);
} }
@ -174,34 +174,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));
} }
@ -212,17 +212,17 @@ export class EffectAssetDownloadManager extends EventDispatcher
} }
} }
for(const id of loadedEffects) this._incompleteEffects.delete(id); for (const id of loadedEffects) this._incompleteEffects.delete(id);
let index = 0; 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++;
@ -233,19 +233,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;
} }
@ -259,17 +259,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);
} }
} }
@ -278,9 +278,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);
@ -289,7 +289,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

@ -1,7 +1,7 @@
import { RenderTexture } from '@pixi/core'; import { RenderTexture } from '@pixi/core';
import { Sprite } from '@pixi/sprite'; import { Sprite } from '@pixi/sprite';
import { IGraphicAsset } from '../../api';
import { IDisposable } from '../../core/common/disposable/IDisposable'; import { IDisposable } from '../../core/common/disposable/IDisposable';
import { IGraphicAsset } from '../../room/object/visualization/utils/IGraphicAsset';
import { IAnimationLayerData } from './animation/IAnimationLayerData'; import { IAnimationLayerData } from './animation/IAnimationLayerData';
import { IAvatarDataContainer } from './animation/IAvatarDataContainer'; import { IAvatarDataContainer } from './animation/IAvatarDataContainer';
import { ISpriteDataContainer } from './animation/ISpriteDataContainer'; import { ISpriteDataContainer } from './animation/ISpriteDataContainer';

View File

@ -1,6 +1,5 @@
import { IAssetManager } from '../../core/asset/IAssetManager'; import { IAssetManager, IGraphicAsset } from '../../api';
import { INitroManager } from '../../core/common/INitroManager'; import { INitroManager } from '../../core/common/INitroManager';
import { IGraphicAsset } from '../../room/object/visualization/utils/IGraphicAsset';
import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager'; import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager';
import { AvatarStructure } from './AvatarStructure'; import { AvatarStructure } from './AvatarStructure';
import { IAvatarEffectListener } from './IAvatarEffectListener'; import { IAvatarEffectListener } from './IAvatarEffectListener';

View File

@ -1,4 +1,4 @@
import { IAssetManager } from '../../../core/asset/IAssetManager'; import { IAssetManager } from '../../../api';
import { ActionDefinition } from './ActionDefinition'; import { ActionDefinition } from './ActionDefinition';
import { IActiveActionData } from './IActiveActionData'; import { IActiveActionData } from './IActiveActionData';
@ -19,53 +19,53 @@ 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);
const z = (canvasOffset.z || 0); const z = (canvasOffset.z || 0);
action.setOffsets(size, direction, [ x, y, z ]); action.setOffsets(size, direction, [x, y, z]);
} }
} }
} }
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;
} }
@ -77,18 +77,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;
@ -102,14 +102,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;
@ -117,19 +117,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;
@ -146,24 +146,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);
} }
@ -173,14 +173,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

@ -1,4 +1,4 @@
import { IAssetAlias } from '../../../core/asset/interfaces'; import { IAssetAlias } from '../../../api';
export class AssetAlias export class AssetAlias
{ {

View File

@ -1,5 +1,4 @@
import { IAssetManager } from '../../../core/asset/IAssetManager'; import { IAssetManager, IGraphicAsset } from '../../../api';
import { IGraphicAsset } from '../../../room/object/visualization/utils/IGraphicAsset';
import { AvatarRenderManager } from '../AvatarRenderManager'; import { AvatarRenderManager } from '../AvatarRenderManager';
import { AssetAlias } from './AssetAlias'; import { AssetAlias } from './AssetAlias';
@ -31,19 +30,19 @@ export class AssetAliasCollection
public init(): void public init(): void
{ {
for(const collection of this._assets.collections.values()) for (const collection of this._assets.collections.values())
{ {
if(!collection) continue; if (!collection) continue;
const aliases = collection.data && collection.data.aliases; const aliases = collection.data && collection.data.aliases;
if(!aliases) continue; if (!aliases) continue;
for(const name in aliases) for (const name in aliases)
{ {
const alias = aliases[name]; const alias = aliases[name];
if(!alias) continue; if (!alias) continue;
this._aliases.set(name, new AssetAlias(name, alias)); this._aliases.set(name, new AssetAlias(name, alias));
} }
@ -54,7 +53,7 @@ export class AssetAliasCollection
{ {
const alias = this._aliases.get(k); const alias = this._aliases.get(k);
if(alias) return true; if (alias) return true;
return false; return false;
} }
@ -64,7 +63,7 @@ export class AssetAliasCollection
let _local_2 = k; let _local_2 = k;
let _local_3 = 5; let _local_3 = 5;
while(this.hasAlias(_local_2) && (_local_3 >= 0)) while (this.hasAlias(_local_2) && (_local_3 >= 0))
{ {
const _local_4 = this._aliases.get(_local_2); const _local_4 = this._aliases.get(_local_2);
@ -77,13 +76,13 @@ export class AssetAliasCollection
public getAsset(name: string): IGraphicAsset public getAsset(name: string): IGraphicAsset
{ {
if(!this._assets) return null; if (!this._assets) return null;
name = this.getAssetName(name); name = this.getAssetName(name);
const asset = this._assets.getAsset(name); const asset = this._assets.getAsset(name);
if(!asset) return null; if (!asset) return null;
return asset; return asset;
} }

View File

@ -1,4 +1,4 @@
import { IAssetAnimationAdd } from '../../../core/asset/interfaces'; import { IAssetAnimationAdd } from '../../../api';
export class AddDataContainer export class AddDataContainer
{ {
@ -18,13 +18,13 @@ export class AddDataContainer
const _local_2 = k.blend; const _local_2 = k.blend;
if(_local_2) if (_local_2)
{ {
if(_local_2.length > 0) if (_local_2.length > 0)
{ {
this._blend = parseInt(_local_2); this._blend = parseInt(_local_2);
if(this._blend > 1) this._blend = (this._blend / 100); if (this._blend > 1) this._blend = (this._blend / 100);
} }
} }
} }

View File

@ -1,4 +1,4 @@
import { IAssetAnimation, IAssetAnimationFrame } from '../../../core/asset/interfaces'; import { IAssetAnimation, IAssetAnimationFrame } from '../../../api';
import { AvatarStructure } from '../AvatarStructure'; import { AvatarStructure } from '../AvatarStructure';
import { AddDataContainer } from './AddDataContainer'; import { AddDataContainer } from './AddDataContainer';
import { AvatarAnimationLayerData } from './AvatarAnimationLayerData'; import { AvatarAnimationLayerData } from './AvatarAnimationLayerData';
@ -37,37 +37,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;
@ -87,23 +87,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);
@ -112,9 +112,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);
@ -132,13 +132,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;
@ -146,38 +146,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)];
} }
@ -186,7 +186,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)];
} }
@ -195,24 +195,24 @@ export class Animation implements IAnimation
return layers; return layers;
} }
public getAnimatedBodyPartIds(k: number, _arg_2: string=null): string[] public getAnimatedBodyPartIds(k: number, _arg_2: string = null): string[]
{ {
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);
} }
} }
} }
@ -223,17 +223,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;
} }
} }
} }
@ -259,11 +259,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

@ -1,4 +1,4 @@
import { IAssetAnimation } from '../../../core/asset/interfaces'; import { IAssetAnimation } from '../../../api';
import { AvatarStructure } from '../AvatarStructure'; import { AvatarStructure } from '../AvatarStructure';
import { Animation } from './Animation'; import { Animation } from './Animation';
import { IAnimation } from './IAnimation'; import { IAnimation } from './IAnimation';
@ -29,7 +29,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;
} }
@ -38,7 +38,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

@ -1,4 +1,4 @@
import { IAssetAnimationFramePart } from '../../../core/asset/interfaces/animation/IAssetAnimationFramePart'; import { IAssetAnimationFramePart } from '../../../api';
import { ActiveActionData } from '../actions/ActiveActionData'; import { ActiveActionData } from '../actions/ActiveActionData';
import { IActionDefinition } from '../actions/IActionDefinition'; import { IActionDefinition } from '../actions/IActionDefinition';
import { IActiveActionData } from '../actions/IActiveActionData'; import { IActiveActionData } from '../actions/IActiveActionData';
@ -32,13 +32,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;
@ -55,7 +55,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

@ -1,5 +1,5 @@
import { AdjustmentFilter } from '@pixi/filter-adjustment'; import { AdjustmentFilter } from '@pixi/filter-adjustment';
import { IAssetAnimationAvatar } from '../../../core/asset/interfaces'; import { IAssetAnimationAvatar } from '../../../api';
import { IAvatarDataContainer } from './IAvatarDataContainer'; import { IAvatarDataContainer } from './IAvatarDataContainer';
export class AvatarDataContainer implements IAvatarDataContainer export class AvatarDataContainer implements IAvatarDataContainer
@ -42,7 +42,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;
@ -111,9 +111,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

@ -1,4 +1,4 @@
import { IAssetAnimationDirection } from '../../../core/asset/interfaces'; import { IAssetAnimationDirection } from '../../../api';
export class DirectionDataContainer export class DirectionDataContainer
{ {

View File

@ -1,4 +1,4 @@
import { IAssetAnimationSprite } from '../../../core/asset/interfaces'; import { IAssetAnimationSprite } from '../../../api';
import { IAnimation } from './IAnimation'; import { IAnimation } from './IAnimation';
import { ISpriteDataContainer } from './ISpriteDataContainer'; import { ISpriteDataContainer } from './ISpriteDataContainer';
@ -28,13 +28,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);
@ -45,21 +45,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

@ -24,20 +24,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 = Nitro.instance.getConfiguration<string>('image.library.url') + 'Habbo-Stories/'; const imagesUrl = Nitro.instance.getConfiguration<string>('image.library.url') + 'Habbo-Stories/';
const effects = Nitro.instance.getConfiguration<{ name: string, colorMatrix?: ColorMatrix, minLevel: number, blendMode?: number, enabled: boolean }[]>('camera.available.effects'); const effects = Nitro.instance.getConfiguration<{ 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;
} }
@ -60,20 +60,22 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
container.addChild(sprite); container.addChild(sprite);
for(const selectedEffect of selectedEffects) if (isZoomed) sprite.scale.set(2);
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

@ -1,7 +1,7 @@
import { BaseTexture, Resource, Texture } from '@pixi/core'; import { BaseTexture, Resource, Texture } from '@pixi/core';
import { Loader, LoaderResource } from '@pixi/loaders'; import { Loader, LoaderResource } from '@pixi/loaders';
import { Spritesheet } from '@pixi/spritesheet'; import { Spritesheet } from '@pixi/spritesheet';
import { IAssetData } from '../../core/asset/interfaces'; import { IAssetData, IGraphicAssetCollection } from '../../api';
import { NitroBundle } from '../../core/asset/NitroBundle'; import { NitroBundle } from '../../core/asset/NitroBundle';
import { INitroLogger } from '../../core/common/logger/INitroLogger'; import { INitroLogger } from '../../core/common/logger/INitroLogger';
import { NitroLogger } from '../../core/common/logger/NitroLogger'; import { NitroLogger } from '../../core/common/logger/NitroLogger';
@ -11,7 +11,6 @@ import { RoomContentLoadedEvent } from '../../room/events/RoomContentLoadedEvent
import { IRoomObject } from '../../room/object/IRoomObject'; import { IRoomObject } from '../../room/object/IRoomObject';
import { GraphicAssetCollection } from '../../room/object/visualization/utils/GraphicAssetCollection'; import { GraphicAssetCollection } from '../../room/object/visualization/utils/GraphicAssetCollection';
import { GraphicAssetGifCollection } from '../../room/object/visualization/utils/GraphicAssetGifCollection'; import { GraphicAssetGifCollection } from '../../room/object/visualization/utils/GraphicAssetGifCollection';
import { IGraphicAssetCollection } from '../../room/object/visualization/utils/IGraphicAssetCollection';
import { Nitro } from '../Nitro'; import { Nitro } from '../Nitro';
import { FurnitureType } from '../session/furniture/FurnitureType'; import { FurnitureType } from '../session/furniture/FurnitureType';
import { IFurnitureData } from '../session/furniture/IFurnitureData'; import { IFurnitureData } from '../session/furniture/IFurnitureData';
@ -98,7 +97,7 @@ export class RoomContentLoader implements IFurnitureDataListener
this.setFurnitureData(); this.setFurnitureData();
for(const [index, name] of Nitro.instance.getConfiguration<string[]>('pet.types').entries()) this._pets[name] = index; for (const [index, name] of Nitro.instance.getConfiguration<string[]>('pet.types').entries()) this._pets[name] = index;
} }
public dispose(): void public dispose(): void
@ -110,7 +109,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
this._sessionDataManager = sessionData; this._sessionDataManager = sessionData;
if(this._waitingForSessionDataManager) if (this._waitingForSessionDataManager)
{ {
this._waitingForSessionDataManager = false; this._waitingForSessionDataManager = false;
@ -125,7 +124,7 @@ export class RoomContentLoader implements IFurnitureDataListener
private setFurnitureData(): void private setFurnitureData(): void
{ {
if(!this._sessionDataManager) if (!this._sessionDataManager)
{ {
this._waitingForSessionDataManager = true; this._waitingForSessionDataManager = true;
@ -134,7 +133,7 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
@ -145,42 +144,42 @@ export class RoomContentLoader implements IFurnitureDataListener
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';
@ -189,12 +188,12 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
@ -213,7 +212,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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);
} }
@ -222,7 +221,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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);
} }
@ -231,29 +230,29 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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);
} }
@ -262,7 +261,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const value = this._objectTypeAdUrls.get(type); const value = this._objectTypeAdUrls.get(type);
if(!value) return ''; if (!value) return '';
return value; return value;
} }
@ -271,7 +270,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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);
} }
@ -281,11 +280,11 @@ export class RoomContentLoader implements IFurnitureDataListener
const colorResults = this._petColors.get(petIndex); const colorResults = this._petColors.get(petIndex);
const results: PetColorResult[] = []; const results: PetColorResult[] = [];
if(colorResults) if (colorResults)
{ {
for(const result of colorResults.values()) for (const result of colorResults.values())
{ {
if(result.tag === tagName) results.push(result); if (result.tag === tagName) results.push(result);
} }
} }
@ -294,15 +293,15 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
@ -317,18 +316,18 @@ export class RoomContentLoader implements IFurnitureDataListener
public getGifCollection(name: string): GraphicAssetGifCollection public getGifCollection(name: string): GraphicAssetGifCollection
{ {
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();
@ -341,14 +340,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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);
@ -359,7 +358,7 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
@ -367,12 +366,12 @@ export class RoomContentLoader implements IFurnitureDataListener
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, PetColorResult> = new Map(); const palettes: Map<number, PetColorResult> = 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];
@ -395,14 +394,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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;
} }
@ -410,27 +409,27 @@ export class RoomContentLoader implements IFurnitureDataListener
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;
} }
@ -444,7 +443,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
type = RoomObjectUserType.getRealType(type); type = RoomObjectUserType.getRealType(type);
if(type === RoomObjectVisualizationType.USER) return false; if (type === RoomObjectVisualizationType.USER) return false;
return true; return true;
} }
@ -454,13 +453,13 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
} }
@ -469,7 +468,7 @@ export class RoomContentLoader implements IFurnitureDataListener
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];
@ -505,18 +504,18 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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({
@ -531,7 +530,7 @@ export class RoomContentLoader implements IFurnitureDataListener
const onDownloaded = (status: boolean, url: string) => const onDownloaded = (status: boolean, url: string) =>
{ {
if(!status) if (!status)
{ {
this._logger.error('Failed to download asset', url); this._logger.error('Failed to download asset', url);
@ -544,13 +543,13 @@ export class RoomContentLoader implements IFurnitureDataListener
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));
@ -560,11 +559,11 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
@ -573,7 +572,7 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
@ -592,7 +591,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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);
@ -613,7 +612,7 @@ export class RoomContentLoader implements IFurnitureDataListener
}); });
}; };
if(baseTexture.valid) if (baseTexture.valid)
{ {
createAsset(); createAsset();
} }
@ -633,7 +632,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
const existing = this._objectAliases.get(name); const existing = this._objectAliases.get(name);
if(!existing) return name; if (!existing) return name;
return existing; return existing;
} }
@ -642,14 +641,14 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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)];
@ -666,13 +665,13 @@ export class RoomContentLoader implements IFurnitureDataListener
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))));
@ -682,7 +681,7 @@ export class RoomContentLoader implements IFurnitureDataListener
return [assetUrl]; return [assetUrl];
} }
if(category === RoomObjectCategory.UNIT) if (category === RoomObjectCategory.UNIT)
{ {
return [this.getAssetUrlWithPetBase(type)]; return [this.getAssetUrlWithPetBase(type)];
} }
@ -697,14 +696,14 @@ export class RoomContentLoader implements IFurnitureDataListener
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);
} }
@ -713,7 +712,7 @@ export class RoomContentLoader implements IFurnitureDataListener
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;
} }
@ -742,7 +741,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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);
} }
@ -751,7 +750,7 @@ export class RoomContentLoader implements IFurnitureDataListener
{ {
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;
} }

View File

@ -1,4 +1,4 @@
import { IAssetData } from '../../../core/asset/interfaces'; import { IAssetData } from '../../../api';
import { NitroLogger } from '../../../core/common/logger/NitroLogger'; import { NitroLogger } from '../../../core/common/logger/NitroLogger';
import { IRoomObjectGraphicVisualization } from '../../../room/object/visualization/IRoomObjectGraphicVisualization'; import { IRoomObjectGraphicVisualization } from '../../../room/object/visualization/IRoomObjectGraphicVisualization';
import { IObjectVisualizationData } from '../../../room/object/visualization/IRoomObjectVisualizationData'; import { IObjectVisualizationData } from '../../../room/object/visualization/IRoomObjectVisualizationData';
@ -63,18 +63,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;
@ -185,7 +185,7 @@ export class RoomObjectVisualizationFactory implements IRoomObjectVisualizationF
break; break;
} }
if(!visualization) if (!visualization)
{ {
NitroLogger.log('Unknown Visualization', type); NitroLogger.log('Unknown Visualization', type);
@ -199,11 +199,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:
@ -255,21 +255,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomToObjectOwnAvatarMoveEvent } from '../../../events/RoomToObjectOwnAvatarMoveEvent'; import { RoomToObjectOwnAvatarMoveEvent } from '../../../events/RoomToObjectOwnAvatarMoveEvent';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureLogic } from './FurnitureLogic'; import { FurnitureLogic } from './FurnitureLogic';
@ -16,33 +16,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);
} }
@ -51,4 +51,4 @@ export class FurnitureChangeStateWhenStepOnLogic extends FurnitureLogic
this.object.setState(0, 0); this.object.setState(0, 0);
} }
} }
} }

View File

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core'; import { IAssetData } from '../../../../../api';
import { RoomObjectUpdateMessage } from '../../../../../room'; import { RoomObjectUpdateMessage } from '../../../../../room';
import { RoomObjectWidgetRequestEvent } from '../../../events'; import { RoomObjectWidgetRequestEvent } from '../../../events';
import { ObjectDataUpdateMessage } from '../../../messages'; import { ObjectDataUpdateMessage } from '../../../messages';
@ -9,7 +9,7 @@ export class FurnitureClothingChangeLogic extends FurnitureLogic
{ {
public getEventTypes(): string[] public getEventTypes(): string[]
{ {
const types = [ RoomObjectWidgetRequestEvent.CLOTHING_CHANGE ]; const types = [RoomObjectWidgetRequestEvent.CLOTHING_CHANGE];
return this.mergeTypes(super.getEventTypes(), types); return this.mergeTypes(super.getEventTypes(), types);
} }
@ -27,22 +27,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent'; import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureLogic } from './FurnitureLogic'; import { FurnitureLogic } from './FurnitureLogic';
@ -20,9 +20,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);
@ -30,7 +30,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent'; import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic'; import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic';
@ -18,12 +18,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent'; import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent';
import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry'; import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry';
import { MouseEventType } from '../../../../ui/MouseEventType'; import { MouseEventType } from '../../../../ui/MouseEventType';
@ -21,7 +21,7 @@ export class FurnitureEditableInternalLinkLogic extends FurnitureLogic
public getEventTypes(): string[] public getEventTypes(): string[]
{ {
const types = [ RoomObjectWidgetRequestEvent.INERNAL_LINK ]; const types = [RoomObjectWidgetRequestEvent.INERNAL_LINK];
return this.mergeTypes(super.getEventTypes(), types); return this.mergeTypes(super.getEventTypes(), types);
} }
@ -30,11 +30,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;
} }
} }
} }
@ -43,11 +43,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);
@ -57,9 +57,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);
} }
@ -67,9 +67,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);
} }
@ -79,7 +79,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent'; import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureLogic } from './FurnitureLogic'; import { FurnitureLogic } from './FurnitureLogic';
@ -9,7 +9,7 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
public getEventTypes(): string[] public getEventTypes(): string[]
{ {
const types = [ RoomObjectWidgetRequestEvent.ROOM_LINK ]; const types = [RoomObjectWidgetRequestEvent.ROOM_LINK];
return this.mergeTypes(super.getEventTypes(), types); return this.mergeTypes(super.getEventTypes(), types);
} }
@ -18,11 +18,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));
} }
@ -32,7 +32,7 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
protected onDispose(): void protected onDispose(): void
{ {
if(this._timer) if (this._timer)
{ {
clearTimeout(this._timer); clearTimeout(this._timer);
@ -44,9 +44,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);
} }
@ -56,7 +56,7 @@ export class FurnitureEditableRoomLinkLogic extends FurnitureLogic
{ {
this.setAutomaticStateIndex(1); this.setAutomaticStateIndex(1);
if(this._timer) if (this._timer)
{ {
clearTimeout(this._timer); clearTimeout(this._timer);
@ -70,7 +70,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomObjectWidgetRequestEvent } from '../../../events'; import { RoomObjectWidgetRequestEvent } from '../../../events';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic'; import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic';
@ -18,15 +18,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);
@ -36,7 +36,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

@ -1,4 +1,4 @@
import { IAssetData, IParticleSystem } from '../../../../../core'; import { IAssetData, IParticleSystem } from '../../../../../api';
import { RoomObjectEvent } from '../../../../../room/events/RoomObjectEvent'; import { RoomObjectEvent } from '../../../../../room/events/RoomObjectEvent';
import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent'; import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent';
import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry'; import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry';
@ -11,7 +11,7 @@ export class FurnitureFireworksLogic extends FurnitureLogic
{ {
public getEventTypes(): string[] public getEventTypes(): string[]
{ {
const types = [ RoomObjectStateChangedEvent.STATE_CHANGE ]; const types = [RoomObjectStateChangedEvent.STATE_CHANGE];
return this.mergeTypes(super.getEventTypes(), types); return this.mergeTypes(super.getEventTypes(), types);
} }
@ -20,9 +20,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);
} }
@ -31,14 +31,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);
@ -48,7 +48,7 @@ export class FurnitureFireworksLogic extends FurnitureLogic
break; break;
} }
if(this.eventDispatcher && objectEvent) if (this.eventDispatcher && objectEvent)
{ {
this.eventDispatcher.dispatchEvent(objectEvent); this.eventDispatcher.dispatchEvent(objectEvent);
@ -62,7 +62,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage'; import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage';
import { ContextMenuEnum } from '../../../../ui'; import { ContextMenuEnum } from '../../../../ui';
import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent'; import { RoomObjectWidgetRequestEvent } from '../../../events/RoomObjectWidgetRequestEvent';
@ -19,16 +19,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;
} }
@ -43,16 +43,16 @@ export class FurnitureFriendFurniLogic extends FurnitureMultiStateLogic
public getEventTypes(): string[] public getEventTypes(): string[]
{ {
const types = [ RoomObjectWidgetRequestEvent.FRIEND_FURNITURE_ENGRAVING ]; const types = [RoomObjectWidgetRequestEvent.FRIEND_FURNITURE_ENGRAVING];
return this.mergeTypes(super.getEventTypes(), types); return this.mergeTypes(super.getEventTypes(), types);
} }
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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent'; import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent';
import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry'; import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry';
import { MouseEventType } from '../../../../ui/MouseEventType'; import { MouseEventType } from '../../../../ui/MouseEventType';
@ -24,13 +24,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;
} }
} }
} }
@ -39,11 +39,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);
@ -53,9 +53,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);
} }
@ -63,9 +63,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);
} }
@ -75,7 +75,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomObjectMouseEvent } from '../../../../../room/events/RoomObjectMouseEvent'; import { RoomObjectMouseEvent } from '../../../../../room/events/RoomObjectMouseEvent';
import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent'; import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent';
import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage'; import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage';
@ -61,12 +61,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 = Nitro.instance.getConfiguration<number>('furni.rotation.bounce.steps', 8); FurnitureLogic.BOUNCING_STEPS = Nitro.instance.getConfiguration<number>('furni.rotation.bounce.steps', 8);
} }
if(FurnitureLogic.BOUNCING_Z === -1) if (FurnitureLogic.BOUNCING_Z === -1)
{ {
FurnitureLogic.BOUNCING_Z = Nitro.instance.getConfiguration<number>('furni.rotation.bounce.height', 0.0625); FurnitureLogic.BOUNCING_Z = Nitro.instance.getConfiguration<number>('furni.rotation.bounce.height', 0.0625);
} }
@ -82,30 +82,30 @@ export class FurnitureLogic extends MovingObjectLogic
RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_SHOW, RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_SHOW,
RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_HIDE, RoomObjectRoomAdEvent.ROOM_AD_TOOLTIP_HIDE,
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;
@ -118,19 +118,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);
} }
@ -159,7 +159,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
@ -167,9 +167,9 @@ export class FurnitureLogic extends MovingObjectLogic
return model.getValue<string>(RoomObjectVariable.FURNITURE_AD_URL); return model.getValue<string>(RoomObjectVariable.FURNITURE_AD_URL);
} }
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));
} }
@ -178,31 +178,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);
@ -211,16 +211,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);
@ -233,9 +233,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;
@ -248,27 +248,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);
} }
@ -277,10 +277,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);
@ -293,11 +293,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));
} }
@ -316,11 +316,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));
} }
@ -342,7 +342,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);
@ -353,16 +353,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);
@ -370,7 +370,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);
@ -382,20 +382,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);
@ -411,27 +411,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

@ -1,4 +1,4 @@
import { IAssetData } from '../../../../../core/asset/interfaces'; import { IAssetData } from '../../../../../api';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic'; import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic';
@ -8,6 +8,6 @@ export class FurnitureMultiHeightLogic extends FurnitureMultiStateLogic
{ {
super.initialize(asset); super.initialize(asset);
if(this.object && this.object.model) this.object.model.setValue(RoomObjectVariable.FURNITURE_IS_VARIABLE_HEIGHT, 1); if (this.object && this.object.model) this.object.model.setValue(RoomObjectVariable.FURNITURE_IS_VARIABLE_HEIGHT, 1);
} }
} }

View File

@ -1,4 +1,4 @@
import { IAssetData, IAssetLogicPlanetSystem } from '../../../../../core/asset/interfaces'; import { IAssetData, IAssetLogicPlanetSystem } from '../../../../../api';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureLogic } from './FurnitureLogic'; import { FurnitureLogic } from './FurnitureLogic';
@ -8,9 +8,9 @@ export class FurniturePlanetSystemLogic extends FurnitureLogic
{ {
super.initialize(asset); super.initialize(asset);
if(asset.logic) if (asset.logic)
{ {
if(asset.logic.planetSystems) if (asset.logic.planetSystems)
{ {
this.object.model.setValue<IAssetLogicPlanetSystem[]>(RoomObjectVariable.FURNITURE_PLANETSYSTEM_DATA, asset.logic.planetSystems); this.object.model.setValue<IAssetLogicPlanetSystem[]>(RoomObjectVariable.FURNITURE_PLANETSYSTEM_DATA, asset.logic.planetSystems);
} }

View File

@ -1,4 +1,4 @@
import { IAssetData, IParticleSystem } from '../../../../../core/asset/interfaces'; import { IAssetData, IParticleSystem } from '../../../../../api';
import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent'; import { RoomSpriteMouseEvent } from '../../../../../room/events/RoomSpriteMouseEvent';
import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage'; import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage';
import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry'; import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry';
@ -32,9 +32,9 @@ export class FurniturePresentLogic 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);
} }
@ -45,16 +45,16 @@ export class FurniturePresentLogic 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);
this.updateStuffData(); this.updateStuffData();
} }
if(message instanceof ObjectModelDataUpdateMessage) if (message instanceof ObjectModelDataUpdateMessage)
{ {
if(message.numberKey === RoomObjectVariable.FURNITURE_DISABLE_PICKING_ANIMATION) if (message.numberKey === RoomObjectVariable.FURNITURE_DISABLE_PICKING_ANIMATION)
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_DISABLE_PICKING_ANIMATION, message.numberValue); this.object.model.setValue(RoomObjectVariable.FURNITURE_DISABLE_PICKING_ANIMATION, message.numberValue);
} }
@ -63,7 +63,7 @@ export class FurniturePresentLogic extends FurnitureLogic
private updateStuffData(): void private updateStuffData(): void
{ {
if(!this.object || !this.object.model) return; if (!this.object || !this.object.model) return;
const stuffData = new MapDataType(); const stuffData = new MapDataType();
@ -72,7 +72,7 @@ export class FurniturePresentLogic extends FurnitureLogic
const message = stuffData.getValue(FurniturePresentLogic.MESSAGE); const message = stuffData.getValue(FurniturePresentLogic.MESSAGE);
const data = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_DATA); const data = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_DATA);
if(!message && (typeof data === 'string')) if (!message && (typeof data === 'string'))
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_DATA, data.substr(1)); this.object.model.setValue(RoomObjectVariable.FURNITURE_DATA, data.substr(1));
} }
@ -88,16 +88,16 @@ export class FurniturePresentLogic extends FurnitureLogic
private writeToModel(key: string, value: string): void private writeToModel(key: string, value: string): void
{ {
if(!value) return; if (!value) return;
this.object.model.setValue(key, value); this.object.model.setValue(key, value);
} }
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.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_BUTTON, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectFurnitureActionEvent(RoomObjectFurnitureActionEvent.MOUSE_BUTTON, this.object));
@ -112,7 +112,7 @@ export class FurniturePresentLogic 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.PRESENT, this.object)); this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.PRESENT, this.object));
} }

View File

@ -1,6 +1,6 @@
import { BaseTexture, Texture } from '@pixi/core'; import { BaseTexture, Texture } from '@pixi/core';
import { decompressFrames, parseGIF } from 'gifuct-js'; import { decompressFrames, parseGIF } from 'gifuct-js';
import { IAssetData } from '../../../../../core'; import { IAssetData } from '../../../../../api';
import { IRoomGeometry, RoomSpriteMouseEvent } from '../../../../../room'; import { IRoomGeometry, RoomSpriteMouseEvent } from '../../../../../room';
import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage'; import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage';
import { Nitro } from '../../../../Nitro'; import { Nitro } from '../../../../Nitro';
@ -35,7 +35,7 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
public getEventTypes(): string[] public getEventTypes(): string[]
{ {
const types = [ RoomObjectRoomAdEvent.ROOM_AD_LOAD_IMAGE ]; const types = [RoomObjectRoomAdEvent.ROOM_AD_LOAD_IMAGE];
return this.mergeTypes(super.getEventTypes(), types); return this.mergeTypes(super.getEventTypes(), types);
} }
@ -44,7 +44,7 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
{ {
super.initialize(asset); super.initialize(asset);
if(this._disableFurnitureSelection) if (this._disableFurnitureSelection)
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_SELECTION_DISABLED, 1); this.object.model.setValue(RoomObjectVariable.FURNITURE_SELECTION_DISABLED, 1);
} }
@ -54,14 +54,14 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
if(message instanceof ObjectDataUpdateMessage) this.processAdDataUpdateMessage(message); if (message instanceof ObjectDataUpdateMessage) this.processAdDataUpdateMessage(message);
if(message instanceof ObjectAdUpdateMessage) this.processAdUpdate(message); if (message instanceof ObjectAdUpdateMessage) this.processAdUpdate(message);
} }
private processAdDataUpdateMessage(message: ObjectDataUpdateMessage): void private processAdDataUpdateMessage(message: ObjectDataUpdateMessage): void
{ {
if(!message) return; if (!message) return;
const objectData = new MapDataType(); const objectData = new MapDataType();
@ -69,12 +69,12 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
const state = parseInt(objectData.getValue(FurnitureRoomBrandingLogic.STATE)); const state = parseInt(objectData.getValue(FurnitureRoomBrandingLogic.STATE));
if(!isNaN(state) && (this.object.getState(0) !== state)) this.object.setState(state, 0); if (!isNaN(state) && (this.object.getState(0) !== state)) this.object.setState(state, 0);
const imageUrl = objectData.getValue(FurnitureRoomBrandingLogic.IMAGEURL_KEY); const imageUrl = objectData.getValue(FurnitureRoomBrandingLogic.IMAGEURL_KEY);
const existingUrl = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_URL); const existingUrl = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_URL);
if(!existingUrl || (existingUrl !== imageUrl)) if (!existingUrl || (existingUrl !== imageUrl))
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_URL, imageUrl); this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_URL, imageUrl);
this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_STATUS, 0); this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_STATUS, 0);
@ -84,13 +84,13 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
const clickUrl = objectData.getValue(FurnitureRoomBrandingLogic.CLICKURL_KEY); const clickUrl = objectData.getValue(FurnitureRoomBrandingLogic.CLICKURL_KEY);
if(clickUrl) if (clickUrl)
{ {
const existingUrl = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_BRANDING_URL); const existingUrl = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_BRANDING_URL);
if(!existingUrl || existingUrl !== clickUrl) if (!existingUrl || existingUrl !== clickUrl)
{ {
if(this.object.model) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_URL, clickUrl); if (this.object.model) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_URL, clickUrl);
} }
} }
@ -98,13 +98,13 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
const offsetY = parseInt(objectData.getValue(FurnitureRoomBrandingLogic.OFFSETY_KEY)); const offsetY = parseInt(objectData.getValue(FurnitureRoomBrandingLogic.OFFSETY_KEY));
const offsetZ = parseInt(objectData.getValue(FurnitureRoomBrandingLogic.OFFSETZ_KEY)); const offsetZ = parseInt(objectData.getValue(FurnitureRoomBrandingLogic.OFFSETZ_KEY));
if(!isNaN(offsetX)) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_X, offsetX); if (!isNaN(offsetX)) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_X, offsetX);
if(!isNaN(offsetY)) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_Y, offsetY); if (!isNaN(offsetY)) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_Y, offsetY);
if(!isNaN(offsetZ)) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_Z, offsetZ); if (!isNaN(offsetZ)) this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_Z, offsetZ);
let options = (((FurnitureRoomBrandingLogic.IMAGEURL_KEY + '=') + ((imageUrl !== null) ? imageUrl : '')) + '\t'); let options = (((FurnitureRoomBrandingLogic.IMAGEURL_KEY + '=') + ((imageUrl !== null) ? imageUrl : '')) + '\t');
if(this._hasClickUrl) if (this._hasClickUrl)
{ {
options = (options + (((FurnitureRoomBrandingLogic.CLICKURL_KEY + '=') + ((clickUrl !== null) ? clickUrl : '')) + '\t')); options = (options + (((FurnitureRoomBrandingLogic.CLICKURL_KEY + '=') + ((clickUrl !== null) ? clickUrl : '')) + '\t'));
} }
@ -118,9 +118,9 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
private processAdUpdate(message: ObjectAdUpdateMessage): void private processAdUpdate(message: ObjectAdUpdateMessage): void
{ {
if(!message || !this.object) return; if (!message || !this.object) return;
switch(message.type) switch (message.type)
{ {
case ObjectAdUpdateMessage.IMAGE_LOADED: case ObjectAdUpdateMessage.IMAGE_LOADED:
this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_STATUS, 1); this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_STATUS, 1);
@ -133,9 +133,9 @@ export class FurnitureRoomBrandingLogic 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.MOUSE_MOVE) || (event.type === MouseEventType.DOUBLE_CLICK)) return; if ((event.type === MouseEventType.MOUSE_MOVE) || (event.type === MouseEventType.DOUBLE_CLICK)) return;
super.mouseEvent(event, geometry); super.mouseEvent(event, geometry);
} }
@ -144,14 +144,14 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
{ {
const model = this.object && this.object.model; const model = this.object && this.object.model;
if(!model) return; if (!model) return;
const imageUrl = model.getValue<string>(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_URL); const imageUrl = model.getValue<string>(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_URL);
const imageStatus = model.getValue<number>(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_STATUS); const imageStatus = model.getValue<number>(RoomObjectVariable.FURNITURE_BRANDING_IMAGE_STATUS);
if(!imageUrl || (imageUrl === '') || (imageStatus === 1)) return; if (!imageUrl || (imageUrl === '') || (imageStatus === 1)) return;
if(imageUrl.endsWith('.gif')) if (imageUrl.endsWith('.gif'))
{ {
this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IS_ANIMATED, true); this.object.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_IS_ANIMATED, true);
@ -169,30 +169,30 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
let frame = new Uint8Array(wh * 4); let frame = new Uint8Array(wh * 4);
for(let ind = 0; ind < frames.length; ind++) for (let ind = 0; ind < frames.length; ind++)
{ {
if(ind > 0) frame = frame.slice(0); if (ind > 0) frame = frame.slice(0);
const pixels = frames[ind].pixels; const pixels = frames[ind].pixels;
const colorTable = frames[ind].colorTable; const colorTable = frames[ind].colorTable;
const trans = frames[ind].transparentIndex; const trans = frames[ind].transparentIndex;
const dims = frames[ind].dims; const dims = frames[ind].dims;
for(let j = 0; j < dims.height; j++) for (let j = 0; j < dims.height; j++)
{ {
for(let i = 0; i < dims.width; i++) for (let i = 0; i < dims.width; i++)
{ {
const pixel = pixels[j*dims.width + i]; const pixel = pixels[j * dims.width + i];
const coord = (j + dims.top) * width + (i + dims.left); const coord = (j + dims.top) * width + (i + dims.left);
if(trans !== pixel) if (trans !== pixel)
{ {
const c = colorTable[pixel]; const c = colorTable[pixel];
frame[ 4 * coord ] = c[0]; frame[4 * coord] = c[0];
frame[ 4 * coord + 1 ] = c[1]; frame[4 * coord + 1] = c[1];
frame[ 4 * coord + 2 ] = c[2]; frame[4 * coord + 2] = c[2];
frame[ 4 * coord + 3 ] = 255; frame[4 * coord + 3] = 255;
} }
} }
} }
@ -216,15 +216,15 @@ export class FurnitureRoomBrandingLogic extends FurnitureLogic
{ {
const asset = Nitro.instance.core && Nitro.instance.core.asset; const asset = Nitro.instance.core && Nitro.instance.core.asset;
if(!asset) return; if (!asset) return;
const texture = asset.getTexture(imageUrl); const texture = asset.getTexture(imageUrl);
if(!texture) if (!texture)
{ {
asset.downloadAsset(imageUrl, (flag: boolean) => asset.downloadAsset(imageUrl, (flag: boolean) =>
{ {
if(flag) if (flag)
{ {
this.processUpdateMessage(new ObjectAdUpdateMessage(ObjectAdUpdateMessage.IMAGE_LOADED)); this.processUpdateMessage(new ObjectAdUpdateMessage(ObjectAdUpdateMessage.IMAGE_LOADED));
} }

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