This commit is contained in:
Bill 2022-12-15 13:51:10 -05:00
parent def234e058
commit a67b9daaaa
182 changed files with 2835 additions and 4179 deletions

View File

@ -1,16 +0,0 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

135
.eslintrc.json Normal file
View File

@ -0,0 +1,135 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"no-multi-spaces": [
"error"
],
"no-trailing-spaces": [
"error",
{
"skipBlankLines": false,
"ignoreComments": true
}
],
"linebreak-style": [
"off"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"brace-style": [
"error",
"allman"
],
"object-curly-spacing": [
"error",
"always"
],
"keyword-spacing": [
"error",
{
"overrides":
{
"if":
{
"after": false
},
"for":
{
"after": false
},
"while":
{
"after": false
},
"switch":
{
"after": false
}
}
}
],
"@typescript-eslint/no-explicit-any": [
"off"
],
"@typescript-eslint/explicit-module-boundary-types": [
"off",
{
"allowedNames": [
"getMessageArray"
]
}
],
"@typescript-eslint/ban-ts-comment": [
"off"
],
"@typescript-eslint/no-empty-function": [
"error",
{
"allow": [
"functions",
"arrowFunctions",
"generatorFunctions",
"methods",
"generatorMethods",
"constructors"
]
}
],
"@typescript-eslint/no-unused-vars": [
"off"
],
"@typescript-eslint/no-inferrable-types": [
"error",
{
"ignoreParameters": true,
"ignoreProperties": true
}
],
"@typescript-eslint/ban-types": [
"error",
{
"types":
{
"String": true,
"Boolean": true,
"Number": true,
"Symbol": true,
"{}": false,
"Object": false,
"object": false,
"Function": false
},
"extendDefaults": true
}
]
}
}

24
.vscode/settings.json vendored
View File

@ -4,13 +4,27 @@
"typescript.preferences.quoteStyle": "single", "typescript.preferences.quoteStyle": "single",
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true, "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"typescript.format.placeOpenBraceOnNewLineForFunctions": true, "typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"editor.wordWrap": "on",
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll": true, "source.fixAll.eslint": true,
"source.organizeImports": true, "source.fixAll.sortJSON": false,
"source.organizeImports": true
}, },
"emmet.showExpandedAbbreviation": "never", "editor.formatOnSave": false,
"git.ignoreLimitWarning": true, "git.ignoreLimitWarning": true,
"files.eol": "\n", "files.eol": "\n",
"files.insertFinalNewline": true, "files.insertFinalNewline": true,
"files.trimFinalNewlines": true "files.trimFinalNewlines": true,
"emmet.showExpandedAbbreviation": "never",
"eslint.format.enable": true,
"eslint.validate": [
"javascript",
"typescript"
],
"eslint.workingDirectories": [
{
"pattern": "./src/*"
}
],
"javascript.format.enable": false
} }

View File

@ -1,2 +0,0 @@
require('dotenv').config();
require('./src/main');

3208
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,24 +5,26 @@
"main": "index.ts", "main": "index.ts",
"dependencies": { "dependencies": {
"bytebuffer": "^5.0.1", "bytebuffer": "^5.0.1",
"canvas": "^2.8.0", "canvas": "^2.10.2",
"chalk": "^4.1.2", "cli-color": "^2.0.3",
"dotenv": "^10.0.0", "dotenv": "^16.0.3",
"express": "^4.17.1", "express": "^4.18.2",
"gifencoder": "^2.0.1", "gifencoder": "^2.0.1",
"node-fetch": "^2.6.1", "node-fetch": "^2.0.0",
"pako": "^2.0.4" "pako": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/bytebuffer": "^5.0.42", "@types/bytebuffer": "^5.0.44",
"@types/chalk": "^2.2.0", "@types/cli-color": "^2.0.2",
"@types/express": "^4.17.13", "@types/express": "^4.17.15",
"@types/gifencoder": "^2.0.1", "@types/gifencoder": "^2.0.1",
"@types/node": "^14.17.12", "@types/node": "^18.11.15",
"@types/node-fetch": "^2.5.12", "@types/pako": "^2.0.0",
"@types/pako": "^1.0.2", "@typescript-eslint/eslint-plugin": "^5.46.1",
"ts-node-dev": "^1.1.8", "@typescript-eslint/parser": "^5.46.1",
"typescript": "^4.4.2" "eslint": "^8.29.0",
"ts-node-dev": "^2.0.0",
"typescript": "^4.9.4"
}, },
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",

View File

@ -1,76 +0,0 @@
import * as express from 'express';
import { INitroCore, NitroManager } from '../core';
import { AvatarRenderManager, IAvatarRenderManager } from './avatar';
import { IApplication } from './IApplication';
import { HttpRouter } from './router/HttpRouter';
export class Application extends NitroManager implements IApplication
{
private static INSTANCE: IApplication = null;
private _core: INitroCore;
private _avatar: IAvatarRenderManager;
constructor(core: INitroCore)
{
super();
Application.INSTANCE = this;
this._core = core;
this._avatar = new AvatarRenderManager(core.asset);
}
protected async onInit(): Promise<void>
{
if(this._core) await this._core.init();
if(this._avatar) await this._avatar.init();
this.setupRouter();
this.logger.log(`Initialized`);
}
protected async onDispose(): Promise<void>
{
if(this._avatar) await this._avatar.dispose();
if(this._core) await this._core.dispose();
}
public getConfiguration<T>(key: string, value: T = null): T
{
return this._core.configuration.getValue<T>(key, value);
}
private setupRouter(): void
{
const router = express();
router.use('/', HttpRouter);
const host = (process.env.API_HOST as string);
const port = parseInt(process.env.API_PORT);
router.listen(port, host, () =>
{
this.logger.log(`Server Started ${ host }:${ port }`);
});
}
public get core(): INitroCore
{
return this._core;
}
public get avatar(): IAvatarRenderManager
{
return this._avatar;
}
public static get instance(): IApplication
{
return this.INSTANCE;
}
}

View File

@ -1,9 +0,0 @@
import { INitroCore, INitroManager } from '../core';
import { IAvatarRenderManager } from './avatar';
export interface IApplication extends INitroManager
{
getConfiguration<T>(key: string, value?: T): T;
core: INitroCore;
avatar: IAvatarRenderManager;
}

View File

@ -1,18 +0,0 @@
import { AssetAliasCollection } from './alias';
import { AvatarFigureContainer } from './AvatarFigureContainer';
import { AvatarImage } from './AvatarImage';
import { AvatarStructure } from './AvatarStructure';
import { EffectAssetDownloadManager } from './EffectAssetDownloadManager';
export class PlaceHolderAvatarImage extends AvatarImage
{
constructor(k: AvatarStructure, _arg_2: AssetAliasCollection, _arg_3: AvatarFigureContainer, _arg_4: string, _arg_5: EffectAssetDownloadManager)
{
super(k, _arg_2, _arg_3, _arg_4, _arg_5);
}
public isPlaceholder(): boolean
{
return true;
}
}

View File

@ -1,3 +0,0 @@
export * from './Application';
export * from './avatar';
export * from './IApplication';

View File

@ -1,6 +0,0 @@
import { Router } from 'express';
import { HabboImagingRouter } from './habbo-imaging';
export const HttpRouter = Router();
HttpRouter.use('/', HabboImagingRouter);

View File

@ -1,6 +0,0 @@
import { Router } from 'express';
import { HabboImagingRouterGet } from './handlers';
export const HabboImagingRouter = Router();
HabboImagingRouter.get('/', HabboImagingRouterGet);

View File

@ -1 +0,0 @@
export * from './HabboImagingRouterGet';

View File

@ -1 +0,0 @@
export * from './HabboImagingRouter';

View File

@ -1,4 +1,4 @@
import { IAssetManager } from '../../core'; import { AssetManager } from '../core';
export class AvatarAssetDownloadLibrary export class AvatarAssetDownloadLibrary
{ {
@ -10,15 +10,13 @@ export class AvatarAssetDownloadLibrary
private _libraryName: string; private _libraryName: string;
private _revision: string; private _revision: string;
private _downloadUrl: string; private _downloadUrl: string;
private _assets: IAssetManager;
constructor(id: string, revision: string, assets: IAssetManager, assetUrl: string) constructor(id: string, revision: string, assetUrl: string)
{ {
this._state = AvatarAssetDownloadLibrary.NOT_LOADED; this._state = AvatarAssetDownloadLibrary.NOT_LOADED;
this._libraryName = id; this._libraryName = id;
this._revision = revision; this._revision = revision;
this._downloadUrl = assetUrl; this._downloadUrl = assetUrl;
this._assets = assets;
this._downloadUrl = this._downloadUrl.replace(/%libname%/gi, this._libraryName); this._downloadUrl = this._downloadUrl.replace(/%libname%/gi, this._libraryName);
this._downloadUrl = this._downloadUrl.replace(/%revision%/gi, this._revision); this._downloadUrl = this._downloadUrl.replace(/%revision%/gi, this._revision);
@ -30,7 +28,7 @@ export class AvatarAssetDownloadLibrary
{ {
if(this._state === AvatarAssetDownloadLibrary.LOADED) return true; if(this._state === AvatarAssetDownloadLibrary.LOADED) return true;
const asset = this._assets.getCollection(this._libraryName); const asset = AssetManager.getCollection(this._libraryName);
if(asset) if(asset)
{ {
@ -44,13 +42,13 @@ export class AvatarAssetDownloadLibrary
public async downloadAsset(): Promise<boolean> public async downloadAsset(): Promise<boolean>
{ {
if(!this._assets || (this._state === AvatarAssetDownloadLibrary.LOADING)) return false; if(this._state === AvatarAssetDownloadLibrary.LOADING) return false;
if(this.checkIfAssetLoaded()) return false; if(this.checkIfAssetLoaded()) return false;
this._state = AvatarAssetDownloadLibrary.LOADING; this._state = AvatarAssetDownloadLibrary.LOADING;
if(!await this._assets.downloadAsset(this._downloadUrl)) return false; if(!await AssetManager.downloadAsset(this._downloadUrl)) return false;
this._state = AvatarAssetDownloadLibrary.LOADED; this._state = AvatarAssetDownloadLibrary.LOADED;

View File

@ -1,33 +1,28 @@
import { AdvancedMap, FileUtilities, IAssetManager } from '../../core'; import { AdvancedMap, ConfigurationManager, FileUtilities } from '../core';
import { Application } from '../Application';
import { AvatarAssetDownloadLibrary } from './AvatarAssetDownloadLibrary'; import { AvatarAssetDownloadLibrary } from './AvatarAssetDownloadLibrary';
import { AvatarStructure } from './AvatarStructure'; import { AvatarStructure } from './AvatarStructure';
import { IAvatarFigureContainer } from './IAvatarFigureContainer'; import { IAvatarFigureContainer } from './IAvatarFigureContainer';
export class AvatarAssetDownloadManager export class AvatarAssetDownloadManager
{ {
private _assets: IAssetManager;
private _structure: AvatarStructure; private _structure: AvatarStructure;
private _missingMandatoryLibs: string[]; private _missingMandatoryLibs: string[] = [];
private _figureMap: AdvancedMap<string, AvatarAssetDownloadLibrary[]>; private _figureMap: AdvancedMap<string, AvatarAssetDownloadLibrary[]> = new AdvancedMap();
private _libraryNames: string[]; private _libraryNames: string[] = [];
constructor(assets: IAssetManager, structure: AvatarStructure) constructor(structure: AvatarStructure)
{ {
this._assets = assets;
this._structure = structure; this._structure = structure;
this._missingMandatoryLibs = Application.instance.getConfiguration<string[]>('avatar.mandatory.libraries'); this._missingMandatoryLibs = ConfigurationManager.getValue<string[]>('avatar.mandatory.libraries');
this._figureMap = new AdvancedMap();
this._libraryNames = [];
} }
public async loadFigureMap(): Promise<void> public async loadFigureMap(): Promise<void>
{ {
const url = (process.env.AVATAR_FIGUREMAP_URL as string); const url = (process.env.AVATAR_FIGUREMAP_URL as string);
if(!url || !url.length) return Promise.reject('invalid_figuremap_url'); if(!url || !url.length) throw new Error('invalid_figuremap_url');
const data = await FileUtilities.readFileAsString(url); const data = await FileUtilities.readFileAsString(url);
const json = JSON.parse(data); const json = JSON.parse(data);
@ -56,7 +51,7 @@ export class AvatarAssetDownloadManager
this._libraryNames.push(id); this._libraryNames.push(id);
const downloadLibrary = new AvatarAssetDownloadLibrary(id, revision, this._assets, url); const downloadLibrary = new AvatarAssetDownloadLibrary(id, revision, url);
for(const part of library.parts) for(const part of library.parts)
{ {

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../core'; import { AdvancedMap } from '../core';
import { IAvatarFigureContainer } from './IAvatarFigureContainer'; import { IAvatarFigureContainer } from './IAvatarFigureContainer';
export class AvatarFigureContainer implements IAvatarFigureContainer export class AvatarFigureContainer implements IAvatarFigureContainer
@ -97,9 +97,9 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
if(pieces.length >= 2) if(pieces.length >= 2)
{ {
const type = pieces[0]; const type = pieces[0];
const setId = parseInt(pieces[1]); const setId = parseInt(pieces[1]);
const colors = []; const colors = [];
let index = 2; let index = 2;

View File

@ -1,5 +1,5 @@
import { Canvas } from 'canvas'; import { Canvas } from 'canvas';
import { CanvasUtilities, IGraphicAsset } from '../../core'; import { CanvasUtilities, IGraphicAsset } from '../core';
import { ActiveActionData, IActionDefinition, IActiveActionData } from './actions'; import { ActiveActionData, IActionDefinition, IActiveActionData } from './actions';
import { AssetAliasCollection } from './alias'; import { AssetAliasCollection } from './alias';
import { IAnimationLayerData, IAvatarDataContainer, ISpriteDataContainer } from './animation'; import { IAnimationLayerData, IAvatarDataContainer, ISpriteDataContainer } from './animation';
@ -14,15 +14,15 @@ import { IPartColor } from './structure';
export class AvatarImage implements IAvatarImage export class AvatarImage implements IAvatarImage
{ {
private static CHANNELS_EQUAL: string = 'CHANNELS_EQUAL'; private static CHANNELS_EQUAL: string = 'CHANNELS_EQUAL';
private static CHANNELS_UNIQUE: string = 'CHANNELS_UNIQUE'; private static CHANNELS_UNIQUE: string = 'CHANNELS_UNIQUE';
private static CHANNELS_RED: string = 'CHANNELS_RED'; private static CHANNELS_RED: string = 'CHANNELS_RED';
private static CHANNELS_GREEN: string = 'CHANNELS_GREEN'; private static CHANNELS_GREEN: string = 'CHANNELS_GREEN';
private static CHANNELS_BLUE: string = 'CHANNELS_BLUE'; private static CHANNELS_BLUE: string = 'CHANNELS_BLUE';
private static CHANNELS_DESATURATED: string = 'CHANNELS_DESATURATED'; private static CHANNELS_DESATURATED: string = 'CHANNELS_DESATURATED';
private static DEFAULT_ACTION: string = 'Default'; private static DEFAULT_ACTION: string = 'Default';
private static DEFAULT_DIRECTION: number = 2; private static DEFAULT_DIRECTION: number = 2;
private static DEFAULT_AVATAR_SET: string = AvatarSetType.FULL; private static DEFAULT_AVATAR_SET: string = AvatarSetType.FULL;
protected _structure: AvatarStructure; protected _structure: AvatarStructure;
protected _scale: string; protected _scale: string;
@ -299,13 +299,15 @@ export class AvatarImage implements IAvatarImage
ctx.fillStyle = null; ctx.fillStyle = null;
} }
let partCount = (bodyParts.length - 1); let partCount = (bodyParts.length - 1);
while(partCount >= 0) while(partCount >= 0)
{ {
const set = bodyParts[partCount]; const set = bodyParts[partCount];
const part = this._cache.getImageContainer(set, this._frameCounter); const part = this._cache.getImageContainer(set, this._frameCounter);
console.log(part);
if(part) if(part)
{ {
const partCacheContainer = part.image; const partCacheContainer = part.image;
@ -614,8 +616,8 @@ export class AvatarImage implements IAvatarImage
{ {
if(!this._sortedActions == null) return; if(!this._sortedActions == null) return;
const _local_3: number = 0; const _local_3 = 0;
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);

View File

@ -1,5 +1,5 @@
import { Canvas } from 'canvas'; import { Canvas } from 'canvas';
import { Point } from '../../core'; import { Point } from '../core';
export class AvatarImageBodyPartContainer export class AvatarImageBodyPartContainer
{ {
@ -10,19 +10,19 @@ export class AvatarImageBodyPartContainer
constructor(image: Canvas, regPoint: Point, isCacheable: boolean) constructor(image: Canvas, regPoint: Point, isCacheable: boolean)
{ {
this._image = image; this._image = image;
this._regPoint = regPoint; this._regPoint = regPoint;
this._offset = new Point(0, 0); this._offset = new Point(0, 0);
this._isCacheable = isCacheable; this._isCacheable = isCacheable;
this.cleanPoints(); this.cleanPoints();
} }
public dispose(): void public dispose(): void
{ {
this._image = null; this._image = null;
this._regPoint = null; this._regPoint = null;
this._offset = null; this._offset = null;
} }
private cleanPoints(): void private cleanPoints(): void

View File

@ -1,6 +1,5 @@
import { IActionDefinition } from './actions/IActionDefinition'; import { IActionDefinition } from './actions';
import { AvatarAnimationFrame } from './structure/animation/AvatarAnimationFrame'; import { AvatarAnimationFrame, IPartColor } from './structure';
import { IPartColor } from './structure/figure/IPartColor';
export class AvatarImagePartContainer export class AvatarImagePartContainer
{ {
@ -17,16 +16,16 @@ export class AvatarImagePartContainer
constructor(k: string, _arg_2: string, _arg_3: string, _arg_4: IPartColor, _arg_5: AvatarAnimationFrame[], _arg_6: IActionDefinition, _arg_7: boolean, _arg_8: number, _arg_9: string = '', _arg_10: boolean = false, _arg_11: number = 1) constructor(k: string, _arg_2: string, _arg_3: string, _arg_4: IPartColor, _arg_5: AvatarAnimationFrame[], _arg_6: IActionDefinition, _arg_7: boolean, _arg_8: number, _arg_9: string = '', _arg_10: boolean = false, _arg_11: number = 1)
{ {
this._bodyPartId = k; this._bodyPartId = k;
this._partType = _arg_2; this._partType = _arg_2;
this._partId = _arg_3; this._partId = _arg_3;
this._color = _arg_4; this._color = _arg_4;
this._frames = _arg_5; this._frames = _arg_5;
this._action = _arg_6; this._action = _arg_6;
this._isColorable = _arg_7; this._isColorable = _arg_7;
this._paletteMapId = _arg_8; this._paletteMapId = _arg_8;
this._flippedPartType = _arg_9; this._flippedPartType = _arg_9;
this._isBlendable = _arg_10; this._isBlendable = _arg_10;
if(this._partType === 'ey') this._isColorable = false; if(this._partType === 'ey') this._isColorable = false;
} }

View File

@ -1,5 +1,4 @@
import { FileUtilities, IAssetManager, IGraphicAsset, NitroManager } from '../../core'; import { ConfigurationManager, FileUtilities, IGraphicAsset } from '../core';
import { Application } from '../Application';
import { AssetAliasCollection } from './alias'; import { AssetAliasCollection } from './alias';
import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager'; import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager';
import { AvatarFigureContainer } from './AvatarFigureContainer'; import { AvatarFigureContainer } from './AvatarFigureContainer';
@ -15,53 +14,50 @@ import { IAvatarRenderManager } from './IAvatarRenderManager';
import { IFigureData } from './interfaces'; import { IFigureData } from './interfaces';
import { IFigurePartSet, IStructureData } from './structure'; import { IFigurePartSet, IStructureData } from './structure';
export class AvatarRenderManager extends NitroManager implements IAvatarRenderManager export class AvatarRenderManager implements IAvatarRenderManager
{ {
private static INSTANCE: AvatarRenderManager = null;
public static DEFAULT_FIGURE: string = 'hd-99999-99999'; public static DEFAULT_FIGURE: string = 'hd-99999-99999';
private _aliasCollection: AssetAliasCollection; private _aliasCollection: AssetAliasCollection = null;
private _assets: IAssetManager; private _structure: AvatarStructure = null;
private _structure: AvatarStructure; private _avatarAssetDownloadManager: AvatarAssetDownloadManager = null;
private _avatarAssetDownloadManager: AvatarAssetDownloadManager; private _effectAssetDownloadManager: EffectAssetDownloadManager = null;
private _effectAssetDownloadManager: EffectAssetDownloadManager;
private _placeHolderFigure: AvatarFigureContainer;
constructor(assets: IAssetManager) public static async init(): Promise<void>
{ {
super(); if(!AvatarRenderManager.INSTANCE) AvatarRenderManager.INSTANCE = new AvatarRenderManager();
this._assets = assets; await AvatarRenderManager.instance.init();
this._structure = null;
this._avatarAssetDownloadManager = null;
this._effectAssetDownloadManager = null;
this._placeHolderFigure = null;
} }
public async onInit(): Promise<void> public async init(): Promise<void>
{ {
this._structure = new AvatarStructure(this); this._structure = new AvatarStructure(this);
this._structure.initGeometry(HabboAvatarGeometry.geometry); this._structure.initGeometry(HabboAvatarGeometry.geometry);
this._structure.initPartSets(HabboAvatarPartSets.partSets); this._structure.initPartSets(HabboAvatarPartSets.partSets);
this._structure.initAnimation(HabboAvatarAnimations.animations); this._structure.initAnimation(HabboAvatarAnimations.animations);
await this.loadActions(); await this.loadActions();
await this.loadFigureData(); await this.loadFigureData();
this._aliasCollection = new AssetAliasCollection(this, this._assets); this._aliasCollection = new AssetAliasCollection(this);
this._aliasCollection.init(); this._aliasCollection.init();
if(!this._avatarAssetDownloadManager) if(!this._avatarAssetDownloadManager)
{ {
this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(this._assets, this._structure); this._avatarAssetDownloadManager = new AvatarAssetDownloadManager(this._structure);
await this._avatarAssetDownloadManager.loadFigureMap(); await this._avatarAssetDownloadManager.loadFigureMap();
} }
if(!this._effectAssetDownloadManager) if(!this._effectAssetDownloadManager)
{ {
this._effectAssetDownloadManager = new EffectAssetDownloadManager(this._assets, this._structure); this._effectAssetDownloadManager = new EffectAssetDownloadManager(this._structure);
await this._effectAssetDownloadManager.loadEffectMap(); await this._effectAssetDownloadManager.loadEffectMap();
} }
@ -70,23 +66,23 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private async loadActions(): Promise<void> private async loadActions(): Promise<void>
{ {
this._structure.initActions({ this._structure.initActions({
"actions": [ 'actions': [
{ {
"id": "Default", 'id': 'Default',
"state": "std", 'state': 'std',
"precedence": 1000, 'precedence': 1000,
"main": true, 'main': true,
"isDefault": true, 'isDefault': true,
"geometryType": "vertical", 'geometryType': 'vertical',
"activePartSet": "figure", 'activePartSet': 'figure',
"assetPartDefinition": "std" 'assetPartDefinition': 'std'
} }
] ]
}); });
const url = (process.env.AVATAR_ACTIONS_URL as string); const url = (process.env.AVATAR_ACTIONS_URL as string);
if(!url || !url.length) return Promise.reject('invalid_actions_url'); if(!url || !url.length) throw new Error(`Invalid avatar actions url: ${ url }`);
const data = await FileUtilities.readFileAsString(url); const data = await FileUtilities.readFileAsString(url);
@ -95,13 +91,13 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private async loadFigureData(): Promise<void> private async loadFigureData(): Promise<void>
{ {
const defaultFigureData = Application.instance.getConfiguration<IFigureData>('avatar.default.figuredata'); const defaultFigureData = ConfigurationManager.getValue<IFigureData>('avatar.default.figuredata');
if(this._structure) this._structure.initFigureData(defaultFigureData); if(this._structure) this._structure.initFigureData(defaultFigureData);
const url = (process.env.AVATAR_FIGUREDATA_URL as string); const url = (process.env.AVATAR_FIGUREDATA_URL as string);
if(!url || !url.length) return Promise.reject('invalid_figuredata_url'); if(!url || !url.length) throw new Error('invalid_figuredata_url');
const data = await FileUtilities.readFileAsString(url); const data = await FileUtilities.readFileAsString(url);
@ -120,6 +116,13 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
return this._avatarAssetDownloadManager.isAvatarFigureContainerReady(container); return this._avatarAssetDownloadManager.isAvatarFigureContainerReady(container);
} }
public async downloadAvatarFigure(container: IAvatarFigureContainer): Promise<void>
{
if(!this._avatarAssetDownloadManager) return;
await this._avatarAssetDownloadManager.downloadAvatarFigure(container);
}
public async createAvatarImage(figure: string, size: string, gender: string): Promise<IAvatarImage> public async createAvatarImage(figure: string, size: string, gender: string): Promise<IAvatarImage>
{ {
if(!this._structure || !this._avatarAssetDownloadManager) return null; if(!this._structure || !this._avatarAssetDownloadManager) return null;
@ -128,23 +131,14 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
if(gender) this.validateAvatarFigure(figureContainer, gender); if(gender) this.validateAvatarFigure(figureContainer, gender);
if(!this._avatarAssetDownloadManager.isAvatarFigureContainerReady(figureContainer)) if(!this.isFigureContainerReady(figureContainer))
{ {
await this._avatarAssetDownloadManager.downloadAvatarFigure(figureContainer); await this.downloadAvatarFigure(figureContainer);
} }
if(!this._placeHolderFigure) this._placeHolderFigure = new AvatarFigureContainer(AvatarRenderManager.DEFAULT_FIGURE);
return new AvatarImage(this._structure, this._aliasCollection, figureContainer, size, this._effectAssetDownloadManager); return new AvatarImage(this._structure, this._aliasCollection, figureContainer, size, this._effectAssetDownloadManager);
} }
public async downloadAvatarFigure(container: IAvatarFigureContainer): Promise<void>
{
if(!this._avatarAssetDownloadManager) return;
await this._avatarAssetDownloadManager.downloadAvatarFigure(container);
}
private validateAvatarFigure(container: AvatarFigureContainer, gender: string): boolean private validateAvatarFigure(container: AvatarFigureContainer, gender: string): boolean
{ {
let isValid = false; let isValid = false;
@ -199,23 +193,23 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
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);
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)
{ {
@ -241,7 +235,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
public isValidFigureSetForGender(setId: number, gender: string): boolean public isValidFigureSetForGender(setId: number, gender: string): boolean
{ {
const structure = this.structureData; const structure = this.structureData;
const partSet = structure.getFigurePartSet(setId); const partSet = structure.getFigurePartSet(setId);
return !!(partSet && ((partSet.gender.toUpperCase() === 'U') || (partSet.gender.toUpperCase() === gender.toUpperCase()))); return !!(partSet && ((partSet.gender.toUpperCase() === 'U') || (partSet.gender.toUpperCase() === gender.toUpperCase())));
} }
@ -264,8 +258,8 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
private resolveFigureSets(k: number[]): IFigurePartSet[] private resolveFigureSets(k: number[]): IFigurePartSet[]
{ {
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)
{ {
@ -289,11 +283,6 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
return this._aliasCollection.getAsset(name); return this._aliasCollection.getAsset(name);
} }
public get assets(): IAssetManager
{
return this._assets;
}
public get structure(): AvatarStructure public get structure(): AvatarStructure
{ {
return this._structure; return this._structure;
@ -315,4 +304,9 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa
{ {
return this._effectAssetDownloadManager; return this._effectAssetDownloadManager;
} }
public static get instance(): AvatarRenderManager
{
return AvatarRenderManager.INSTANCE;
}
} }

View File

@ -1,4 +1,4 @@
import { AdvancedMap, IAssetAnimation, IAssetManager, Point } from '../../core'; import { AdvancedMap, AssetManager, IAssetAnimation, Point } from '../core';
import { ActionDefinition, AvatarActionManager, IActionDefinition, IActiveActionData } from './actions'; import { ActionDefinition, AvatarActionManager, IActionDefinition, IActiveActionData } from './actions';
import { Animation, AnimationManager, AvatarAnimationLayerData } from './animation'; import { Animation, AnimationManager, AvatarAnimationLayerData } from './animation';
import { AvatarImagePartContainer } from './AvatarImagePartContainer'; import { AvatarImagePartContainer } from './AvatarImagePartContainer';
@ -104,13 +104,13 @@ export class AvatarStructure
this._figureData.injectJSON(data); this._figureData.injectJSON(data);
} }
public registerAnimations(k: IAssetManager, _arg_2: string = 'fx', _arg_3: number = 200): void public registerAnimations(name: string = 'fx', _arg_3: number = 200): void
{ {
let index = 0; let index = 0;
while(index < _arg_3) while(index < _arg_3)
{ {
const collection = k.getCollection((_arg_2 + index)); const collection = AssetManager.getCollection((name + index));
if(collection) if(collection)
{ {
@ -227,8 +227,8 @@ export class AvatarStructure
{ {
let _local_3: string[] = []; let _local_3: string[] = [];
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)
{ {
@ -332,10 +332,10 @@ export class AvatarStructure
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)
{ {
@ -364,8 +364,8 @@ export class AvatarStructure
} }
} }
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)
{ {
@ -445,7 +445,7 @@ export class AvatarStructure
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.getValue(_local_12))); const _local_40 = ((_arg_8) && (_arg_8.getValue(_local_12)));

View File

@ -1,4 +1,4 @@
import { IAssetAnimation, IAssetManager } from '../../core'; import { AssetManager, IAssetAnimation } from '../core';
export class EffectAssetDownloadLibrary export class EffectAssetDownloadLibrary
{ {
@ -10,16 +10,14 @@ export class EffectAssetDownloadLibrary
private _libraryName: string; private _libraryName: string;
private _revision: string; private _revision: string;
private _downloadUrl: string; private _downloadUrl: string;
private _assets: IAssetManager;
private _animation: { [index: string]: IAssetAnimation }; private _animation: { [index: string]: IAssetAnimation };
constructor(id: string, revision: string, assets: IAssetManager, assetUrl: string) constructor(id: string, revision: string, assetUrl: string)
{ {
this._state = EffectAssetDownloadLibrary.NOT_LOADED; this._state = EffectAssetDownloadLibrary.NOT_LOADED;
this._libraryName = id; this._libraryName = id;
this._revision = revision; this._revision = revision;
this._downloadUrl = assetUrl; this._downloadUrl = assetUrl;
this._assets = assets;
this._animation = null; this._animation = null;
this._downloadUrl = this._downloadUrl.replace(/%libname%/gi, this._libraryName); this._downloadUrl = this._downloadUrl.replace(/%libname%/gi, this._libraryName);
@ -32,7 +30,7 @@ export class EffectAssetDownloadLibrary
{ {
if(this._state === EffectAssetDownloadLibrary.LOADED) return true; if(this._state === EffectAssetDownloadLibrary.LOADED) return true;
const asset = this._assets.getCollection(this._libraryName); const asset = AssetManager.getCollection(this._libraryName);
if(asset) if(asset)
{ {
@ -46,15 +44,15 @@ export class EffectAssetDownloadLibrary
public async downloadAsset(): Promise<boolean> public async downloadAsset(): Promise<boolean>
{ {
if(!this._assets || (this._state === EffectAssetDownloadLibrary.LOADING)) return; if(this._state === EffectAssetDownloadLibrary.LOADING) return;
if(this.checkIfAssetLoaded()) return true; if(this.checkIfAssetLoaded()) return true;
this._state = EffectAssetDownloadLibrary.LOADING; this._state = EffectAssetDownloadLibrary.LOADING;
if(!await this._assets.downloadAsset(this._downloadUrl)) return false; if(!await AssetManager.downloadAsset(this._downloadUrl)) return false;
const collection = this._assets.getCollection(this._libraryName); const collection = AssetManager.getCollection(this._libraryName);
if(collection) this._animation = collection.data.animations; if(collection) this._animation = collection.data.animations;

View File

@ -1,32 +1,27 @@
import { AdvancedMap, FileUtilities, IAssetManager } from '../../core'; import { AdvancedMap, ConfigurationManager, FileUtilities } from '../core';
import { Application } from '../Application';
import { AvatarStructure } from './AvatarStructure'; import { AvatarStructure } from './AvatarStructure';
import { EffectAssetDownloadLibrary } from './EffectAssetDownloadLibrary'; import { EffectAssetDownloadLibrary } from './EffectAssetDownloadLibrary';
export class EffectAssetDownloadManager export class EffectAssetDownloadManager
{ {
private _assets: IAssetManager;
private _structure: AvatarStructure; private _structure: AvatarStructure;
private _missingMandatoryLibs: string[]; private _missingMandatoryLibs: string[] = [];
private _effectMap: AdvancedMap<string, EffectAssetDownloadLibrary[]>; private _effectMap: AdvancedMap<string, EffectAssetDownloadLibrary[]> = new AdvancedMap();
private _libraryNames: string[]; private _libraryNames: string[] = [];
constructor(assets: IAssetManager, structure: AvatarStructure) constructor(structure: AvatarStructure)
{ {
this._assets = assets;
this._structure = structure; this._structure = structure;
this._missingMandatoryLibs = Application.instance.getConfiguration<string[]>('avatar.mandatory.effect.libraries'); this._missingMandatoryLibs = ConfigurationManager.getValue<string[]>('avatar.mandatory.effect.libraries');
this._effectMap = new AdvancedMap();
this._libraryNames = [];
} }
public async loadEffectMap(): Promise<void> public async loadEffectMap(): Promise<void>
{ {
const url = (process.env.AVATAR_EFFECTMAP_URL as string); const url = (process.env.AVATAR_EFFECTMAP_URL as string);
if(!url || !url.length) return Promise.reject('invalid_effectmap_url'); if(!url || !url.length) throw new Error('invalid_effectmap_url');
const data = await FileUtilities.readFileAsString(url); const data = await FileUtilities.readFileAsString(url);
const json = JSON.parse(data); const json = JSON.parse(data);
@ -56,7 +51,7 @@ export class EffectAssetDownloadManager
this._libraryNames.push(lib); this._libraryNames.push(lib);
const downloadLibrary = new EffectAssetDownloadLibrary(lib, revision, this._assets, url); const downloadLibrary = new EffectAssetDownloadLibrary(lib, revision, url);
let existing = this._effectMap.getValue(id); let existing = this._effectMap.getValue(id);

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../core'; import { AdvancedMap } from '../core';
export class FigureDataContainer export class FigureDataContainer
{ {
@ -31,18 +31,18 @@ export class FigureDataContainer
public loadAvatarData(k: string, _arg_2: string): void public loadAvatarData(k: string, _arg_2: string): void
{ {
this._data = new AdvancedMap(); this._data = new AdvancedMap();
this._colors = new AdvancedMap(); this._colors = new AdvancedMap();
this._gender = _arg_2; this._gender = _arg_2;
this.parseFigureString(k); this.parseFigureString(k);
} }
public dispose(): void public dispose(): void
{ {
this._data = null; this._data = null;
this._colors = null; this._colors = null;
this._isDisposed = true; this._isDisposed = true;
} }
public get disposed(): boolean public get disposed(): boolean
@ -60,9 +60,9 @@ export class FigureDataContainer
if(_local_3.length > 0) if(_local_3.length > 0)
{ {
const part = _local_3[0]; const part = _local_3[0];
const setId = parseInt(_local_3[1]); const setId = parseInt(_local_3[1]);
const colors: number[] = []; const colors: number[] = [];
let i = 2; let i = 2;
@ -192,8 +192,8 @@ export class FigureDataContainer
{ {
const partSets: string[] = [ FigureDataContainer.HD ]; const partSets: string[] = [ FigureDataContainer.HD ];
let figure = ''; let figure = '';
const sets: string[] = []; const sets: string[] = [];
for(const part of partSets) for(const part of partSets)
{ {

View File

@ -1,11 +1,11 @@
import { Canvas } from 'canvas'; import { Canvas } from 'canvas';
import { IDisposable, IGraphicAsset } from '../../core'; import { IGraphicAsset } from '../core';
import { IActiveActionData } from './actions'; import { IActiveActionData } from './actions';
import { IAnimationLayerData, IAvatarDataContainer, ISpriteDataContainer } from './animation'; import { IAnimationLayerData, IAvatarDataContainer, ISpriteDataContainer } from './animation';
import { IAvatarFigureContainer } from './IAvatarFigureContainer'; import { IAvatarFigureContainer } from './IAvatarFigureContainer';
import { IPartColor } from './structure'; import { IPartColor } from './structure';
export interface IAvatarImage extends IDisposable export interface IAvatarImage
{ {
setDirection(_arg_1: string, _arg_2: number): void; setDirection(_arg_1: string, _arg_2: number): void;
setDirectionAngle(_arg_1: string, _arg_2: number): void; setDirectionAngle(_arg_1: string, _arg_2: number): void;

View File

@ -1,4 +1,4 @@
import { IAssetManager, IGraphicAsset, INitroManager } from '../../core'; import { IGraphicAsset } from '../core';
import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager'; import { AvatarAssetDownloadManager } from './AvatarAssetDownloadManager';
import { AvatarStructure } from './AvatarStructure'; import { AvatarStructure } from './AvatarStructure';
import { EffectAssetDownloadManager } from './EffectAssetDownloadManager'; import { EffectAssetDownloadManager } from './EffectAssetDownloadManager';
@ -6,8 +6,9 @@ import { IAvatarFigureContainer } from './IAvatarFigureContainer';
import { IAvatarImage } from './IAvatarImage'; import { IAvatarImage } from './IAvatarImage';
import { IStructureData } from './structure/IStructureData'; import { IStructureData } from './structure/IStructureData';
export interface IAvatarRenderManager extends INitroManager export interface IAvatarRenderManager
{ {
init: () => Promise<void>;
createFigureContainer(figure: string): IAvatarFigureContainer; createFigureContainer(figure: string): IAvatarFigureContainer;
isFigureContainerReady(container: IAvatarFigureContainer): boolean; isFigureContainerReady(container: IAvatarFigureContainer): boolean;
createAvatarImage(figure: string, size: string, gender: string): Promise<IAvatarImage>; createAvatarImage(figure: string, size: string, gender: string): Promise<IAvatarImage>;
@ -17,7 +18,6 @@ export interface IAvatarRenderManager extends INitroManager
getFigureStringWithFigureIds(k: string, _arg_2: string, _arg_3: number[]): string; getFigureStringWithFigureIds(k: string, _arg_2: string, _arg_3: number[]): string;
getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[]; getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[];
getAssetByName(name: string): IGraphicAsset; getAssetByName(name: string): IGraphicAsset;
assets: IAssetManager;
structure: AvatarStructure; structure: AvatarStructure;
structureData: IStructureData; structureData: IStructureData;
downloadManager: AvatarAssetDownloadManager; downloadManager: AvatarAssetDownloadManager;

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { ActionType } from './ActionType'; import { ActionType } from './ActionType';
import { IActionDefinition } from './IActionDefinition'; import { IActionDefinition } from './IActionDefinition';
@ -24,23 +24,23 @@ export class ActionDefinition implements IActionDefinition
constructor(data: any) constructor(data: any)
{ {
this._id = data.id; this._id = data.id;
this._state = data.state; this._state = data.state;
this._precedence = data.precedence; this._precedence = data.precedence;
this._activePartSet = data.activePartSet; this._activePartSet = data.activePartSet;
this._assetPartDefinition = data.assetPartDefinition; this._assetPartDefinition = data.assetPartDefinition;
this._lay = data.lay; this._lay = data.lay;
this._geometryType = data.geometryType; this._geometryType = data.geometryType;
this._isMain = data.main || false; this._isMain = data.main || false;
this._isDefault = data.isDefault || false; this._isDefault = data.isDefault || false;
this._isAnimation = data.animation || false; this._isAnimation = data.animation || false;
this._startFromFrameZero = data.startFromFrameZero || false; this._startFromFrameZero = data.startFromFrameZero || false;
this._prevents = data.prevents || []; this._prevents = data.prevents || [];
this._preventHeadTurn = data.preventHeadTurn || false; this._preventHeadTurn = data.preventHeadTurn || false;
this._types = new AdvancedMap(); this._types = new AdvancedMap();
this._params = new AdvancedMap(); this._params = new AdvancedMap();
this._defaultParameterValue = ''; this._defaultParameterValue = '';
this._canvasOffsets = null; this._canvasOffsets = null;
if(data.params && (data.params.length > 0)) if(data.params && (data.params.length > 0))
{ {

View File

@ -8,11 +8,11 @@ export class ActionType
constructor(data: any) constructor(data: any)
{ {
this._id = parseInt(data.id); this._id = parseInt(data.id);
this._value = parseInt(data.id); this._value = parseInt(data.id);
this._prevents = data.prevents || []; this._prevents = data.prevents || [];
this._preventHeadTurn = data.preventHeadTurn || false; this._preventHeadTurn = data.preventHeadTurn || false;
this._isAnimated = true; this._isAnimated = true;
if((data.animated !== undefined) && (data.animated === false)) this._isAnimated = false; if((data.animated !== undefined) && (data.animated === false)) this._isAnimated = false;
} }

View File

@ -11,18 +11,18 @@ export class ActiveActionData implements IActiveActionData
constructor(action: string, parameter: string = '', startFrame: number = 0) constructor(action: string, parameter: string = '', startFrame: number = 0)
{ {
this._actionType = action || ''; this._actionType = action || '';
this._actionParameter = parameter || ''; this._actionParameter = parameter || '';
this._definition = null; this._definition = null;
this._startFrame = startFrame || 0; this._startFrame = startFrame || 0;
this._overridingAction = null; this._overridingAction = null;
} }
public dispose(): void public dispose(): void
{ {
this._actionType = null; this._actionType = null;
this._actionParameter = null; this._actionParameter = null;
this._definition = null; this._definition = null;
} }
public get id(): string public get id(): string

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { ActionDefinition } from './ActionDefinition'; import { ActionDefinition } from './ActionDefinition';
import { IActiveActionData } from './IActiveActionData'; import { IActiveActionData } from './IActiveActionData';
@ -43,7 +43,7 @@ export class AvatarActionManager
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;
@ -104,8 +104,8 @@ export class AvatarActionManager
{ {
if(!activeAction) continue; if(!activeAction) continue;
const action = this._actions.getValue(activeAction.actionType); const action = this._actions.getValue(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;
} }
@ -141,8 +141,8 @@ export class AvatarActionManager
private filterActions(actions: IActiveActionData[]): IActiveActionData[] private filterActions(actions: IActiveActionData[]): IActiveActionData[]
{ {
let preventions: string[] = []; let preventions: string[] = [];
const activeActions: IActiveActionData[] = []; const activeActions: IActiveActionData[] = [];
for(const action of actions) for(const action of actions)
{ {

View File

@ -1,4 +1,4 @@
import { IAssetAlias } from '../../../core'; import { IAssetAlias } from '../../core';
export class AssetAlias export class AssetAlias
{ {
@ -9,8 +9,8 @@ export class AssetAlias
constructor(name: string, alias: IAssetAlias) constructor(name: string, alias: IAssetAlias)
{ {
this._name = name; this._name = name;
this._link = alias.link; this._link = alias.link;
this._flipH = alias.flipH; this._flipH = alias.flipH;
this._flipV = alias.flipV; this._flipV = alias.flipV;
} }

View File

@ -1,25 +1,22 @@
import { AdvancedMap, IAssetManager, IGraphicAsset } from '../../../core'; import { AdvancedMap, AssetManager, IGraphicAsset } from '../../core';
import { AvatarRenderManager } from '../AvatarRenderManager'; import { AvatarRenderManager } from '../AvatarRenderManager';
import { AssetAlias } from './AssetAlias'; import { AssetAlias } from './AssetAlias';
export class AssetAliasCollection export class AssetAliasCollection
{ {
private _assets: IAssetManager;
private _aliases: AdvancedMap<string, AssetAlias>; private _aliases: AdvancedMap<string, AssetAlias>;
private _avatarRenderManager: AvatarRenderManager; private _avatarRenderManager: AvatarRenderManager;
private _missingAssetNames: string[]; private _missingAssetNames: string[];
constructor(renderManager: AvatarRenderManager, assetManager: IAssetManager) constructor(renderManager: AvatarRenderManager)
{ {
this._avatarRenderManager = renderManager; this._avatarRenderManager = renderManager;
this._aliases = new AdvancedMap(); this._aliases = new AdvancedMap();
this._assets = assetManager;
this._missingAssetNames = []; this._missingAssetNames = [];
} }
public dispose(): void public dispose(): void
{ {
this._assets = null;
this._aliases = null; this._aliases = null;
} }
@ -30,7 +27,7 @@ export class AssetAliasCollection
public init(): void public init(): void
{ {
for(const collection of this._assets.collections.getValues()) for(const collection of AssetManager.collections.getValues())
{ {
if(!collection) continue; if(!collection) continue;
@ -76,11 +73,9 @@ export class AssetAliasCollection
public getAsset(name: string): IGraphicAsset public getAsset(name: string): IGraphicAsset
{ {
if(!this._assets) return null;
name = this.getAssetName(name); name = this.getAssetName(name);
const asset = this._assets.getAsset(name); const asset = AssetManager.getAsset(name);
if(!asset) return null; if(!asset) return null;

View File

@ -1,4 +1,4 @@
import { IAssetAnimationAdd } from '../../../core'; import { IAssetAnimationAdd } from '../../core';
export class AddDataContainer export class AddDataContainer
{ {

View File

@ -1,4 +1,4 @@
import { AdvancedMap, IAssetAnimation, IAssetAnimationFrame } from '../../../core'; import { AdvancedMap, IAssetAnimation, IAssetAnimationFrame } from '../../core';
import { AvatarStructure } from '../AvatarStructure'; import { AvatarStructure } from '../AvatarStructure';
import { AddDataContainer } from './AddDataContainer'; import { AddDataContainer } from './AddDataContainer';
import { AvatarAnimationLayerData } from './AvatarAnimationLayerData'; import { AvatarAnimationLayerData } from './AvatarAnimationLayerData';

View File

@ -1,4 +1,4 @@
import { AdvancedMap, IAssetAnimation } from '../../../core'; import { AdvancedMap, IAssetAnimation } from '../../core';
import { AvatarStructure } from '../AvatarStructure'; import { AvatarStructure } from '../AvatarStructure';
import { Animation } from './Animation'; import { Animation } from './Animation';
import { IAnimation } from './IAnimation'; import { IAnimation } from './IAnimation';

View File

@ -1,4 +1,4 @@
import { AdvancedMap, IAssetAnimationFramePart } from '../../../core'; import { AdvancedMap, IAssetAnimationFramePart } from '../../core';
import { ActiveActionData, IActionDefinition, IActiveActionData } from '../actions'; import { ActiveActionData, IActionDefinition, IActiveActionData } from '../actions';
import { IAnimationLayerData } from './IAnimationLayerData'; import { IAnimationLayerData } from './IAnimationLayerData';

View File

@ -1,4 +1,4 @@
import { AdvancedMap, IAssetAnimationAvatar } from '../../../core'; import { AdvancedMap, IAssetAnimationAvatar } from '../../core';
import { IAvatarDataContainer } from './IAvatarDataContainer'; import { IAvatarDataContainer } from './IAvatarDataContainer';
export class AvatarDataContainer implements IAvatarDataContainer export class AvatarDataContainer implements IAvatarDataContainer

View File

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

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { IAnimation } from './IAnimation'; import { IAnimation } from './IAnimation';
import { IAnimationLayerData } from './IAnimationLayerData'; import { IAnimationLayerData } from './IAnimationLayerData';

View File

@ -1,4 +1,4 @@
import { IAssetAnimationSprite } from '../../../core'; import { IAssetAnimationSprite } from '../../core';
import { IAnimation } from './IAnimation'; import { IAnimation } from './IAnimation';
import { ISpriteDataContainer } from './ISpriteDataContainer'; import { ISpriteDataContainer } from './ISpriteDataContainer';
@ -16,6 +16,7 @@ export class SpriteDataContainer implements ISpriteDataContainer
constructor(animation: IAnimation, sprite: IAssetAnimationSprite) constructor(animation: IAnimation, sprite: IAssetAnimationSprite)
{ {
console.log(sprite);
this._animation = animation; this._animation = animation;
this._id = sprite.id; this._id = sprite.id;
this._ink = sprite.ink; this._ink = sprite.ink;

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { AvatarImageDirectionCache } from './AvatarImageDirectionCache'; import { AvatarImageDirectionCache } from './AvatarImageDirectionCache';
export class AvatarImageActionCache export class AvatarImageActionCache

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { IActiveActionData } from '../actions'; import { IActiveActionData } from '../actions';
import { AvatarImageActionCache } from './AvatarImageActionCache'; import { AvatarImageActionCache } from './AvatarImageActionCache';
@ -35,8 +35,8 @@ export class AvatarImageBodyPartCache
this._cache.reset(); this._cache.reset();
this._cache = null; this._cache = null;
this._disposed = true; this._disposed = true;
} }
} }

View File

@ -1,4 +1,4 @@
import { AdvancedMap, CanvasUtilities, Point, Rectangle } from '../../../core'; import { AdvancedMap, CanvasUtilities, Point, Rectangle } from '../../core';
import { IActiveActionData } from '../actions'; import { IActiveActionData } from '../actions';
import { AssetAliasCollection } from '../alias'; import { AssetAliasCollection } from '../alias';
import { AvatarAnimationLayerData } from '../animation'; import { AvatarAnimationLayerData } from '../animation';
@ -45,10 +45,10 @@ export class AvatarImageCache
if(this._disposed) return; if(this._disposed) return;
this._structure = null; this._structure = null;
this._avatar = null; this._avatar = null;
this._assets = null; this._assets = null;
this._canvas = null; this._canvas = null;
this._disposed = true; this._disposed = true;
if(this._cache) if(this._cache)
{ {
@ -138,16 +138,16 @@ export class AvatarImageCache
if((((this._geometryType === GeometryType.SITTING) && (k === GeometryType.VERTICAL)) || ((this._geometryType === GeometryType.VERTICAL) && (k === GeometryType.SITTING)) || ((this._geometryType === GeometryType.SNOWWARS_HORIZONTAL) && (k = GeometryType.SNOWWARS_HORIZONTAL)))) if((((this._geometryType === GeometryType.SITTING) && (k === GeometryType.VERTICAL)) || ((this._geometryType === GeometryType.VERTICAL) && (k === GeometryType.SITTING)) || ((this._geometryType === GeometryType.SNOWWARS_HORIZONTAL) && (k = GeometryType.SNOWWARS_HORIZONTAL))))
{ {
this._geometryType = k; this._geometryType = k;
this._canvas = null; this._canvas = null;
return; return;
} }
this.disposeInactiveActions(0); this.disposeInactiveActions(0);
this._geometryType = k; this._geometryType = k;
this._canvas = null; this._canvas = null;
} }
public getImageContainer(k: string, frameNumber: number): AvatarImageBodyPartContainer public getImageContainer(k: string, frameNumber: number): AvatarImageBodyPartContainer
@ -315,10 +315,10 @@ export class AvatarImageCache
if(!this._canvas) return null; if(!this._canvas) return null;
} }
const isFlipped = AvatarDirectionAngle.DIRECTION_IS_FLIPPED[direction] || false; const isFlipped = AvatarDirectionAngle.DIRECTION_IS_FLIPPED[direction] || false;
let assetPartDefinition = _arg_4.definition.assetPartDefinition; let assetPartDefinition = _arg_4.definition.assetPartDefinition;
let isCacheable = true; let isCacheable = true;
let containerIndex = (containers.length - 1); let containerIndex = (containers.length - 1);
while(containerIndex >= 0) while(containerIndex >= 0)
{ {
@ -330,10 +330,10 @@ export class AvatarImageCache
{ {
if(!((container.partType === 'ri') && !container.partId)) if(!((container.partType === 'ri') && !container.partId))
{ {
const partId = container.partId; const partId = container.partId;
const animationFrame = container.getFrameDefinition(frameCount); const animationFrame = container.getFrameDefinition(frameCount);
let partType = container.partType; let partType = container.partType;
let frameNumber = 0; let frameNumber = 0;
if(animationFrame) if(animationFrame)
@ -344,8 +344,8 @@ export class AvatarImageCache
} }
else frameNumber = container.getFrameIndex(frameCount); else frameNumber = container.getFrameIndex(frameCount);
let assetDirection = direction; let assetDirection = direction;
let flipH = false; let flipH = false;
if(isFlipped) if(isFlipped)
{ {
@ -355,21 +355,21 @@ export class AvatarImageCache
} }
else else
{ {
if(direction === 4) assetDirection = 2; if(direction === 4) assetDirection = 2;
else if(direction === 5) assetDirection = 1; else if(direction === 5) assetDirection = 1;
else if(direction === 6) assetDirection = 0; else if(direction === 6) assetDirection = 0;
if(container.flippedPartType !== partType) partType = container.flippedPartType; if(container.flippedPartType !== partType) partType = container.flippedPartType;
} }
} }
let assetName = (this._scale + '_' + assetPartDefinition + '_' + partType + '_' + partId + '_' + assetDirection + '_' + frameNumber); let assetName = (this._scale + '_' + assetPartDefinition + '_' + partType + '_' + partId + '_' + assetDirection + '_' + frameNumber);
let asset = this._assets.getAsset(assetName); let asset = this._assets.getAsset(assetName);
if(!asset) if(!asset)
{ {
assetName = (this._scale + '_std_' + partType + '_' + partId + '_' + assetDirection + '_0'); assetName = (this._scale + '_std_' + partType + '_' + partId + '_' + assetDirection + '_0');
asset = this._assets.getAsset(assetName); asset = this._assets.getAsset(assetName);
} }
if(asset) if(asset)
@ -399,9 +399,9 @@ export class AvatarImageCache
if(!this._unionImages.length) return null; if(!this._unionImages.length) return null;
const imageData = this.createUnionImage(this._unionImages, isFlipped); const imageData = this.createUnionImage(this._unionImages, isFlipped);
const canvasOffset = ((this._scale === AvatarScaleType.LARGE) ? (this._canvas.height - 16) : (this._canvas.height - 8)); const canvasOffset = ((this._scale === AvatarScaleType.LARGE) ? (this._canvas.height - 16) : (this._canvas.height - 8));
const offset = new Point(-(imageData.regPoint.x), (canvasOffset - imageData.regPoint.y)); const offset = new Point(-(imageData.regPoint.x), (canvasOffset - imageData.regPoint.y));
if(isFlipped && (assetPartDefinition !== 'lay')) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 67 : 31)); if(isFlipped && (assetPartDefinition !== 'lay')) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 67 : 31));
@ -459,7 +459,7 @@ export class AvatarImageCache
if(flipH) if(flipH)
{ {
scale = -1; scale = -1;
tx = ((data.rect.x + data.rect.width) + regPoint.x); tx = ((data.rect.x + data.rect.width) + regPoint.x);
ty = (regPoint.y - data.rect.y); ty = (regPoint.y - data.rect.y);
} }

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { AvatarImageBodyPartContainer } from '../AvatarImageBodyPartContainer'; import { AvatarImageBodyPartContainer } from '../AvatarImageBodyPartContainer';
import { AvatarImagePartContainer } from '../AvatarImagePartContainer'; import { AvatarImagePartContainer } from '../AvatarImagePartContainer';
@ -9,8 +9,8 @@ export class AvatarImageDirectionCache
constructor(k: AvatarImagePartContainer[]) constructor(k: AvatarImagePartContainer[])
{ {
this._partList = k; this._partList = k;
this._images = new AdvancedMap(); this._images = new AdvancedMap();
} }
public dispose(): void public dispose(): void

View File

@ -1,5 +1,5 @@
import { Canvas } from 'canvas'; import { Canvas } from 'canvas';
import { Point, Rectangle } from '../../../core'; import { Point, Rectangle } from '../../core';
export class CompleteImageData export class CompleteImageData
{ {

View File

@ -1,4 +1,4 @@
import { Point, Rectangle, Texture } from '../../../core'; import { Point, Rectangle, Texture } from '../../core';
export class ImageData export class ImageData
{ {

View File

@ -12,17 +12,17 @@ export const HabboAvatarGeometry = {
'geometries': [ 'geometries': [
{ {
'id': 'vertical', 'id': 'vertical',
'width': 64, 'width': 90,
'height': 110, 'height': 130,
'dx': 0, 'dx': 0,
'dy': 6 'dy': 0
}, },
{ {
'id': 'sitting', 'id': 'sitting',
'width': 64, 'width': 90,
'height': 110, 'height': 130,
'dx': 0, 'dx': 0,
'dy': 6 'dy': 0
}, },
{ {
'id': 'horizontal', 'id': 'horizontal',

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { IAvatarImage } from '../IAvatarImage'; import { IAvatarImage } from '../IAvatarImage';
import { AvatarCanvas } from '../structure'; import { AvatarCanvas } from '../structure';
import { AvatarSet } from './AvatarSet'; import { AvatarSet } from './AvatarSet';

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
export class AvatarSet export class AvatarSet
{ {
@ -10,11 +10,11 @@ export class AvatarSet
constructor(k: any) constructor(k: any)
{ {
this._id = k.id; this._id = k.id;
this._isMain = k.main || false; this._isMain = k.main || false;
this._avatarSets = new AdvancedMap(); this._avatarSets = new AdvancedMap();
this._bodyParts = []; this._bodyParts = [];
this._allBodyParts = []; this._allBodyParts = [];
if(k.avatarSets && (k.avatarSets.length > 0)) if(k.avatarSets && (k.avatarSets.length > 0))
{ {

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { IAvatarImage } from '../IAvatarImage'; import { IAvatarImage } from '../IAvatarImage';
import { GeometryItem } from './GeometryItem'; import { GeometryItem } from './GeometryItem';
import { Matrix4x4 } from './Matrix4x4'; import { Matrix4x4 } from './Matrix4x4';
@ -16,10 +16,10 @@ export class GeometryBodyPart extends Node3D
{ {
super(parseFloat(k.x), parseFloat(k.y), parseFloat(k.z)); super(parseFloat(k.x), parseFloat(k.y), parseFloat(k.z));
this._id = k.id; this._id = k.id;
this._radius = parseFloat(k.radius); this._radius = parseFloat(k.radius);
this._parts = new AdvancedMap(); this._parts = new AdvancedMap();
this._dynamicParts = new AdvancedMap(); this._dynamicParts = new AdvancedMap();
if(k.items && (k.items.length > 0)) if(k.items && (k.items.length > 0))
{ {
@ -36,7 +36,7 @@ export class GeometryBodyPart extends Node3D
public getDynamicParts(k: IAvatarImage): GeometryItem[] public getDynamicParts(k: IAvatarImage): GeometryItem[]
{ {
const existing = this._dynamicParts.getValue(k); const existing = this._dynamicParts.getValue(k);
const parts: GeometryItem[] = []; const parts: GeometryItem[] = [];
if(existing) if(existing)

View File

@ -13,14 +13,14 @@ export class GeometryItem extends Node3D
{ {
super(parseFloat(k.x), parseFloat(k.y), parseFloat(k.z)); super(parseFloat(k.x), parseFloat(k.y), parseFloat(k.z));
this._id = k.id; this._id = k.id;
this._radius = parseFloat(k.radius); this._radius = parseFloat(k.radius);
this._normal = new Vector3D(parseFloat(k.nx), parseFloat(k.ny), parseFloat(k.nz)); this._normal = new Vector3D(parseFloat(k.nx), parseFloat(k.ny), parseFloat(k.nz));
this._isDoubleSided = k.double || false; this._isDoubleSided = k.double || false;
this._isDynamic = _arg_2; this._isDynamic = _arg_2;
} }
public getDistance(k: Vector3D): number public getDistance(k: Vector3D): number
{ {
const _local_2 = Math.abs(((k.z - this.transformedLocation.z) - this._radius)); const _local_2 = Math.abs(((k.z - this.transformedLocation.z) - this._radius));
const _local_3 = Math.abs(((k.z - this.transformedLocation.z) + this._radius)); const _local_3 = Math.abs(((k.z - this.transformedLocation.z) + this._radius));

View File

@ -2,8 +2,8 @@
export class Matrix4x4 export class Matrix4x4
{ {
public static IDENTITY:Matrix4x4 = new Matrix4x4(1, 0, 0, 0, 1, 0, 0, 0, 1); public static IDENTITY:Matrix4x4 = new Matrix4x4(1, 0, 0, 0, 1, 0, 0, 0, 1);
private static TOLERANS: number = 1E-18; private static TOLERANS: number = 1E-18;
private _data: number[]; private _data: number[];
@ -57,14 +57,14 @@ export class Matrix4x4
public multiply(k:Matrix4x4): Matrix4x4 public multiply(k:Matrix4x4): Matrix4x4
{ {
const _local_2 = (((this._data[0] * k.data[0]) + (this._data[1] * k.data[3])) + (this._data[2] * k.data[6])); const _local_2 = (((this._data[0] * k.data[0]) + (this._data[1] * k.data[3])) + (this._data[2] * k.data[6]));
const _local_3 = (((this._data[0] * k.data[1]) + (this._data[1] * k.data[4])) + (this._data[2] * k.data[7])); const _local_3 = (((this._data[0] * k.data[1]) + (this._data[1] * k.data[4])) + (this._data[2] * k.data[7]));
const _local_4 = (((this._data[0] * k.data[2]) + (this._data[1] * k.data[5])) + (this._data[2] * k.data[8])); const _local_4 = (((this._data[0] * k.data[2]) + (this._data[1] * k.data[5])) + (this._data[2] * k.data[8]));
const _local_5 = (((this._data[3] * k.data[0]) + (this._data[4] * k.data[3])) + (this._data[5] * k.data[6])); const _local_5 = (((this._data[3] * k.data[0]) + (this._data[4] * k.data[3])) + (this._data[5] * k.data[6]));
const _local_6 = (((this._data[3] * k.data[1]) + (this._data[4] * k.data[4])) + (this._data[5] * k.data[7])); const _local_6 = (((this._data[3] * k.data[1]) + (this._data[4] * k.data[4])) + (this._data[5] * k.data[7]));
const _local_7 = (((this._data[3] * k.data[2]) + (this._data[4] * k.data[5])) + (this._data[5] * k.data[8])); const _local_7 = (((this._data[3] * k.data[2]) + (this._data[4] * k.data[5])) + (this._data[5] * k.data[8]));
const _local_8 = (((this._data[6] * k.data[0]) + (this._data[7] * k.data[3])) + (this._data[8] * k.data[6])); const _local_8 = (((this._data[6] * k.data[0]) + (this._data[7] * k.data[3])) + (this._data[8] * k.data[6]));
const _local_9 = (((this._data[6] * k.data[1]) + (this._data[7] * k.data[4])) + (this._data[8] * k.data[7])); const _local_9 = (((this._data[6] * k.data[1]) + (this._data[7] * k.data[4])) + (this._data[8] * k.data[7]));
const _local_10 = (((this._data[6] * k.data[2]) + (this._data[7] * k.data[5])) + (this._data[8] * k.data[8])); const _local_10 = (((this._data[6] * k.data[2]) + (this._data[7] * k.data[5])) + (this._data[8] * k.data[8]));
return new Matrix4x4(_local_2, _local_3, _local_4, _local_5, _local_6, _local_7, _local_8, _local_9, _local_10); return new Matrix4x4(_local_2, _local_3, _local_4, _local_5, _local_6, _local_7, _local_8, _local_9, _local_10);

View File

@ -9,9 +9,9 @@ export class Node3D
constructor(k: number, _arg_2: number, _arg_3: number) constructor(k: number, _arg_2: number, _arg_3: number)
{ {
this._location = new Vector3D(k, _arg_2, _arg_3); this._location = new Vector3D(k, _arg_2, _arg_3);
this._transformedLocation = new Vector3D(); this._transformedLocation = new Vector3D();
this._needsTransformation = false; this._needsTransformation = false;
if(((!(k == 0)) || (!(_arg_2 == 0))) || (!(_arg_3 == 0))) this._needsTransformation = true; if(((!(k == 0)) || (!(_arg_2 == 0))) || (!(_arg_3 == 0))) this._needsTransformation = true;
} }

View File

@ -20,5 +20,8 @@ export * from './IAvatarFigureContainer';
export * from './IAvatarImage'; export * from './IAvatarImage';
export * from './IAvatarRenderManager'; export * from './IAvatarRenderManager';
export * from './interfaces'; export * from './interfaces';
export * from './PlaceHolderAvatarImage'; export * from './interfaces/figuredata';
export * from './structure'; export * from './structure';
export * from './structure/animation';
export * from './structure/figure';
export * from './structure/parts';

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { IActionDefinition } from '../actions'; import { IActionDefinition } from '../actions';
import { AnimationAction } from './animation'; import { AnimationAction } from './animation';
import { IFigureSetData } from './IFigureSetData'; import { IFigureSetData } from './IFigureSetData';

View File

@ -1,4 +1,4 @@
import { Point } from '../../../core'; import { Point } from '../../core';
import { AvatarScaleType } from '../enum'; import { AvatarScaleType } from '../enum';
export class AvatarCanvas export class AvatarCanvas

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { IFigureData } from '../interfaces'; import { IFigureData } from '../interfaces';
import { IFigurePartSet, IPalette, ISetType, Palette, SetType } from './figure'; import { IFigurePartSet, IPalette, ISetType, Palette, SetType } from './figure';
import { IFigureSetData } from './IFigureSetData'; import { IFigureSetData } from './IFigureSetData';

View File

@ -1,4 +1,4 @@
import { AdvancedMap } from '../../../core'; import { AdvancedMap } from '../../core';
import { ActionDefinition, IActionDefinition } from '../actions'; import { ActionDefinition, IActionDefinition } from '../actions';
import { IFigureSetData } from './IFigureSetData'; import { IFigureSetData } from './IFigureSetData';
import { ActivePartSet, PartDefinition } from './parts'; import { ActivePartSet, PartDefinition } from './parts';

View File

@ -1,4 +1,4 @@
import { AdvancedMap, Point } from '../../../../core'; import { AdvancedMap, Point } from '../../../core';
import { AnimationActionPart } from './AnimationActionPart'; import { AnimationActionPart } from './AnimationActionPart';
export class AnimationAction export class AnimationAction

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