mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-19 06:46:28 +01:00
Eslint fixes
This commit is contained in:
parent
8e20920cab
commit
3424aa2784
@ -1,6 +1,3 @@
|
|||||||
import { INitroManager } from '../../common';
|
import { INitroManager } from '../../common';
|
||||||
|
|
||||||
export interface INitroCommunicationDemo extends INitroManager
|
export type INitroCommunicationDemo = INitroManager
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -19,7 +19,7 @@ export class ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if ((this._flags & ObjectDataFlags.UNIQUE_SET) > 0)
|
if((this._flags & ObjectDataFlags.UNIQUE_SET) > 0)
|
||||||
{
|
{
|
||||||
this._uniqueNumber = wrapper.readInt();
|
this._uniqueNumber = wrapper.readInt();
|
||||||
this._uniqueSeries = wrapper.readInt();
|
this._uniqueSeries = wrapper.readInt();
|
||||||
@ -34,7 +34,7 @@ export class ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
public writeRoomObjectModel(model: IRoomObjectModel): void
|
public writeRoomObjectModel(model: IRoomObjectModel): void
|
||||||
{
|
{
|
||||||
if (!model) return;
|
if(!model) return;
|
||||||
|
|
||||||
model.setValue(RoomObjectVariable.FURNITURE_UNIQUE_SERIAL_NUMBER, this._uniqueNumber);
|
model.setValue(RoomObjectVariable.FURNITURE_UNIQUE_SERIAL_NUMBER, this._uniqueNumber);
|
||||||
model.setValue(RoomObjectVariable.FURNITURE_UNIQUE_EDITION_SIZE, this._uniqueSeries);
|
model.setValue(RoomObjectVariable.FURNITURE_UNIQUE_EDITION_SIZE, this._uniqueSeries);
|
||||||
|
@ -7,7 +7,7 @@ export class ObjectDataFactory
|
|||||||
{
|
{
|
||||||
let objectData: IObjectData = null;
|
let objectData: IObjectData = null;
|
||||||
|
|
||||||
switch (flags & 0xFF)
|
switch(flags & 0xFF)
|
||||||
{
|
{
|
||||||
case CrackableDataType.FORMAT_KEY:
|
case CrackableDataType.FORMAT_KEY:
|
||||||
objectData = new CrackableDataType();
|
objectData = new CrackableDataType();
|
||||||
@ -35,7 +35,7 @@ export class ObjectDataFactory
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!objectData) return null;
|
if(!objectData) return null;
|
||||||
|
|
||||||
objectData.flags = (flags & 0xFF00);
|
objectData.flags = (flags & 0xFF00);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export class CrackableDataType extends ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._state = wrapper.readString();
|
this._state = wrapper.readString();
|
||||||
this._hits = wrapper.readInt();
|
this._hits = wrapper.readInt();
|
||||||
|
@ -13,7 +13,7 @@ export class EmptyDataType extends ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._state = '';
|
this._state = '';
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ export class HighScoreDataType extends ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._state = wrapper.readString();
|
this._state = wrapper.readString();
|
||||||
this._scoreType = wrapper.readInt();
|
this._scoreType = wrapper.readInt();
|
||||||
@ -35,7 +35,7 @@ export class HighScoreDataType extends ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
let totalScores = wrapper.readInt();
|
let totalScores = wrapper.readInt();
|
||||||
|
|
||||||
while (totalScores > 0)
|
while(totalScores > 0)
|
||||||
{
|
{
|
||||||
const data = new HighScoreData();
|
const data = new HighScoreData();
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ export class HighScoreDataType extends ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
let totalUsers = wrapper.readInt();
|
let totalUsers = wrapper.readInt();
|
||||||
|
|
||||||
while (totalUsers > 0)
|
while(totalUsers > 0)
|
||||||
{
|
{
|
||||||
data.addUsername(wrapper.readString());
|
data.addUsername(wrapper.readString());
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ export class HighScoreDataType extends ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < totalEntries)
|
while(i < totalEntries)
|
||||||
{
|
{
|
||||||
const data = new HighScoreData();
|
const data = new HighScoreData();
|
||||||
|
|
||||||
@ -91,13 +91,13 @@ export class HighScoreDataType extends ObjectDataBase implements IObjectData
|
|||||||
model.setValue(RoomObjectVariable.FURNITURE_HIGHSCORE_SCORE_TYPE, this._scoreType);
|
model.setValue(RoomObjectVariable.FURNITURE_HIGHSCORE_SCORE_TYPE, this._scoreType);
|
||||||
model.setValue(RoomObjectVariable.FURNITURE_HIGHSCORE_CLEAR_TYPE, this._clearType);
|
model.setValue(RoomObjectVariable.FURNITURE_HIGHSCORE_CLEAR_TYPE, this._clearType);
|
||||||
|
|
||||||
if (this._entries)
|
if(this._entries)
|
||||||
{
|
{
|
||||||
model.setValue(RoomObjectVariable.FURNITURE_HIGHSCORE_DATA_ENTRY_COUNT, this._entries.length);
|
model.setValue(RoomObjectVariable.FURNITURE_HIGHSCORE_DATA_ENTRY_COUNT, this._entries.length);
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < this._entries.length)
|
while(i < this._entries.length)
|
||||||
{
|
{
|
||||||
const entry = this._entries[i];
|
const entry = this._entries[i];
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ export class LegacyDataType extends ObjectDataBase implements IObjectData
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._data = wrapper.readString();
|
this._data = wrapper.readString();
|
||||||
|
|
||||||
|
@ -23,13 +23,13 @@ export class MapDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._data = {};
|
this._data = {};
|
||||||
|
|
||||||
const totalSets = wrapper.readInt();
|
const totalSets = wrapper.readInt();
|
||||||
|
|
||||||
if (totalSets) for (let i = 0; i < totalSets; i++) this._data[wrapper.readString()] = wrapper.readString();
|
if(totalSets) for(let i = 0; i < totalSets; i++) this._data[wrapper.readString()] = wrapper.readString();
|
||||||
|
|
||||||
super.parseWrapper(wrapper);
|
super.parseWrapper(wrapper);
|
||||||
}
|
}
|
||||||
@ -51,11 +51,11 @@ export class MapDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public getLegacyString(): string
|
public getLegacyString(): string
|
||||||
{
|
{
|
||||||
if (!this._data) return '';
|
if(!this._data) return '';
|
||||||
|
|
||||||
const state = this._data[MapDataType.STATE];
|
const state = this._data[MapDataType.STATE];
|
||||||
|
|
||||||
if (state === undefined || state === null) return '';
|
if(state === undefined || state === null) return '';
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -72,11 +72,11 @@ export class MapDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public get rarityLevel(): number
|
public get rarityLevel(): number
|
||||||
{
|
{
|
||||||
if (!this._data) return -1;
|
if(!this._data) return -1;
|
||||||
|
|
||||||
const state = this._data[MapDataType.RARITY];
|
const state = this._data[MapDataType.RARITY];
|
||||||
|
|
||||||
if (state === undefined || state === null) return -1;
|
if(state === undefined || state === null) return -1;
|
||||||
|
|
||||||
return parseInt(state);
|
return parseInt(state);
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ export class NumberDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._data = [];
|
this._data = [];
|
||||||
|
|
||||||
const totalNumbers = wrapper.readInt();
|
const totalNumbers = wrapper.readInt();
|
||||||
|
|
||||||
if (totalNumbers) for (let i = 0; i < totalNumbers; i++) this._data.push(wrapper.readInt());
|
if(totalNumbers) for(let i = 0; i < totalNumbers; i++) this._data.push(wrapper.readInt());
|
||||||
|
|
||||||
super.parseWrapper(wrapper);
|
super.parseWrapper(wrapper);
|
||||||
}
|
}
|
||||||
@ -50,26 +50,26 @@ export class NumberDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public getLegacyString(): string
|
public getLegacyString(): string
|
||||||
{
|
{
|
||||||
if (!this._data || !this._data.length) return '';
|
if(!this._data || !this._data.length) return '';
|
||||||
|
|
||||||
return this._data[NumberDataType.STATE].toString();
|
return this._data[NumberDataType.STATE].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public compare(data: IObjectData): boolean
|
public compare(data: IObjectData): boolean
|
||||||
{
|
{
|
||||||
if (!(data instanceof NumberDataType)) return false;
|
if(!(data instanceof NumberDataType)) return false;
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < this._data.length)
|
while(i < this._data.length)
|
||||||
{
|
{
|
||||||
if (i === 0)
|
if(i === 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (this._data[i] !== data.getValue(i)) return false;
|
if(this._data[i] !== data.getValue(i)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
@ -80,11 +80,11 @@ export class NumberDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public getValue(index: number): number
|
public getValue(index: number): number
|
||||||
{
|
{
|
||||||
if (!this._data || !this._data.length) return -1;
|
if(!this._data || !this._data.length) return -1;
|
||||||
|
|
||||||
const value = this._data[index];
|
const value = this._data[index];
|
||||||
|
|
||||||
if (value === undefined || value === null) return -1;
|
if(value === undefined || value === null) return -1;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ export class StringDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._data = [];
|
this._data = [];
|
||||||
|
|
||||||
const totalStrings = wrapper.readInt();
|
const totalStrings = wrapper.readInt();
|
||||||
|
|
||||||
if (totalStrings) for (let i = 0; i < totalStrings; i++) this._data.push(wrapper.readString());
|
if(totalStrings) for(let i = 0; i < totalStrings; i++) this._data.push(wrapper.readString());
|
||||||
|
|
||||||
super.parseWrapper(wrapper);
|
super.parseWrapper(wrapper);
|
||||||
}
|
}
|
||||||
@ -50,26 +50,26 @@ export class StringDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public getLegacyString(): string
|
public getLegacyString(): string
|
||||||
{
|
{
|
||||||
if (!this._data || !this._data.length) return '';
|
if(!this._data || !this._data.length) return '';
|
||||||
|
|
||||||
return this._data[StringDataType.STATE];
|
return this._data[StringDataType.STATE];
|
||||||
}
|
}
|
||||||
|
|
||||||
public compare(data: IObjectData): boolean
|
public compare(data: IObjectData): boolean
|
||||||
{
|
{
|
||||||
if (!(data instanceof StringDataType)) return false;
|
if(!(data instanceof StringDataType)) return false;
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < this._data.length)
|
while(i < this._data.length)
|
||||||
{
|
{
|
||||||
if (i === 0)
|
if(i === 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (this._data[i] !== data.getValue(i)) return false;
|
if(this._data[i] !== data.getValue(i)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
@ -22,7 +22,7 @@ export class VoteDataType extends ObjectDataBase
|
|||||||
|
|
||||||
public parseWrapper(wrapper: IMessageDataWrapper): void
|
public parseWrapper(wrapper: IMessageDataWrapper): void
|
||||||
{
|
{
|
||||||
if (!wrapper) return;
|
if(!wrapper) return;
|
||||||
|
|
||||||
this._state = wrapper.readString();
|
this._state = wrapper.readString();
|
||||||
this._result = wrapper.readInt();
|
this._result = wrapper.readInt();
|
||||||
|
@ -17,46 +17,46 @@ export class Vector3d implements IVector3D
|
|||||||
|
|
||||||
public static sum(vector1: IVector3D, vector2: IVector3D): Vector3d
|
public static sum(vector1: IVector3D, vector2: IVector3D): Vector3d
|
||||||
{
|
{
|
||||||
if (!vector1 || !vector2) return null;
|
if(!vector1 || !vector2) return null;
|
||||||
|
|
||||||
return new Vector3d((vector1.x + vector2.x), (vector1.y + vector2.y), (vector1.z + vector2.z));
|
return new Vector3d((vector1.x + vector2.x), (vector1.y + vector2.y), (vector1.z + vector2.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static dif(vector1: IVector3D, vector2: IVector3D): Vector3d
|
public static dif(vector1: IVector3D, vector2: IVector3D): Vector3d
|
||||||
{
|
{
|
||||||
if (!vector1 || !vector2) return null;
|
if(!vector1 || !vector2) return null;
|
||||||
|
|
||||||
return new Vector3d((vector1.x - vector2.x), (vector1.y - vector2.y), (vector1.z - vector2.z));
|
return new Vector3d((vector1.x - vector2.x), (vector1.y - vector2.y), (vector1.z - vector2.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static product(vector: IVector3D, value: number): Vector3d
|
public static product(vector: IVector3D, value: number): Vector3d
|
||||||
{
|
{
|
||||||
if (!vector) return null;
|
if(!vector) return null;
|
||||||
|
|
||||||
return new Vector3d((vector.x * value), (vector.y * value), (vector.z * value));
|
return new Vector3d((vector.x * value), (vector.y * value), (vector.z * value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static dotProduct(vector1: IVector3D, vector2: IVector3D): number
|
public static dotProduct(vector1: IVector3D, vector2: IVector3D): number
|
||||||
{
|
{
|
||||||
if (!vector1 || !vector2) return 0;
|
if(!vector1 || !vector2) return 0;
|
||||||
|
|
||||||
return (vector1.x * vector2.x) + (vector1.y * vector2.y) + (vector1.z * vector2.z);
|
return (vector1.x * vector2.x) + (vector1.y * vector2.y) + (vector1.z * vector2.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static crossProduct(vector1: IVector3D, vector2: IVector3D): Vector3d
|
public static crossProduct(vector1: IVector3D, vector2: IVector3D): Vector3d
|
||||||
{
|
{
|
||||||
if (!vector1 || !vector2) return null;
|
if(!vector1 || !vector2) return null;
|
||||||
|
|
||||||
return new Vector3d(((vector1.y * vector2.z) - (vector1.z * vector2.y)), ((vector1.z * vector2.x) - (vector1.x * vector2.z)), ((vector1.x * vector2.y) - (vector1.y * vector2.x)));
|
return new Vector3d(((vector1.y * vector2.z) - (vector1.z * vector2.y)), ((vector1.z * vector2.x) - (vector1.x * vector2.z)), ((vector1.x * vector2.y) - (vector1.y * vector2.x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static scalarProjection(vector1: IVector3D, vector2: IVector3D): number
|
public static scalarProjection(vector1: IVector3D, vector2: IVector3D): number
|
||||||
{
|
{
|
||||||
if (!vector1 || !vector2) return -1;
|
if(!vector1 || !vector2) return -1;
|
||||||
|
|
||||||
const length = vector2.length;
|
const length = vector2.length;
|
||||||
|
|
||||||
if (length > 0)
|
if(length > 0)
|
||||||
{
|
{
|
||||||
return ((vector1.x * vector2.x) + (vector1.y * vector2.y) + (vector1.z * vector2.z)) / length;
|
return ((vector1.x * vector2.x) + (vector1.y * vector2.y) + (vector1.z * vector2.z)) / length;
|
||||||
}
|
}
|
||||||
@ -66,20 +66,20 @@ export class Vector3d implements IVector3D
|
|||||||
|
|
||||||
public static cosAngle(vector1: IVector3D, vector2: IVector3D): number
|
public static cosAngle(vector1: IVector3D, vector2: IVector3D): number
|
||||||
{
|
{
|
||||||
if (!vector1 || !vector2) return 0;
|
if(!vector1 || !vector2) return 0;
|
||||||
|
|
||||||
const totalLength = (vector1.length * vector2.length);
|
const totalLength = (vector1.length * vector2.length);
|
||||||
|
|
||||||
if (!totalLength) return 0;
|
if(!totalLength) return 0;
|
||||||
|
|
||||||
return (Vector3d.dotProduct(vector1, vector2) / totalLength);
|
return (Vector3d.dotProduct(vector1, vector2) / totalLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isEqual(vector1: IVector3D, vector2: IVector3D): boolean
|
public static isEqual(vector1: IVector3D, vector2: IVector3D): boolean
|
||||||
{
|
{
|
||||||
if (!vector1 || !vector2) return false;
|
if(!vector1 || !vector2) return false;
|
||||||
|
|
||||||
if ((vector1.x !== vector2.x) || (vector1.y !== vector2.y) || (vector1.z !== vector2.z)) return false;
|
if((vector1.x !== vector2.x) || (vector1.y !== vector2.y) || (vector1.z !== vector2.z)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ export class Vector3d implements IVector3D
|
|||||||
|
|
||||||
public add(vector: IVector3D): void
|
public add(vector: IVector3D): void
|
||||||
{
|
{
|
||||||
if (!vector) return;
|
if(!vector) return;
|
||||||
|
|
||||||
this._x += vector.x;
|
this._x += vector.x;
|
||||||
this._y += vector.y;
|
this._y += vector.y;
|
||||||
@ -103,7 +103,7 @@ export class Vector3d implements IVector3D
|
|||||||
|
|
||||||
public subtract(vector: IVector3D): void
|
public subtract(vector: IVector3D): void
|
||||||
{
|
{
|
||||||
if (!vector) return;
|
if(!vector) return;
|
||||||
|
|
||||||
this._x -= vector.x;
|
this._x -= vector.x;
|
||||||
this._y -= vector.y;
|
this._y -= vector.y;
|
||||||
@ -121,7 +121,7 @@ export class Vector3d implements IVector3D
|
|||||||
|
|
||||||
public divide(amount: number): void
|
public divide(amount: number): void
|
||||||
{
|
{
|
||||||
if (!amount) return;
|
if(!amount) return;
|
||||||
|
|
||||||
this._x /= amount;
|
this._x /= amount;
|
||||||
this._y /= amount;
|
this._y /= amount;
|
||||||
@ -131,7 +131,7 @@ export class Vector3d implements IVector3D
|
|||||||
|
|
||||||
public assign(vector: IVector3D): void
|
public assign(vector: IVector3D): void
|
||||||
{
|
{
|
||||||
if (!vector) return;
|
if(!vector) return;
|
||||||
|
|
||||||
this._x = vector.x;
|
this._x = vector.x;
|
||||||
this._y = vector.y;
|
this._y = vector.y;
|
||||||
@ -174,7 +174,7 @@ export class Vector3d implements IVector3D
|
|||||||
|
|
||||||
public get length(): number
|
public get length(): number
|
||||||
{
|
{
|
||||||
if (isNaN(this._length))
|
if(isNaN(this._length))
|
||||||
{
|
{
|
||||||
this._length = Math.sqrt(((this._x * this._x) + (this._y * this._y)) + (this._z * this._z));
|
this._length = Math.sqrt(((this._x * this._x) + (this._y * this._y)) + (this._z * this._z));
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,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();
|
||||||
|
|
||||||
|
@ -24,33 +24,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;
|
||||||
}
|
}
|
||||||
@ -60,24 +60,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);
|
||||||
}
|
}
|
||||||
@ -92,7 +92,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);
|
||||||
|
|
||||||
@ -101,9 +101,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({
|
||||||
@ -118,7 +118,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);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ export class AssetManager extends Disposable implements IAssetManager
|
|||||||
|
|
||||||
remaining--;
|
remaining--;
|
||||||
|
|
||||||
if (!remaining)
|
if(!remaining)
|
||||||
{
|
{
|
||||||
loader.destroy();
|
loader.destroy();
|
||||||
|
|
||||||
@ -143,11 +143,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);
|
||||||
|
|
||||||
@ -156,7 +156,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);
|
||||||
|
|
||||||
@ -168,12 +168,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);
|
||||||
|
|
||||||
@ -205,7 +205,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);
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ export class AssetManager extends Disposable implements IAssetManager
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (baseTexture.valid)
|
if(baseTexture.valid)
|
||||||
{
|
{
|
||||||
createAsset();
|
createAsset();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ export class GraphicAsset implements IGraphicAsset
|
|||||||
graphicAsset._name = name;
|
graphicAsset._name = name;
|
||||||
graphicAsset._source = source || null;
|
graphicAsset._source = source || null;
|
||||||
|
|
||||||
if (texture)
|
if(texture)
|
||||||
{
|
{
|
||||||
graphicAsset._texture = texture;
|
graphicAsset._texture = texture;
|
||||||
graphicAsset._initialized = false;
|
graphicAsset._initialized = false;
|
||||||
@ -56,7 +56,7 @@ export class GraphicAsset implements IGraphicAsset
|
|||||||
|
|
||||||
private initialize(): void
|
private initialize(): void
|
||||||
{
|
{
|
||||||
if (this._initialized || !this._texture) return;
|
if(this._initialized || !this._texture) return;
|
||||||
|
|
||||||
this._width = this._texture.width;
|
this._width = this._texture.width;
|
||||||
this._height = this._texture.height;
|
this._height = this._texture.height;
|
||||||
@ -110,14 +110,14 @@ export class GraphicAsset implements IGraphicAsset
|
|||||||
|
|
||||||
public get offsetX(): number
|
public get offsetX(): number
|
||||||
{
|
{
|
||||||
if (!this._flipH) return this._x;
|
if(!this._flipH) return this._x;
|
||||||
|
|
||||||
return (-(this._x));
|
return (-(this._x));
|
||||||
}
|
}
|
||||||
|
|
||||||
public get offsetY(): number
|
public get offsetY(): number
|
||||||
{
|
{
|
||||||
if (!this._flipV) return this._y;
|
if(!this._flipV) return this._y;
|
||||||
|
|
||||||
return (-(this._y));
|
return (-(this._y));
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ export class GraphicAsset implements IGraphicAsset
|
|||||||
|
|
||||||
public get rectangle(): Rectangle
|
public get rectangle(): Rectangle
|
||||||
{
|
{
|
||||||
if (!this._rectangle) this._rectangle = new Rectangle(0, 0, this.width, this.height);
|
if(!this._rectangle) this._rectangle = new Rectangle(0, 0, this.width, this.height);
|
||||||
|
|
||||||
return this._rectangle;
|
return this._rectangle;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
constructor(data: IAssetData, spritesheet: Spritesheet)
|
constructor(data: IAssetData, spritesheet: Spritesheet)
|
||||||
{
|
{
|
||||||
if (!data) throw new Error('invalid_collection');
|
if(!data) throw new Error('invalid_collection');
|
||||||
|
|
||||||
this._name = data.name;
|
this._name = data.name;
|
||||||
this._baseTexture = ((spritesheet && spritesheet.baseTexture) || null);
|
this._baseTexture = ((spritesheet && spritesheet.baseTexture) || null);
|
||||||
@ -32,7 +32,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
this._palettes = new Map();
|
this._palettes = new Map();
|
||||||
this._paletteAssetNames = [];
|
this._paletteAssetNames = [];
|
||||||
|
|
||||||
if (spritesheet) this.addLibraryAsset(spritesheet.textures);
|
if(spritesheet) this.addLibraryAsset(spritesheet.textures);
|
||||||
|
|
||||||
this.define(data);
|
this.define(data);
|
||||||
}
|
}
|
||||||
@ -44,23 +44,23 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if (this._palettes)
|
if(this._palettes)
|
||||||
{
|
{
|
||||||
for (const palette of this._palettes.values()) palette.dispose();
|
for(const palette of this._palettes.values()) palette.dispose();
|
||||||
|
|
||||||
this._palettes.clear();
|
this._palettes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._paletteAssetNames)
|
if(this._paletteAssetNames)
|
||||||
{
|
{
|
||||||
this.disposePaletteAssets();
|
this.disposePaletteAssets();
|
||||||
|
|
||||||
this._paletteAssetNames = null;
|
this._paletteAssetNames = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._assets)
|
if(this._assets)
|
||||||
{
|
{
|
||||||
for (const asset of this._assets.values()) asset.recycle();
|
for(const asset of this._assets.values()) asset.recycle();
|
||||||
|
|
||||||
this._assets.clear();
|
this._assets.clear();
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
{
|
{
|
||||||
this._referenceCount--;
|
this._referenceCount--;
|
||||||
|
|
||||||
if (this._referenceCount <= 0)
|
if(this._referenceCount <= 0)
|
||||||
{
|
{
|
||||||
this._referenceCount = 0;
|
this._referenceCount = 0;
|
||||||
//this._referenceTimestamp = Nitro.instance.time;
|
//this._referenceTimestamp = Nitro.instance.time;
|
||||||
@ -90,20 +90,20 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
const assets = data.assets;
|
const assets = data.assets;
|
||||||
const palettes = data.palettes;
|
const palettes = data.palettes;
|
||||||
|
|
||||||
if (assets) this.defineAssets(assets);
|
if(assets) this.defineAssets(assets);
|
||||||
|
|
||||||
if (palettes) this.definePalettes(palettes);
|
if(palettes) this.definePalettes(palettes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private defineAssets(assets: { [index: string]: IAsset }): void
|
private defineAssets(assets: { [index: string]: IAsset }): void
|
||||||
{
|
{
|
||||||
if (!assets) return;
|
if(!assets) return;
|
||||||
|
|
||||||
for (const name in assets)
|
for(const name in assets)
|
||||||
{
|
{
|
||||||
const asset = assets[name];
|
const asset = assets[name];
|
||||||
|
|
||||||
if (!asset) continue;
|
if(!asset) continue;
|
||||||
|
|
||||||
const x = (-(asset.x) || 0);
|
const x = (-(asset.x) || 0);
|
||||||
const y = (-(asset.y) || 0);
|
const y = (-(asset.y) || 0);
|
||||||
@ -112,23 +112,23 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
const usesPalette = (asset.usesPalette || false);
|
const usesPalette = (asset.usesPalette || false);
|
||||||
let source = (asset.source || '');
|
let source = (asset.source || '');
|
||||||
|
|
||||||
if (asset.flipH && source.length) flipH = true;
|
if(asset.flipH && source.length) flipH = true;
|
||||||
|
|
||||||
// if(asset.flipV && source.length) flipV = true;
|
// if(asset.flipV && source.length) flipV = true;
|
||||||
|
|
||||||
if (!source.length) source = name;
|
if(!source.length) source = name;
|
||||||
|
|
||||||
const texture = this.getLibraryAsset(source);
|
const texture = this.getLibraryAsset(source);
|
||||||
|
|
||||||
if (!texture) continue;
|
if(!texture) continue;
|
||||||
|
|
||||||
let didAddAsset = this.createAsset(name, source, texture, flipH, flipV, x, y, usesPalette);
|
let didAddAsset = this.createAsset(name, source, texture, flipH, flipV, x, y, usesPalette);
|
||||||
|
|
||||||
if (!didAddAsset)
|
if(!didAddAsset)
|
||||||
{
|
{
|
||||||
const existingAsset = this.getAsset(name);
|
const existingAsset = this.getAsset(name);
|
||||||
|
|
||||||
if (existingAsset && (existingAsset.name !== existingAsset.source))
|
if(existingAsset && (existingAsset.name !== existingAsset.source))
|
||||||
{
|
{
|
||||||
didAddAsset = this.replaceAsset(name, source, texture, flipH, flipV, x, y, usesPalette);
|
didAddAsset = this.replaceAsset(name, source, texture, flipH, flipV, x, y, usesPalette);
|
||||||
}
|
}
|
||||||
@ -138,28 +138,28 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
private definePalettes(palettes: { [index: string]: IAssetPalette }): void
|
private definePalettes(palettes: { [index: string]: IAssetPalette }): void
|
||||||
{
|
{
|
||||||
if (!palettes) return;
|
if(!palettes) return;
|
||||||
|
|
||||||
for (const name in palettes)
|
for(const name in palettes)
|
||||||
{
|
{
|
||||||
const palette = palettes[name];
|
const palette = palettes[name];
|
||||||
|
|
||||||
if (!palette) continue;
|
if(!palette) continue;
|
||||||
|
|
||||||
const id = palette.id.toString();
|
const id = palette.id.toString();
|
||||||
|
|
||||||
if (this._palettes.get(id)) continue;
|
if(this._palettes.get(id)) continue;
|
||||||
|
|
||||||
let colorOne = 0xFFFFFF;
|
let colorOne = 0xFFFFFF;
|
||||||
let colorTwo = 0xFFFFFF;
|
let colorTwo = 0xFFFFFF;
|
||||||
|
|
||||||
let color = palette.color1;
|
let color = palette.color1;
|
||||||
|
|
||||||
if (color && color.length > 0) colorOne = parseInt(color, 16);
|
if(color && color.length > 0) colorOne = parseInt(color, 16);
|
||||||
|
|
||||||
color = palette.color2;
|
color = palette.color2;
|
||||||
|
|
||||||
if (color && color.length > 0) colorTwo = parseInt(color, 16);
|
if(color && color.length > 0) colorTwo = parseInt(color, 16);
|
||||||
|
|
||||||
this._palettes.set(id, new GraphicAssetPalette(palette.rgb, colorOne, colorTwo));
|
this._palettes.set(id, new GraphicAssetPalette(palette.rgb, colorOne, colorTwo));
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
private createAsset(name: string, source: string, texture: Texture<Resource>, flipH: boolean, flipV: boolean, x: number, y: number, usesPalette: boolean): boolean
|
private createAsset(name: string, source: string, texture: Texture<Resource>, flipH: boolean, flipV: boolean, x: number, y: number, usesPalette: boolean): boolean
|
||||||
{
|
{
|
||||||
if (this._assets.get(name)) return false;
|
if(this._assets.get(name)) return false;
|
||||||
|
|
||||||
const graphicAsset = GraphicAsset.createAsset(name, source, texture, x, y, flipH, flipV, usesPalette);
|
const graphicAsset = GraphicAsset.createAsset(name, source, texture, x, y, flipH, flipV, usesPalette);
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
{
|
{
|
||||||
const existing = this._assets.get(name);
|
const existing = this._assets.get(name);
|
||||||
|
|
||||||
if (existing)
|
if(existing)
|
||||||
{
|
{
|
||||||
this._assets.delete(name);
|
this._assets.delete(name);
|
||||||
|
|
||||||
@ -192,11 +192,11 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
public getAsset(name: string): IGraphicAsset
|
public getAsset(name: string): IGraphicAsset
|
||||||
{
|
{
|
||||||
if (!name) return null;
|
if(!name) return null;
|
||||||
|
|
||||||
const existing = this._assets.get(name);
|
const existing = this._assets.get(name);
|
||||||
|
|
||||||
if (!existing) return null;
|
if(!existing) return null;
|
||||||
|
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
@ -207,19 +207,19 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
let asset = this.getAsset(saveName);
|
let asset = this.getAsset(saveName);
|
||||||
|
|
||||||
if (!asset)
|
if(!asset)
|
||||||
{
|
{
|
||||||
asset = this.getAsset(name);
|
asset = this.getAsset(name);
|
||||||
|
|
||||||
if (!asset || !asset.usesPalette) return asset;
|
if(!asset || !asset.usesPalette) return asset;
|
||||||
|
|
||||||
const palette = this.getPalette(paletteName);
|
const palette = this.getPalette(paletteName);
|
||||||
|
|
||||||
if (palette)
|
if(palette)
|
||||||
{
|
{
|
||||||
const texture = palette.applyPalette(asset.texture);
|
const texture = palette.applyPalette(asset.texture);
|
||||||
|
|
||||||
if (texture)
|
if(texture)
|
||||||
{
|
{
|
||||||
this._paletteAssetNames.push(saveName);
|
this._paletteAssetNames.push(saveName);
|
||||||
|
|
||||||
@ -247,36 +247,36 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
{
|
{
|
||||||
const palette = this.getPalette(paletteName);
|
const palette = this.getPalette(paletteName);
|
||||||
|
|
||||||
if (palette) return [palette.primaryColor, palette.secondaryColor];
|
if(palette) return [palette.primaryColor, palette.secondaryColor];
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPalette(name: string): GraphicAssetPalette
|
public getPalette(name: string): GraphicAssetPalette
|
||||||
{
|
{
|
||||||
if (!name) return null;
|
if(!name) return null;
|
||||||
|
|
||||||
const existing = this._palettes.get(name);
|
const existing = this._palettes.get(name);
|
||||||
|
|
||||||
if (!existing) return null;
|
if(!existing) return null;
|
||||||
|
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addAsset(name: string, texture: Texture<Resource>, override: boolean, x: number = 0, y: number = 0, flipH: boolean = false, flipV: boolean = false): boolean
|
public addAsset(name: string, texture: Texture<Resource>, override: boolean, x: number = 0, y: number = 0, flipH: boolean = false, flipV: boolean = false): boolean
|
||||||
{
|
{
|
||||||
if (!name || !texture) return false;
|
if(!name || !texture) return false;
|
||||||
|
|
||||||
const existingTexture = this.getLibraryAsset(name);
|
const existingTexture = this.getLibraryAsset(name);
|
||||||
|
|
||||||
if (!existingTexture)
|
if(!existingTexture)
|
||||||
{
|
{
|
||||||
this._textures.set(name, texture);
|
this._textures.set(name, texture);
|
||||||
|
|
||||||
return this.createAsset(name, name, texture, flipH, flipV, x, y, false);
|
return this.createAsset(name, name, texture, flipH, flipV, x, y, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (override)
|
if(override)
|
||||||
{
|
{
|
||||||
existingTexture.baseTexture = texture.baseTexture;
|
existingTexture.baseTexture = texture.baseTexture;
|
||||||
existingTexture.frame = texture.frame;
|
existingTexture.frame = texture.frame;
|
||||||
@ -294,13 +294,13 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
{
|
{
|
||||||
const existing = this._assets.get(name);
|
const existing = this._assets.get(name);
|
||||||
|
|
||||||
if (!existing) return;
|
if(!existing) return;
|
||||||
|
|
||||||
this._assets.delete(name);
|
this._assets.delete(name);
|
||||||
|
|
||||||
const texture = this.getLibraryAsset(existing.source);
|
const texture = this.getLibraryAsset(existing.source);
|
||||||
|
|
||||||
if (texture)
|
if(texture)
|
||||||
{
|
{
|
||||||
this._textures.delete(existing.source);
|
this._textures.delete(existing.source);
|
||||||
|
|
||||||
@ -312,26 +312,26 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
public getLibraryAsset(name: string): Texture<Resource>
|
public getLibraryAsset(name: string): Texture<Resource>
|
||||||
{
|
{
|
||||||
if (!name) return null;
|
if(!name) return null;
|
||||||
|
|
||||||
name = this._name + '_' + name;
|
name = this._name + '_' + name;
|
||||||
|
|
||||||
const texture = this._textures.get(name);
|
const texture = this._textures.get(name);
|
||||||
|
|
||||||
if (!texture) return null;
|
if(!texture) return null;
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
private addLibraryAsset(textures: Dict<Texture<Resource>>): void
|
private addLibraryAsset(textures: Dict<Texture<Resource>>): void
|
||||||
{
|
{
|
||||||
if (!textures) return;
|
if(!textures) return;
|
||||||
|
|
||||||
for (const name in textures)
|
for(const name in textures)
|
||||||
{
|
{
|
||||||
const texture = textures[name];
|
const texture = textures[name];
|
||||||
|
|
||||||
if (!texture) continue;
|
if(!texture) continue;
|
||||||
|
|
||||||
this._textures.set(GraphicAssetCollection.removeFileExtension(name), texture);
|
this._textures.set(GraphicAssetCollection.removeFileExtension(name), texture);
|
||||||
}
|
}
|
||||||
@ -339,11 +339,11 @@ export class GraphicAssetCollection implements IGraphicAssetCollection
|
|||||||
|
|
||||||
private disposePaletteAssets(disposeAll: boolean = true): void
|
private disposePaletteAssets(disposeAll: boolean = true): void
|
||||||
{
|
{
|
||||||
if (this._paletteAssetNames)
|
if(this._paletteAssetNames)
|
||||||
{
|
{
|
||||||
if (disposeAll || (this._paletteAssetNames.length > GraphicAssetCollection.PALETTE_ASSET_DISPOSE_THRESHOLD))
|
if(disposeAll || (this._paletteAssetNames.length > GraphicAssetCollection.PALETTE_ASSET_DISPOSE_THRESHOLD))
|
||||||
{
|
{
|
||||||
for (const name of this._paletteAssetNames) this.disposeAsset(name);
|
for(const name of this._paletteAssetNames) this.disposeAsset(name);
|
||||||
|
|
||||||
this._paletteAssetNames = [];
|
this._paletteAssetNames = [];
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export class GraphicAssetPalette
|
|||||||
{
|
{
|
||||||
this._palette = palette;
|
this._palette = palette;
|
||||||
|
|
||||||
while (this._palette.length < 256) this._palette.push([0, 0, 0]);
|
while(this._palette.length < 256) this._palette.push([0, 0, 0]);
|
||||||
|
|
||||||
this._primaryColor = primaryColor;
|
this._primaryColor = primaryColor;
|
||||||
this._secondaryColor = secondaryColor;
|
this._secondaryColor = secondaryColor;
|
||||||
@ -30,11 +30,11 @@ export class GraphicAssetPalette
|
|||||||
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)
|
||||||
{
|
{
|
||||||
let paletteColor = this._palette[data[i + 1]];
|
let paletteColor = this._palette[data[i + 1]];
|
||||||
|
|
||||||
if (paletteColor === undefined) paletteColor = [0, 0, 0];
|
if(paletteColor === undefined) paletteColor = [0, 0, 0];
|
||||||
|
|
||||||
data[i] = paletteColor[0];
|
data[i] = paletteColor[0];
|
||||||
data[i + 1] = paletteColor[1];
|
data[i + 1] = paletteColor[1];
|
||||||
|
@ -22,14 +22,14 @@ export class NitroBundle
|
|||||||
|
|
||||||
let fileCount = binaryReader.readShort();
|
let fileCount = binaryReader.readShort();
|
||||||
|
|
||||||
while (fileCount > 0)
|
while(fileCount > 0)
|
||||||
{
|
{
|
||||||
const fileNameLength = binaryReader.readShort();
|
const fileNameLength = binaryReader.readShort();
|
||||||
const fileName = binaryReader.readBytes(fileNameLength).toString();
|
const fileName = binaryReader.readBytes(fileNameLength).toString();
|
||||||
const fileLength = binaryReader.readInt();
|
const fileLength = binaryReader.readInt();
|
||||||
const buffer = binaryReader.readBytes(fileLength);
|
const buffer = binaryReader.readBytes(fileLength);
|
||||||
|
|
||||||
if (fileName.endsWith('.json'))
|
if(fileName.endsWith('.json'))
|
||||||
{
|
{
|
||||||
const decompressed = inflate((buffer.toArrayBuffer() as Data));
|
const decompressed = inflate((buffer.toArrayBuffer() as Data));
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export class Disposable implements IDisposable
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if (this._isDisposed || this._isDisposing) return;
|
if(this._isDisposed || this._isDisposing) return;
|
||||||
|
|
||||||
this._isDisposing = true;
|
this._isDisposing = true;
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
|||||||
|
|
||||||
public addEventListener(type: string, callback: Function): void
|
public addEventListener(type: string, callback: Function): void
|
||||||
{
|
{
|
||||||
if (!type || !callback) return;
|
if(!type || !callback) return;
|
||||||
|
|
||||||
const existing = this._listeners.get(type);
|
const existing = this._listeners.get(type);
|
||||||
|
|
||||||
if (!existing)
|
if(!existing)
|
||||||
{
|
{
|
||||||
this._listeners.set(type, [callback]);
|
this._listeners.set(type, [callback]);
|
||||||
|
|
||||||
@ -41,19 +41,19 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
|||||||
|
|
||||||
public removeEventListener(type: string, callback: any): void
|
public removeEventListener(type: string, callback: any): void
|
||||||
{
|
{
|
||||||
if (!type || !callback) return;
|
if(!type || !callback) return;
|
||||||
|
|
||||||
const existing = this._listeners.get(type);
|
const existing = this._listeners.get(type);
|
||||||
|
|
||||||
if (!existing || !existing.length) return;
|
if(!existing || !existing.length) return;
|
||||||
|
|
||||||
for (const [i, cb] of existing.entries())
|
for(const [i, cb] of existing.entries())
|
||||||
{
|
{
|
||||||
if (!cb || (cb !== callback)) continue;
|
if(!cb || (cb !== callback)) continue;
|
||||||
|
|
||||||
existing.splice(i, 1);
|
existing.splice(i, 1);
|
||||||
|
|
||||||
if (!existing.length) this._listeners.delete(type);
|
if(!existing.length) this._listeners.delete(type);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
|||||||
|
|
||||||
public dispatchEvent(event: NitroEvent): boolean
|
public dispatchEvent(event: NitroEvent): boolean
|
||||||
{
|
{
|
||||||
if (!event) return false;
|
if(!event) return false;
|
||||||
|
|
||||||
//if (Nitro.instance.getConfiguration<boolean>('system.dispatcher.log')) this._logger.log('Dispatched Event', event.type);
|
//if (Nitro.instance.getConfiguration<boolean>('system.dispatcher.log')) this._logger.log('Dispatched Event', event.type);
|
||||||
|
|
||||||
@ -74,18 +74,18 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
|||||||
{
|
{
|
||||||
const existing = this._listeners.get(event.type);
|
const existing = this._listeners.get(event.type);
|
||||||
|
|
||||||
if (!existing || !existing.length) return;
|
if(!existing || !existing.length) return;
|
||||||
|
|
||||||
const callbacks = [];
|
const callbacks = [];
|
||||||
|
|
||||||
for (const callback of existing)
|
for(const callback of existing)
|
||||||
{
|
{
|
||||||
if (!callback) continue;
|
if(!callback) continue;
|
||||||
|
|
||||||
callbacks.push(callback);
|
callbacks.push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (callbacks.length)
|
while(callbacks.length)
|
||||||
{
|
{
|
||||||
const callback = callbacks.shift();
|
const callback = callbacks.shift();
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ export class NitroLogger implements INitroLogger
|
|||||||
|
|
||||||
public printMessage(modus: string, ...message: any[]): void
|
public printMessage(modus: string, ...message: any[]): void
|
||||||
{
|
{
|
||||||
if (!this._print) return;
|
if(!this._print) return;
|
||||||
|
|
||||||
NitroLogger.log(this._name, modus, ...message);
|
NitroLogger.log(this._name, modus, ...message);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ export class NitroLogger implements INitroLogger
|
|||||||
{
|
{
|
||||||
const logPrefix = `[Nitro] [${name}]`;
|
const logPrefix = `[Nitro] [${name}]`;
|
||||||
|
|
||||||
switch (modus)
|
switch(modus)
|
||||||
{
|
{
|
||||||
case 'error':
|
case 'error':
|
||||||
console.error(logPrefix, ...message);
|
console.error(logPrefix, ...message);
|
||||||
|
@ -26,7 +26,7 @@ export class NitroManager extends Disposable implements INitroManager
|
|||||||
|
|
||||||
public init(): void
|
public init(): void
|
||||||
{
|
{
|
||||||
if (this._isLoaded || this._isLoading || this.isDisposing) return;
|
if(this._isLoaded || this._isLoading || this.isDisposing) return;
|
||||||
|
|
||||||
this._isLoading = true;
|
this._isLoading = true;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ export class NitroManager extends Disposable implements INitroManager
|
|||||||
|
|
||||||
protected onDispose(): void
|
protected onDispose(): void
|
||||||
{
|
{
|
||||||
if (this._events) this._events.dispose();
|
if(this._events) this._events.dispose();
|
||||||
|
|
||||||
super.onDispose();
|
super.onDispose();
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,16 @@ export class CommunicationManager extends Disposable implements ICommunicationMa
|
|||||||
|
|
||||||
protected onDispose(): void
|
protected onDispose(): void
|
||||||
{
|
{
|
||||||
if (!this._connections || !this._connections.length) return;
|
if(!this._connections || !this._connections.length) return;
|
||||||
|
|
||||||
for (const connection of this._connections.values()) connection && connection.dispose();
|
for(const connection of this._connections.values()) connection && connection.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public createConnection(stateListener: IConnectionStateListener = null): IConnection
|
public createConnection(stateListener: IConnectionStateListener = null): IConnection
|
||||||
{
|
{
|
||||||
const connection = new SocketConnection(this, stateListener);
|
const connection = new SocketConnection(this, stateListener);
|
||||||
|
|
||||||
if (!connection) return;
|
if(!connection) return;
|
||||||
|
|
||||||
this._connections.push(connection);
|
this._connections.push(connection);
|
||||||
|
|
||||||
@ -35,15 +35,15 @@ export class CommunicationManager extends Disposable implements ICommunicationMa
|
|||||||
{
|
{
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
while (index < this._connections.length)
|
while(index < this._connections.length)
|
||||||
{
|
{
|
||||||
const connection = this._connections[index];
|
const connection = this._connections[index];
|
||||||
|
|
||||||
connection.processReceivedData();
|
connection.processReceivedData();
|
||||||
|
|
||||||
if (this.disposed) return;
|
if(this.disposed) return;
|
||||||
|
|
||||||
if (connection.disposed) this._connections.splice(index, 1);
|
if(connection.disposed) this._connections.splice(index, 1);
|
||||||
else index++;
|
else index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
public init(socketUrl: string): void
|
public init(socketUrl: string): void
|
||||||
{
|
{
|
||||||
if (this._stateListener)
|
if(this._stateListener)
|
||||||
{
|
{
|
||||||
this._stateListener.connectionInit(socketUrl);
|
this._stateListener.connectionInit(socketUrl);
|
||||||
}
|
}
|
||||||
@ -67,13 +67,13 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
public onReady(): void
|
public onReady(): void
|
||||||
{
|
{
|
||||||
if (this._isReady) return;
|
if(this._isReady) return;
|
||||||
|
|
||||||
this._isReady = true;
|
this._isReady = true;
|
||||||
|
|
||||||
if (this._pendingServerMessages && this._pendingServerMessages.length) this.processWrappers(...this._pendingServerMessages);
|
if(this._pendingServerMessages && this._pendingServerMessages.length) this.processWrappers(...this._pendingServerMessages);
|
||||||
|
|
||||||
if (this._pendingClientMessages && this._pendingClientMessages.length) this.send(...this._pendingClientMessages);
|
if(this._pendingClientMessages && this._pendingClientMessages.length) this.send(...this._pendingClientMessages);
|
||||||
|
|
||||||
this._pendingServerMessages = [];
|
this._pendingServerMessages = [];
|
||||||
this._pendingClientMessages = [];
|
this._pendingClientMessages = [];
|
||||||
@ -81,7 +81,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
private createSocket(socketUrl: string): void
|
private createSocket(socketUrl: string): void
|
||||||
{
|
{
|
||||||
if (!socketUrl) return;
|
if(!socketUrl) return;
|
||||||
|
|
||||||
this.destroySocket();
|
this.destroySocket();
|
||||||
|
|
||||||
@ -96,14 +96,14 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
private destroySocket(): void
|
private destroySocket(): void
|
||||||
{
|
{
|
||||||
if (!this._socket) return;
|
if(!this._socket) return;
|
||||||
|
|
||||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen);
|
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen);
|
||||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose);
|
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose);
|
||||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError);
|
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_ERROR, this.onError);
|
||||||
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, this.onMessage);
|
this._socket.removeEventListener(WebSocketEventEnum.CONNECTION_MESSAGE, this.onMessage);
|
||||||
|
|
||||||
if (this._socket.readyState === WebSocket.OPEN) this._socket.close();
|
if(this._socket.readyState === WebSocket.OPEN) this._socket.close();
|
||||||
|
|
||||||
this._socket = null;
|
this._socket = null;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
private onMessage(event: MessageEvent): void
|
private onMessage(event: MessageEvent): void
|
||||||
{
|
{
|
||||||
if (!event) return;
|
if(!event) return;
|
||||||
|
|
||||||
//this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event);
|
//this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event);
|
||||||
|
|
||||||
@ -153,26 +153,26 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
public send(...composers: IMessageComposer<unknown[]>[]): boolean
|
public send(...composers: IMessageComposer<unknown[]>[]): boolean
|
||||||
{
|
{
|
||||||
if (this.disposed || !composers) return false;
|
if(this.disposed || !composers) return false;
|
||||||
|
|
||||||
composers = [...composers];
|
composers = [...composers];
|
||||||
|
|
||||||
if (this._isAuthenticated && !this._isReady)
|
if(this._isAuthenticated && !this._isReady)
|
||||||
{
|
{
|
||||||
if (!this._pendingClientMessages) this._pendingClientMessages = [];
|
if(!this._pendingClientMessages) this._pendingClientMessages = [];
|
||||||
|
|
||||||
this._pendingClientMessages.push(...composers);
|
this._pendingClientMessages.push(...composers);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const composer of composers)
|
for(const composer of composers)
|
||||||
{
|
{
|
||||||
if (!composer) continue;
|
if(!composer) continue;
|
||||||
|
|
||||||
const header = this._messages.getComposerId(composer);
|
const header = this._messages.getComposerId(composer);
|
||||||
|
|
||||||
if (header === -1)
|
if(header === -1)
|
||||||
{
|
{
|
||||||
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log(`Unknown Composer: ${composer.constructor.name}`);
|
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log(`Unknown Composer: ${composer.constructor.name}`);
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
const message = composer.getMessageArray();
|
const message = composer.getMessageArray();
|
||||||
const encoded = this._codec.encode(header, message);
|
const encoded = this._codec.encode(header, message);
|
||||||
|
|
||||||
if (!encoded)
|
if(!encoded)
|
||||||
{
|
{
|
||||||
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('Encoding Failed', composer.constructor.name);
|
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('Encoding Failed', composer.constructor.name);
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
private write(buffer: ArrayBuffer): void
|
private write(buffer: ArrayBuffer): void
|
||||||
{
|
{
|
||||||
if (this._socket.readyState !== WebSocket.OPEN) return;
|
if(this._socket.readyState !== WebSocket.OPEN) return;
|
||||||
|
|
||||||
this._socket.send(buffer);
|
this._socket.send(buffer);
|
||||||
}
|
}
|
||||||
@ -221,11 +221,11 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
{
|
{
|
||||||
const wrappers = this.splitReceivedMessages();
|
const wrappers = this.splitReceivedMessages();
|
||||||
|
|
||||||
if (!wrappers || !wrappers.length) return;
|
if(!wrappers || !wrappers.length) return;
|
||||||
|
|
||||||
if (this._isAuthenticated && !this._isReady)
|
if(this._isAuthenticated && !this._isReady)
|
||||||
{
|
{
|
||||||
if (!this._pendingServerMessages) this._pendingServerMessages = [];
|
if(!this._pendingServerMessages) this._pendingServerMessages = [];
|
||||||
|
|
||||||
this._pendingServerMessages.push(...wrappers);
|
this._pendingServerMessages.push(...wrappers);
|
||||||
|
|
||||||
@ -237,15 +237,15 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
private processWrappers(...wrappers: IMessageDataWrapper[]): void
|
private processWrappers(...wrappers: IMessageDataWrapper[]): void
|
||||||
{
|
{
|
||||||
if (!wrappers || !wrappers.length) return;
|
if(!wrappers || !wrappers.length) return;
|
||||||
|
|
||||||
for (const wrapper of wrappers)
|
for(const wrapper of wrappers)
|
||||||
{
|
{
|
||||||
if (!wrapper) continue;
|
if(!wrapper) continue;
|
||||||
|
|
||||||
const messages = this.getMessagesForWrapper(wrapper);
|
const messages = this.getMessagesForWrapper(wrapper);
|
||||||
|
|
||||||
if (!messages || !messages.length) continue;
|
if(!messages || !messages.length) continue;
|
||||||
|
|
||||||
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser);
|
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser);
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
private splitReceivedMessages(): IMessageDataWrapper[]
|
private splitReceivedMessages(): IMessageDataWrapper[]
|
||||||
{
|
{
|
||||||
if (!this._dataBuffer || !this._dataBuffer.byteLength) return null;
|
if(!this._dataBuffer || !this._dataBuffer.byteLength) return null;
|
||||||
|
|
||||||
return this._codec.decode(this);
|
return this._codec.decode(this);
|
||||||
}
|
}
|
||||||
@ -272,11 +272,11 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
private getMessagesForWrapper(wrapper: IMessageDataWrapper): IMessageEvent[]
|
private getMessagesForWrapper(wrapper: IMessageDataWrapper): IMessageEvent[]
|
||||||
{
|
{
|
||||||
if (!wrapper) return null;
|
if(!wrapper) return null;
|
||||||
|
|
||||||
const events = this._messages.getEvents(wrapper.header);
|
const events = this._messages.getEvents(wrapper.header);
|
||||||
|
|
||||||
if (!events || !events.length)
|
if(!events || !events.length)
|
||||||
{
|
{
|
||||||
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
|
//if (Nitro.instance.getConfiguration<boolean>('system.packet.log')) this.logger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
|
||||||
|
|
||||||
@ -288,9 +288,9 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const parser = new events[0].parserClass();
|
const parser = new events[0].parserClass();
|
||||||
|
|
||||||
if (!parser || !parser.flush() || !parser.parse(wrapper)) return null;
|
if(!parser || !parser.flush() || !parser.parse(wrapper)) return null;
|
||||||
|
|
||||||
for (const event of events) (event.parser = parser);
|
for(const event of events) (event.parser = parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (e)
|
catch (e)
|
||||||
@ -307,33 +307,33 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
{
|
{
|
||||||
messages = [...messages];
|
messages = [...messages];
|
||||||
|
|
||||||
for (const message of messages)
|
for(const message of messages)
|
||||||
{
|
{
|
||||||
if (!message) continue;
|
if(!message) continue;
|
||||||
|
|
||||||
message.connection = this;
|
message.connection = this;
|
||||||
|
|
||||||
if (message.callBack) message.callBack(message);
|
if(message.callBack) message.callBack(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerMessages(configuration: IMessageConfiguration): void
|
public registerMessages(configuration: IMessageConfiguration): void
|
||||||
{
|
{
|
||||||
if (!configuration) return;
|
if(!configuration) return;
|
||||||
|
|
||||||
this._messages.registerMessages(configuration);
|
this._messages.registerMessages(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public addMessageEvent(event: IMessageEvent): void
|
public addMessageEvent(event: IMessageEvent): void
|
||||||
{
|
{
|
||||||
if (!event || !this._messages) return;
|
if(!event || !this._messages) return;
|
||||||
|
|
||||||
this._messages.registerMessageEvent(event);
|
this._messages.registerMessageEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeMessageEvent(event: IMessageEvent): void
|
public removeMessageEvent(event: IMessageEvent): void
|
||||||
{
|
{
|
||||||
if (!event || !this._messages) return;
|
if(!event || !this._messages) return;
|
||||||
|
|
||||||
this._messages.removeMessageEvent(event);
|
this._messages.removeMessageEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,14 @@ export class EvaWireDataWrapper implements IMessageDataWrapper
|
|||||||
|
|
||||||
public readBytes(length: number): IBinaryReader
|
public readBytes(length: number): IBinaryReader
|
||||||
{
|
{
|
||||||
if (!this._buffer) return null;
|
if(!this._buffer) return null;
|
||||||
|
|
||||||
return this._buffer.readBytes(length);
|
return this._buffer.readBytes(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readByte(): number
|
public readByte(): number
|
||||||
{
|
{
|
||||||
if (!this._buffer) return -1;
|
if(!this._buffer) return -1;
|
||||||
|
|
||||||
return this._buffer.readByte();
|
return this._buffer.readByte();
|
||||||
}
|
}
|
||||||
@ -32,28 +32,28 @@ export class EvaWireDataWrapper implements IMessageDataWrapper
|
|||||||
|
|
||||||
public readShort(): number
|
public readShort(): number
|
||||||
{
|
{
|
||||||
if (!this._buffer) return -1;
|
if(!this._buffer) return -1;
|
||||||
|
|
||||||
return this._buffer.readShort();
|
return this._buffer.readShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public readInt(): number
|
public readInt(): number
|
||||||
{
|
{
|
||||||
if (!this._buffer) return -1;
|
if(!this._buffer) return -1;
|
||||||
|
|
||||||
return this._buffer.readInt();
|
return this._buffer.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public readFloat(): number
|
public readFloat(): number
|
||||||
{
|
{
|
||||||
if (!this._buffer) return -1;
|
if(!this._buffer) return -1;
|
||||||
|
|
||||||
return this._buffer.readFloat();
|
return this._buffer.readFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
public readDouble(): number
|
public readDouble(): number
|
||||||
{
|
{
|
||||||
if (!this._buffer) return -1;
|
if(!this._buffer) return -1;
|
||||||
|
|
||||||
return this._buffer.readDouble();
|
return this._buffer.readDouble();
|
||||||
}
|
}
|
||||||
|
@ -12,19 +12,19 @@ export class EvaWireFormat implements ICodec
|
|||||||
|
|
||||||
writer.writeShort(header);
|
writer.writeShort(header);
|
||||||
|
|
||||||
for (const value of messages)
|
for(const value of messages)
|
||||||
{
|
{
|
||||||
let type: string = typeof value;
|
let type: string = typeof value;
|
||||||
|
|
||||||
if (type === 'object')
|
if(type === 'object')
|
||||||
{
|
{
|
||||||
if (value === null) type = 'null';
|
if(value === null) type = 'null';
|
||||||
else if (value instanceof Byte) type = 'byte';
|
else if(value instanceof Byte) type = 'byte';
|
||||||
else if (value instanceof Short) type = 'short';
|
else if(value instanceof Short) type = 'short';
|
||||||
else if (value instanceof ArrayBuffer) type = 'arraybuffer';
|
else if(value instanceof ArrayBuffer) type = 'arraybuffer';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case 'undefined':
|
case 'undefined':
|
||||||
case 'null':
|
case 'null':
|
||||||
@ -43,7 +43,7 @@ export class EvaWireFormat implements ICodec
|
|||||||
writer.writeByte(value ? 1 : 0);
|
writer.writeByte(value ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case 'string':
|
case 'string':
|
||||||
if (!value) writer.writeShort(0);
|
if(!value) writer.writeShort(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
writer.writeString(value, true);
|
writer.writeString(value, true);
|
||||||
@ -57,25 +57,25 @@ export class EvaWireFormat implements ICodec
|
|||||||
|
|
||||||
const buffer = writer.getBuffer();
|
const buffer = writer.getBuffer();
|
||||||
|
|
||||||
if (!buffer) return null;
|
if(!buffer) return null;
|
||||||
|
|
||||||
return new BinaryWriter().writeInt(buffer.byteLength).writeBytes(buffer);
|
return new BinaryWriter().writeInt(buffer.byteLength).writeBytes(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public decode(connection: IConnection): IMessageDataWrapper[]
|
public decode(connection: IConnection): IMessageDataWrapper[]
|
||||||
{
|
{
|
||||||
if (!connection || !connection.dataBuffer || !connection.dataBuffer.byteLength) return null;
|
if(!connection || !connection.dataBuffer || !connection.dataBuffer.byteLength) return null;
|
||||||
|
|
||||||
const wrappers: IMessageDataWrapper[] = [];
|
const wrappers: IMessageDataWrapper[] = [];
|
||||||
|
|
||||||
while (connection.dataBuffer.byteLength)
|
while(connection.dataBuffer.byteLength)
|
||||||
{
|
{
|
||||||
if (connection.dataBuffer.byteLength < 4) break;
|
if(connection.dataBuffer.byteLength < 4) break;
|
||||||
|
|
||||||
const container = new BinaryReader(connection.dataBuffer);
|
const container = new BinaryReader(connection.dataBuffer);
|
||||||
const length = container.readInt();
|
const length = container.readInt();
|
||||||
|
|
||||||
if (length > (connection.dataBuffer.byteLength - 4)) break;
|
if(length > (connection.dataBuffer.byteLength - 4)) break;
|
||||||
|
|
||||||
const extracted = container.readBytes(length);
|
const extracted = container.readBytes(length);
|
||||||
|
|
||||||
|
@ -23,36 +23,36 @@ export class MessageClassManager
|
|||||||
|
|
||||||
public registerMessages(configuration: IMessageConfiguration): void
|
public registerMessages(configuration: IMessageConfiguration): void
|
||||||
{
|
{
|
||||||
for (const [header, handler] of configuration.events) this.registerMessageEventClass(header, handler);
|
for(const [header, handler] of configuration.events) this.registerMessageEventClass(header, handler);
|
||||||
|
|
||||||
for (const [header, handler] of configuration.composers) this.registerMessageComposerClass(header, handler);
|
for(const [header, handler] of configuration.composers) this.registerMessageComposerClass(header, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerMessageEventClass(header: number, handler: Function): void
|
private registerMessageEventClass(header: number, handler: Function): void
|
||||||
{
|
{
|
||||||
if (!header || !handler) return;
|
if(!header || !handler) return;
|
||||||
|
|
||||||
this._messageIdByEvent.set(handler, header);
|
this._messageIdByEvent.set(handler, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerMessageComposerClass(header: number, handler: Function): void
|
private registerMessageComposerClass(header: number, handler: Function): void
|
||||||
{
|
{
|
||||||
if (!header || !handler) return;
|
if(!header || !handler) return;
|
||||||
|
|
||||||
this._messageIdByComposer.set(handler, header);
|
this._messageIdByComposer.set(handler, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerMessageEvent(event: IMessageEvent): void
|
public registerMessageEvent(event: IMessageEvent): void
|
||||||
{
|
{
|
||||||
if (!event) return;
|
if(!event) return;
|
||||||
|
|
||||||
const header = this.getEventId(event);
|
const header = this.getEventId(event);
|
||||||
|
|
||||||
if (!header) return;
|
if(!header) return;
|
||||||
|
|
||||||
let existing = this._messageInstancesById.get(header);
|
let existing = this._messageInstancesById.get(header);
|
||||||
|
|
||||||
if (!existing || !existing.length)
|
if(!existing || !existing.length)
|
||||||
{
|
{
|
||||||
existing = [];
|
existing = [];
|
||||||
|
|
||||||
@ -64,25 +64,25 @@ export class MessageClassManager
|
|||||||
|
|
||||||
public removeMessageEvent(event: IMessageEvent): void
|
public removeMessageEvent(event: IMessageEvent): void
|
||||||
{
|
{
|
||||||
if (!event) return;
|
if(!event) return;
|
||||||
|
|
||||||
const header = this.getEventId(event);
|
const header = this.getEventId(event);
|
||||||
|
|
||||||
if (!header) return;
|
if(!header) return;
|
||||||
|
|
||||||
const existing = this._messageInstancesById.get(header);
|
const existing = this._messageInstancesById.get(header);
|
||||||
|
|
||||||
if (!existing) return;
|
if(!existing) return;
|
||||||
|
|
||||||
for (const [index, message] of existing.entries())
|
for(const [index, message] of existing.entries())
|
||||||
{
|
{
|
||||||
if (!message) continue;
|
if(!message) continue;
|
||||||
|
|
||||||
if (message !== event) continue;
|
if(message !== event) continue;
|
||||||
|
|
||||||
existing.splice(index, 1);
|
existing.splice(index, 1);
|
||||||
|
|
||||||
if (existing.length === 0) this._messageInstancesById.delete(header);
|
if(existing.length === 0) this._messageInstancesById.delete(header);
|
||||||
|
|
||||||
message.dispose();
|
message.dispose();
|
||||||
|
|
||||||
@ -92,36 +92,36 @@ export class MessageClassManager
|
|||||||
|
|
||||||
public getEvents(header: number): IMessageEvent[]
|
public getEvents(header: number): IMessageEvent[]
|
||||||
{
|
{
|
||||||
if (!header) return;
|
if(!header) return;
|
||||||
|
|
||||||
const existing = this._messageInstancesById.get(header);
|
const existing = this._messageInstancesById.get(header);
|
||||||
|
|
||||||
if (!existing) return;
|
if(!existing) return;
|
||||||
|
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getEventId(event: IMessageEvent): number
|
public getEventId(event: IMessageEvent): number
|
||||||
{
|
{
|
||||||
if (!event) return -1;
|
if(!event) return -1;
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const name = (event instanceof MessageEvent ? event.constructor : event) as Function;
|
const name = (event instanceof MessageEvent ? event.constructor : event) as Function;
|
||||||
|
|
||||||
const existing = this._messageIdByEvent.get(name);
|
const existing = this._messageIdByEvent.get(name);
|
||||||
|
|
||||||
if (!existing) return -1;
|
if(!existing) return -1;
|
||||||
|
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getComposerId(composer: IMessageComposer<unknown[]>): number
|
public getComposerId(composer: IMessageComposer<unknown[]>): number
|
||||||
{
|
{
|
||||||
if (!composer) return -1;
|
if(!composer) return -1;
|
||||||
|
|
||||||
const existing = this._messageIdByComposer.get(composer.constructor);
|
const existing = this._messageIdByComposer.get(composer.constructor);
|
||||||
|
|
||||||
if (!existing) return -1;
|
if(!existing) return -1;
|
||||||
|
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
|||||||
|
|
||||||
private loadNextConfiguration(): void
|
private loadNextConfiguration(): void
|
||||||
{
|
{
|
||||||
if (!this._pendingUrls.length)
|
if(!this._pendingUrls.length)
|
||||||
{
|
{
|
||||||
this.dispatchConfigurationEvent(ConfigurationEvent.LOADED);
|
this.dispatchConfigurationEvent(ConfigurationEvent.LOADED);
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
|||||||
|
|
||||||
public loadConfigurationFromUrl(url: string): void
|
public loadConfigurationFromUrl(url: string): void
|
||||||
{
|
{
|
||||||
if (!url || (url === ''))
|
if(!url || (url === ''))
|
||||||
{
|
{
|
||||||
this.dispatchConfigurationEvent(ConfigurationEvent.FAILED);
|
this.dispatchConfigurationEvent(ConfigurationEvent.FAILED);
|
||||||
|
|
||||||
@ -59,13 +59,13 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
|||||||
|
|
||||||
private onConfigurationLoaded(data: { [index: string]: any }, url: string): void
|
private onConfigurationLoaded(data: { [index: string]: any }, url: string): void
|
||||||
{
|
{
|
||||||
if (!data) return;
|
if(!data) return;
|
||||||
|
|
||||||
if (this.parseConfiguration(data))
|
if(this.parseConfiguration(data))
|
||||||
{
|
{
|
||||||
const index = this._pendingUrls.indexOf(url);
|
const index = this._pendingUrls.indexOf(url);
|
||||||
|
|
||||||
if (index >= 0) this._pendingUrls.splice(index, 1);
|
if(index >= 0) this._pendingUrls.splice(index, 1);
|
||||||
|
|
||||||
this.loadNextConfiguration();
|
this.loadNextConfiguration();
|
||||||
|
|
||||||
@ -87,21 +87,21 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
|||||||
|
|
||||||
private parseConfiguration(data: { [index: string]: any }, overrides: boolean = false): boolean
|
private parseConfiguration(data: { [index: string]: any }, overrides: boolean = false): boolean
|
||||||
{
|
{
|
||||||
if (!data) return false;
|
if(!data) return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const regex = new RegExp(/\${(.*?)}/g);
|
const regex = new RegExp(/\${(.*?)}/g);
|
||||||
|
|
||||||
for (const key in data)
|
for(const key in data)
|
||||||
{
|
{
|
||||||
let value = data[key];
|
let value = data[key];
|
||||||
|
|
||||||
if (typeof value === 'string') value = this.interpolate((value as string), regex);
|
if(typeof value === 'string') value = this.interpolate((value as string), regex);
|
||||||
|
|
||||||
if (this._definitions.has(key))
|
if(this._definitions.has(key))
|
||||||
{
|
{
|
||||||
if (overrides) this.setValue(key, value);
|
if(overrides) this.setValue(key, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -122,17 +122,17 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
|||||||
|
|
||||||
public interpolate(value: string, regex: RegExp = null): string
|
public interpolate(value: string, regex: RegExp = null): string
|
||||||
{
|
{
|
||||||
if (!regex) regex = new RegExp(/\${(.*?)}/g);
|
if(!regex) regex = new RegExp(/\${(.*?)}/g);
|
||||||
|
|
||||||
const pieces = value.match(regex);
|
const pieces = value.match(regex);
|
||||||
|
|
||||||
if (pieces && pieces.length)
|
if(pieces && pieces.length)
|
||||||
{
|
{
|
||||||
for (const piece of pieces)
|
for(const piece of pieces)
|
||||||
{
|
{
|
||||||
const existing = (this._definitions.get(this.removeInterpolateKey(piece)) as string);
|
const existing = (this._definitions.get(this.removeInterpolateKey(piece)) as string);
|
||||||
|
|
||||||
if (existing) (value = value.replace(piece, existing));
|
if(existing) (value = value.replace(piece, existing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,9 +148,9 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
|||||||
{
|
{
|
||||||
let existing = this._definitions.get(key);
|
let existing = this._definitions.get(key);
|
||||||
|
|
||||||
if (existing === undefined)
|
if(existing === undefined)
|
||||||
{
|
{
|
||||||
if (this._missingKeys.indexOf(key) >= 0) return value;
|
if(this._missingKeys.indexOf(key) >= 0) return value;
|
||||||
|
|
||||||
this._missingKeys.push(key);
|
this._missingKeys.push(key);
|
||||||
this.logger.warn(`Missing configuration key: ${key}`);
|
this.logger.warn(`Missing configuration key: ${key}`);
|
||||||
@ -167,13 +167,13 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
|||||||
|
|
||||||
let last = this._config;
|
let last = this._config;
|
||||||
|
|
||||||
for (let i = 0; i < parts.length; i++)
|
for(let i = 0; i < parts.length; i++)
|
||||||
{
|
{
|
||||||
const part = parts[i].toString();
|
const part = parts[i].toString();
|
||||||
|
|
||||||
if (i !== (parts.length - 1))
|
if(i !== (parts.length - 1))
|
||||||
{
|
{
|
||||||
if (!last[part]) last[part] = {};
|
if(!last[part]) last[part] = {};
|
||||||
|
|
||||||
last = last[part];
|
last = last[part];
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
this._array = [];
|
this._array = [];
|
||||||
this._keys = [];
|
this._keys = [];
|
||||||
|
|
||||||
if (map) for (const [key, value] of map.entries()) this.add(key, value);
|
if(map) for(const [key, value] of map.entries()) this.add(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get length(): number
|
public get length(): number
|
||||||
@ -29,9 +29,9 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if (!this._dictionary)
|
if(!this._dictionary)
|
||||||
{
|
{
|
||||||
for (const key of this._dictionary.keys()) this._dictionary.delete(key);
|
for(const key of this._dictionary.keys()) this._dictionary.delete(key);
|
||||||
|
|
||||||
this._dictionary = null;
|
this._dictionary = null;
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
|
|
||||||
public reset(): void
|
public reset(): void
|
||||||
{
|
{
|
||||||
for (const key of this._dictionary.keys()) this._dictionary.delete(key);
|
for(const key of this._dictionary.keys()) this._dictionary.delete(key);
|
||||||
|
|
||||||
this._length = 0;
|
this._length = 0;
|
||||||
this._array = [];
|
this._array = [];
|
||||||
@ -52,7 +52,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
|
|
||||||
public unshift(key: T, value: U): boolean
|
public unshift(key: T, value: U): boolean
|
||||||
{
|
{
|
||||||
if (this._dictionary.get(key) !== null) return false;
|
if(this._dictionary.get(key) !== null) return false;
|
||||||
|
|
||||||
this._dictionary.set(key, value);
|
this._dictionary.set(key, value);
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
|
|
||||||
public add(key: T, value: U): boolean
|
public add(key: T, value: U): boolean
|
||||||
{
|
{
|
||||||
if (this._dictionary.get(key) !== undefined) return false;
|
if(this._dictionary.get(key) !== undefined) return false;
|
||||||
|
|
||||||
this._dictionary.set(key, value);
|
this._dictionary.set(key, value);
|
||||||
|
|
||||||
@ -82,11 +82,11 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
{
|
{
|
||||||
const value = this._dictionary.get(key);
|
const value = this._dictionary.get(key);
|
||||||
|
|
||||||
if (!value) return null;
|
if(!value) return null;
|
||||||
|
|
||||||
const index = this._array.indexOf(value);
|
const index = this._array.indexOf(value);
|
||||||
|
|
||||||
if (index >= 0)
|
if(index >= 0)
|
||||||
{
|
{
|
||||||
this._array.splice(index, 1);
|
this._array.splice(index, 1);
|
||||||
this._keys.splice(index, 1);
|
this._keys.splice(index, 1);
|
||||||
@ -101,14 +101,14 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
|
|
||||||
public getWithIndex(index: number): U
|
public getWithIndex(index: number): U
|
||||||
{
|
{
|
||||||
if ((index < 0) || (index >= this._length)) return null;
|
if((index < 0) || (index >= this._length)) return null;
|
||||||
|
|
||||||
return this._array[index];
|
return this._array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getKey(index: number): T
|
public getKey(index: number): T
|
||||||
{
|
{
|
||||||
if ((index < 0) || (index >= this._length)) return null;
|
if((index < 0) || (index >= this._length)) return null;
|
||||||
|
|
||||||
return this._keys[index];
|
return this._keys[index];
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ export class AdvancedMap<T, U> implements IAdvancedMap<T, U>
|
|||||||
|
|
||||||
public concatenate(newValues: AdvancedMap<T, U>): void
|
public concatenate(newValues: AdvancedMap<T, U>): void
|
||||||
{
|
{
|
||||||
for (const k of newValues._keys) this.add(k, newValues.getValue(k));
|
for(const k of newValues._keys) this.add(k, newValues.getValue(k));
|
||||||
}
|
}
|
||||||
|
|
||||||
public clone(): IAdvancedMap<T, U>
|
public clone(): IAdvancedMap<T, U>
|
||||||
|
@ -61,7 +61,7 @@ export class BinaryWriter implements IBinaryWriter
|
|||||||
{
|
{
|
||||||
const array = new TextEncoder().encode(string);
|
const array = new TextEncoder().encode(string);
|
||||||
|
|
||||||
if (includeLength)
|
if(includeLength)
|
||||||
{
|
{
|
||||||
this.writeShort(array.length);
|
this.writeShort(array.length);
|
||||||
this.appendArray(array);
|
this.appendArray(array);
|
||||||
@ -76,7 +76,7 @@ export class BinaryWriter implements IBinaryWriter
|
|||||||
|
|
||||||
private appendArray(array: Uint8Array): void
|
private appendArray(array: Uint8Array): void
|
||||||
{
|
{
|
||||||
if (!array) return;
|
if(!array) return;
|
||||||
|
|
||||||
const mergedArray = new Uint8Array(((this.position + array.length) > this._buffer.length) ? (this.position + array.length) : this._buffer.length);
|
const mergedArray = new Uint8Array(((this.position + array.length) > this._buffer.length) ? (this.position + array.length) : this._buffer.length);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { NitroVersion } from '../NitroVersion';
|
|||||||
|
|
||||||
export const SayHello = () =>
|
export const SayHello = () =>
|
||||||
{
|
{
|
||||||
if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
|
if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
|
||||||
{
|
{
|
||||||
const args = [
|
const args = [
|
||||||
`\n %c %c %c Nitro ${NitroVersion.UI_VERSION} - Renderer ${NitroVersion.RENDERER_VERSION} %c %c %c https://discord.nitrodev.co %c %c \n\n`,
|
`\n %c %c %c Nitro ${NitroVersion.UI_VERSION} - Renderer ${NitroVersion.RENDERER_VERSION} %c %c %c https://discord.nitrodev.co %c %c \n\n`,
|
||||||
@ -19,7 +19,7 @@ export const SayHello = () =>
|
|||||||
self.console.log(...args);
|
self.console.log(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (self.console)
|
else if(self.console)
|
||||||
{
|
{
|
||||||
self.console.log(`Nitro ${NitroVersion.UI_VERSION} - Renderer ${NitroVersion.RENDERER_VERSION} `);
|
self.console.log(`Nitro ${NitroVersion.UI_VERSION} - Renderer ${NitroVersion.RENDERER_VERSION} `);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export class Nitro implements INitro
|
|||||||
|
|
||||||
constructor(core: INitroCore, options?: IApplicationOptions)
|
constructor(core: INitroCore, options?: IApplicationOptions)
|
||||||
{
|
{
|
||||||
if (!Nitro.INSTANCE) Nitro.INSTANCE = this;
|
if(!Nitro.INSTANCE) Nitro.INSTANCE = this;
|
||||||
|
|
||||||
this._worker = null;
|
this._worker = null;
|
||||||
this._application = new PixiApplicationProxy(options);
|
this._application = new PixiApplicationProxy(options);
|
||||||
@ -81,12 +81,12 @@ export class Nitro implements INitro
|
|||||||
this._core.configuration.events.addEventListener(ConfigurationEvent.LOADED, this.onConfigurationLoadedEvent.bind(this));
|
this._core.configuration.events.addEventListener(ConfigurationEvent.LOADED, this.onConfigurationLoadedEvent.bind(this));
|
||||||
this._roomEngine.events.addEventListener(RoomEngineEvent.ENGINE_INITIALIZED, this.onRoomEngineReady.bind(this));
|
this._roomEngine.events.addEventListener(RoomEngineEvent.ENGINE_INITIALIZED, this.onRoomEngineReady.bind(this));
|
||||||
|
|
||||||
if (this._worker) this._worker.onmessage = this.createWorkerEvent.bind(this);
|
if(this._worker) this._worker.onmessage = this.createWorkerEvent.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bootstrap(): void
|
public static bootstrap(): void
|
||||||
{
|
{
|
||||||
if (Nitro.INSTANCE)
|
if(Nitro.INSTANCE)
|
||||||
{
|
{
|
||||||
Nitro.INSTANCE.dispose();
|
Nitro.INSTANCE.dispose();
|
||||||
|
|
||||||
@ -108,25 +108,25 @@ export class Nitro implements INitro
|
|||||||
|
|
||||||
public init(): void
|
public init(): void
|
||||||
{
|
{
|
||||||
if (this._isReady || this._isDisposed) return;
|
if(this._isReady || this._isDisposed) return;
|
||||||
|
|
||||||
if (this._avatar) this._avatar.init();
|
if(this._avatar) this._avatar.init();
|
||||||
|
|
||||||
if (this._soundManager) this._soundManager.init();
|
if(this._soundManager) this._soundManager.init();
|
||||||
|
|
||||||
if (this._roomEngine)
|
if(this._roomEngine)
|
||||||
{
|
{
|
||||||
this._roomEngine.sessionDataManager = this._sessionDataManager;
|
this._roomEngine.sessionDataManager = this._sessionDataManager;
|
||||||
this._roomEngine.roomSessionManager = this._roomSessionManager;
|
this._roomEngine.roomSessionManager = this._roomSessionManager;
|
||||||
this._roomEngine.roomManager = this._roomManager;
|
this._roomEngine.roomManager = this._roomManager;
|
||||||
|
|
||||||
if (this._sessionDataManager) this._sessionDataManager.init();
|
if(this._sessionDataManager) this._sessionDataManager.init();
|
||||||
if (this._roomSessionManager) this._roomSessionManager.init();
|
if(this._roomSessionManager) this._roomSessionManager.init();
|
||||||
|
|
||||||
this._roomEngine.init();
|
this._roomEngine.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._communication.connection)
|
if(!this._communication.connection)
|
||||||
{
|
{
|
||||||
throw new Error('No connection found');
|
throw new Error('No connection found');
|
||||||
}
|
}
|
||||||
@ -138,58 +138,58 @@ export class Nitro implements INitro
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if (this._isDisposed) return;
|
if(this._isDisposed) return;
|
||||||
|
|
||||||
if (this._roomManager)
|
if(this._roomManager)
|
||||||
{
|
{
|
||||||
this._roomManager.dispose();
|
this._roomManager.dispose();
|
||||||
|
|
||||||
this._roomManager = null;
|
this._roomManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._roomSessionManager)
|
if(this._roomSessionManager)
|
||||||
{
|
{
|
||||||
this._roomSessionManager.dispose();
|
this._roomSessionManager.dispose();
|
||||||
|
|
||||||
this._roomSessionManager = null;
|
this._roomSessionManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._sessionDataManager)
|
if(this._sessionDataManager)
|
||||||
{
|
{
|
||||||
this._sessionDataManager.dispose();
|
this._sessionDataManager.dispose();
|
||||||
|
|
||||||
this._sessionDataManager = null;
|
this._sessionDataManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._roomEngine)
|
if(this._roomEngine)
|
||||||
{
|
{
|
||||||
this._roomEngine.dispose();
|
this._roomEngine.dispose();
|
||||||
|
|
||||||
this._roomEngine = null;
|
this._roomEngine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._avatar)
|
if(this._avatar)
|
||||||
{
|
{
|
||||||
this._avatar.dispose();
|
this._avatar.dispose();
|
||||||
|
|
||||||
this._avatar = null;
|
this._avatar = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._soundManager)
|
if(this._soundManager)
|
||||||
{
|
{
|
||||||
this._soundManager.dispose();
|
this._soundManager.dispose();
|
||||||
|
|
||||||
this._soundManager = null;
|
this._soundManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._communication)
|
if(this._communication)
|
||||||
{
|
{
|
||||||
this._communication.dispose();
|
this._communication.dispose();
|
||||||
|
|
||||||
this._communication = null;
|
this._communication = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._application)
|
if(this._application)
|
||||||
{
|
{
|
||||||
this._application.destroy();
|
this._application.destroy();
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ export class Nitro implements INitro
|
|||||||
const animationFPS = this.getConfiguration<number>('system.animation.fps', 24);
|
const animationFPS = this.getConfiguration<number>('system.animation.fps', 24);
|
||||||
const limitsFPS = this.getConfiguration<boolean>('system.limits.fps', true);
|
const limitsFPS = this.getConfiguration<boolean>('system.limits.fps', true);
|
||||||
|
|
||||||
if (limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS;
|
if(limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRoomEngineReady(event: RoomEngineEvent): void
|
private onRoomEngineReady(event: RoomEngineEvent): void
|
||||||
@ -235,7 +235,7 @@ export class Nitro implements INitro
|
|||||||
|
|
||||||
public addWorkerEventTracker(tracker: IWorkerEventTracker): void
|
public addWorkerEventTracker(tracker: IWorkerEventTracker): void
|
||||||
{
|
{
|
||||||
if (this._workerTrackers.indexOf(tracker) >= 0) return;
|
if(this._workerTrackers.indexOf(tracker) >= 0) return;
|
||||||
|
|
||||||
this._workerTrackers.push(tracker);
|
this._workerTrackers.push(tracker);
|
||||||
}
|
}
|
||||||
@ -244,20 +244,20 @@ export class Nitro implements INitro
|
|||||||
{
|
{
|
||||||
const index = this._workerTrackers.indexOf(tracker);
|
const index = this._workerTrackers.indexOf(tracker);
|
||||||
|
|
||||||
if (index === -1) return;
|
if(index === -1) return;
|
||||||
|
|
||||||
this._workerTrackers.splice(index, 1);
|
this._workerTrackers.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createWorkerEvent(message: MessageEvent): void
|
public createWorkerEvent(message: MessageEvent): void
|
||||||
{
|
{
|
||||||
if (!message) return;
|
if(!message) return;
|
||||||
|
|
||||||
const data: { [index: string]: any } = message.data;
|
const data: { [index: string]: any } = message.data;
|
||||||
|
|
||||||
for (const tracker of this._workerTrackers)
|
for(const tracker of this._workerTrackers)
|
||||||
{
|
{
|
||||||
if (!tracker) continue;
|
if(!tracker) continue;
|
||||||
|
|
||||||
tracker.workerMessageReceived(data);
|
tracker.workerMessageReceived(data);
|
||||||
}
|
}
|
||||||
@ -265,14 +265,14 @@ export class Nitro implements INitro
|
|||||||
|
|
||||||
public sendWorkerEvent(message: { [index: string]: any }): void
|
public sendWorkerEvent(message: { [index: string]: any }): void
|
||||||
{
|
{
|
||||||
if (!message || !this._worker) return;
|
if(!message || !this._worker) return;
|
||||||
|
|
||||||
this._worker.postMessage(message);
|
this._worker.postMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public addLinkEventTracker(tracker: ILinkEventTracker): void
|
public addLinkEventTracker(tracker: ILinkEventTracker): void
|
||||||
{
|
{
|
||||||
if (this._linkTrackers.indexOf(tracker) >= 0) return;
|
if(this._linkTrackers.indexOf(tracker) >= 0) return;
|
||||||
|
|
||||||
this._linkTrackers.push(tracker);
|
this._linkTrackers.push(tracker);
|
||||||
}
|
}
|
||||||
@ -281,24 +281,24 @@ export class Nitro implements INitro
|
|||||||
{
|
{
|
||||||
const index = this._linkTrackers.indexOf(tracker);
|
const index = this._linkTrackers.indexOf(tracker);
|
||||||
|
|
||||||
if (index === -1) return;
|
if(index === -1) return;
|
||||||
|
|
||||||
this._linkTrackers.splice(index, 1);
|
this._linkTrackers.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createLinkEvent(link: string): void
|
public createLinkEvent(link: string): void
|
||||||
{
|
{
|
||||||
if (!link || (link === '')) return;
|
if(!link || (link === '')) return;
|
||||||
|
|
||||||
for (const tracker of this._linkTrackers)
|
for(const tracker of this._linkTrackers)
|
||||||
{
|
{
|
||||||
if (!tracker) continue;
|
if(!tracker) continue;
|
||||||
|
|
||||||
const prefix = tracker.eventUrlPrefix;
|
const prefix = tracker.eventUrlPrefix;
|
||||||
|
|
||||||
if (prefix.length > 0)
|
if(prefix.length > 0)
|
||||||
{
|
{
|
||||||
if (link.substr(0, prefix.length) === prefix) tracker.linkReceived(link);
|
if(link.substr(0, prefix.length) === prefix) tracker.linkReceived(link);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -64,7 +64,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);
|
||||||
|
|
||||||
@ -92,16 +92,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);
|
||||||
|
|
||||||
@ -109,7 +109,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);
|
||||||
@ -117,7 +117,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);
|
||||||
|
|
||||||
@ -128,9 +128,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);
|
||||||
}
|
}
|
||||||
@ -140,34 +140,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);
|
||||||
}
|
}
|
||||||
@ -179,22 +179,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++;
|
||||||
@ -205,19 +205,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;
|
||||||
}
|
}
|
||||||
@ -231,38 +231,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);
|
||||||
}
|
}
|
||||||
@ -274,7 +274,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]);
|
||||||
|
|
||||||
@ -284,13 +284,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 = [];
|
||||||
|
|
||||||
@ -302,24 +302,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);
|
||||||
|
|
||||||
@ -328,7 +328,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];
|
||||||
|
|
||||||
|
@ -90,11 +90,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-');
|
||||||
}
|
}
|
||||||
@ -118,7 +118,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;
|
||||||
@ -127,22 +127,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;
|
||||||
}
|
}
|
||||||
@ -176,24 +176,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;
|
||||||
}
|
}
|
||||||
@ -239,34 +239,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);
|
||||||
}
|
}
|
||||||
@ -278,7 +278,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;
|
||||||
@ -291,18 +291,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);
|
||||||
@ -312,19 +312,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);
|
||||||
|
|
||||||
@ -344,16 +344,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
|
||||||
@ -366,7 +366,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;
|
||||||
@ -378,7 +378,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);
|
||||||
|
|
||||||
@ -390,13 +390,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);
|
||||||
|
|
||||||
@ -404,12 +404,12 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cache)
|
if(!cache)
|
||||||
{
|
{
|
||||||
return TextureUtils.generateTexture(container, new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height));
|
return TextureUtils.generateTexture(container, new Rectangle(0, 0, avatarCanvas.width, avatarCanvas.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._reusableTexture)
|
if(this._reusableTexture)
|
||||||
{
|
{
|
||||||
PixiApplicationProxy.instance.renderer.render(container, {
|
PixiApplicationProxy.instance.renderer.render(container, {
|
||||||
renderTexture: this._reusableTexture,
|
renderTexture: this._reusableTexture,
|
||||||
@ -421,7 +421,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)
|
||||||
@ -446,31 +446,31 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
const textureImageData = textureCtx.getImageData(0, 0, textureCanvas.width, textureCanvas.height);
|
const textureImageData = textureCtx.getImageData(0, 0, textureCanvas.width, textureCanvas.height);
|
||||||
const data = textureImageData.data;
|
const data = textureImageData.data;
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i += 4)
|
for(let i = 0; i < data.length; i += 4)
|
||||||
{
|
{
|
||||||
if (reds.length == 256)
|
if(reds.length == 256)
|
||||||
{
|
{
|
||||||
let paletteColor = reds[data[i]];
|
let paletteColor = reds[data[i]];
|
||||||
if (paletteColor === undefined) paletteColor = 0;
|
if(paletteColor === undefined) paletteColor = 0;
|
||||||
|
|
||||||
data[i] = ((paletteColor >> 16) & 0xFF);
|
data[i] = ((paletteColor >> 16) & 0xFF);
|
||||||
data[i + 1] = ((paletteColor >> 8) & 0xFF);
|
data[i + 1] = ((paletteColor >> 8) & 0xFF);
|
||||||
data[i + 2] = (paletteColor & 0xFF);
|
data[i + 2] = (paletteColor & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (greens.length == 256)
|
if(greens.length == 256)
|
||||||
{
|
{
|
||||||
let paletteColor = greens[data[i + 1]];
|
let paletteColor = greens[data[i + 1]];
|
||||||
if (paletteColor === undefined) paletteColor = 0;
|
if(paletteColor === undefined) paletteColor = 0;
|
||||||
|
|
||||||
data[i] = ((paletteColor >> 16) & 0xFF);
|
data[i] = ((paletteColor >> 16) & 0xFF);
|
||||||
data[i + 1] = ((paletteColor >> 8) & 0xFF);
|
data[i + 1] = ((paletteColor >> 8) & 0xFF);
|
||||||
data[i + 2] = (paletteColor & 0xFF);
|
data[i + 2] = (paletteColor & 0xFF);
|
||||||
}
|
}
|
||||||
if (blues.length == 256)
|
if(blues.length == 256)
|
||||||
{
|
{
|
||||||
let paletteColor = greens[data[i + 2]];
|
let paletteColor = greens[data[i + 2]];
|
||||||
if (paletteColor === undefined) paletteColor = 0;
|
if(paletteColor === undefined) paletteColor = 0;
|
||||||
|
|
||||||
data[i] = ((paletteColor >> 16) & 0xFF);
|
data[i] = ((paletteColor >> 16) & 0xFF);
|
||||||
data[i + 1] = ((paletteColor >> 8) & 0xFF);
|
data[i + 1] = ((paletteColor >> 8) & 0xFF);
|
||||||
@ -492,13 +492,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();
|
||||||
@ -511,16 +511,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
|
||||||
@ -531,7 +531,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;
|
||||||
@ -557,29 +557,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
|
||||||
@ -590,7 +590,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;
|
||||||
@ -602,7 +602,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);
|
||||||
|
|
||||||
@ -618,7 +618,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;
|
||||||
}
|
}
|
||||||
@ -627,9 +627,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);
|
||||||
|
|
||||||
@ -646,18 +646,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,13 +690,13 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
{
|
{
|
||||||
let k: ActiveActionData;
|
let k: ActiveActionData;
|
||||||
|
|
||||||
if (!this.sortActions()) return;
|
if(!this.sortActions()) return;
|
||||||
|
|
||||||
for (const k of this._sortedActions)
|
for(const k of this._sortedActions)
|
||||||
{
|
{
|
||||||
if (k.actionType === AvatarAction.EFFECT)
|
if(k.actionType === AvatarAction.EFFECT)
|
||||||
{
|
{
|
||||||
if (!this._effectManager.isAvatarEffectReady(parseInt(k.actionParameter))) this._effectManager.downloadAvatarEffect(parseInt(k.actionParameter), this);
|
if(!this._effectManager.isAvatarEffectReady(parseInt(k.actionParameter))) this._effectManager.downloadAvatarEffect(parseInt(k.actionParameter), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,14 +710,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:
|
||||||
@ -730,11 +730,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);
|
||||||
}
|
}
|
||||||
@ -753,7 +753,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:
|
||||||
@ -777,9 +777,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;
|
||||||
}
|
}
|
||||||
@ -790,7 +790,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;
|
||||||
}
|
}
|
||||||
@ -802,13 +802,13 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
|
|||||||
protected addActionData(k: string, _arg_2: string = ''): void
|
protected addActionData(k: string, _arg_2: string = ''): void
|
||||||
{
|
{
|
||||||
let _local_3: ActiveActionData;
|
let _local_3: ActiveActionData;
|
||||||
if (!this._actions) this._actions = [];
|
if(!this._actions) this._actions = [];
|
||||||
|
|
||||||
let _local_4 = 0;
|
let _local_4 = 0;
|
||||||
while (_local_4 < this._actions.length)
|
while(_local_4 < this._actions.length)
|
||||||
{
|
{
|
||||||
_local_3 = this._actions[_local_4];
|
_local_3 = this._actions[_local_4];
|
||||||
if (((_local_3.actionType == k) && (_local_3.actionParameter == _arg_2)))
|
if(((_local_3.actionType == k) && (_local_3.actionParameter == _arg_2)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -841,14 +841,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;
|
||||||
}
|
}
|
||||||
@ -868,11 +868,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;
|
||||||
|
|
||||||
@ -883,15 +883,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;
|
||||||
|
|
||||||
@ -899,16 +899,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;
|
||||||
|
|
||||||
@ -923,60 +923,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -985,15 +985,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);
|
||||||
@ -1004,11 +1004,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);
|
||||||
@ -1030,7 +1030,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;
|
||||||
@ -1098,7 +1098,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();
|
||||||
@ -1106,7 +1106,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,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);
|
||||||
|
|
||||||
@ -92,7 +92,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);
|
||||||
|
|
||||||
@ -105,14 +105,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);
|
||||||
|
|
||||||
@ -122,7 +122,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);
|
||||||
|
|
||||||
@ -133,7 +133,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);
|
||||||
|
|
||||||
@ -146,7 +146,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();
|
||||||
|
|
||||||
@ -158,7 +158,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));
|
||||||
|
|
||||||
@ -181,7 +181,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);
|
||||||
|
|
||||||
@ -194,14 +194,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));
|
||||||
|
|
||||||
@ -219,7 +219,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;
|
||||||
|
|
||||||
@ -228,14 +228,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;
|
||||||
|
|
||||||
@ -244,20 +244,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
|
||||||
@ -267,25 +267,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);
|
||||||
|
|
||||||
@ -294,7 +294,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);
|
||||||
}
|
}
|
||||||
@ -305,17 +305,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]);
|
||||||
|
|
||||||
@ -326,15 +326,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]);
|
||||||
|
|
||||||
@ -351,49 +351,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;
|
||||||
@ -415,7 +415,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));
|
||||||
}
|
}
|
||||||
@ -428,11 +428,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;
|
||||||
@ -440,7 +440,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);
|
||||||
}
|
}
|
||||||
@ -467,7 +467,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;
|
||||||
}
|
}
|
||||||
|
@ -60,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();
|
||||||
|
|
||||||
@ -73,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();
|
||||||
@ -95,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;
|
||||||
@ -110,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);
|
||||||
}
|
}
|
||||||
@ -131,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;
|
||||||
|
|
||||||
@ -155,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]);
|
||||||
}
|
}
|
||||||
@ -202,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));
|
||||||
}
|
}
|
||||||
@ -211,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];
|
||||||
}
|
}
|
||||||
@ -253,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: '',
|
||||||
@ -280,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);
|
||||||
@ -294,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ export class AvatarStructure extends EventDispatcher
|
|||||||
{
|
{
|
||||||
const _local_5 = this._animationData.getAction(k.definition);
|
const _local_5 = this._animationData.getAction(k.definition);
|
||||||
|
|
||||||
if (_local_5) return _local_5.getFrameBodyPartOffset(_arg_2, _arg_3, _arg_4);
|
if(_local_5) return _local_5.getFrameBodyPartOffset(_arg_2, _arg_3, _arg_4);
|
||||||
|
|
||||||
return AnimationAction.DEFAULT_OFFSET;
|
return AnimationAction.DEFAULT_OFFSET;
|
||||||
}
|
}
|
||||||
@ -353,31 +353,31 @@ export class AvatarStructure extends EventDispatcher
|
|||||||
let _local_20: AvatarAnimationFrame[] = [];
|
let _local_20: AvatarAnimationFrame[] = [];
|
||||||
let _local_36: IPartColor = null;
|
let _local_36: IPartColor = null;
|
||||||
|
|
||||||
if (!_arg_3 == null) return [];
|
if(!_arg_3 == null) return [];
|
||||||
|
|
||||||
const _local_9 = this._partSetsData.getActiveParts(_arg_3.definition);
|
const _local_9 = this._partSetsData.getActiveParts(_arg_3.definition);
|
||||||
const _local_11: AvatarImagePartContainer[] = [];
|
const _local_11: AvatarImagePartContainer[] = [];
|
||||||
let _local_14: any[] = [0];
|
let _local_14: any[] = [0];
|
||||||
const _local_15 = this._animationData.getAction(_arg_3.definition);
|
const _local_15 = this._animationData.getAction(_arg_3.definition);
|
||||||
|
|
||||||
if (_arg_3.definition.isAnimation)
|
if(_arg_3.definition.isAnimation)
|
||||||
{
|
{
|
||||||
const _local_24 = ((_arg_3.definition.state + '.') + _arg_3.actionParameter);
|
const _local_24 = ((_arg_3.definition.state + '.') + _arg_3.actionParameter);
|
||||||
const _local_10 = this._animationManager.getAnimation(_local_24);
|
const _local_10 = this._animationManager.getAnimation(_local_24);
|
||||||
|
|
||||||
if (_local_10)
|
if(_local_10)
|
||||||
{
|
{
|
||||||
_local_14 = this.getPopulatedArray(_local_10.frameCount(_arg_3.overridingAction));
|
_local_14 = this.getPopulatedArray(_local_10.frameCount(_arg_3.overridingAction));
|
||||||
|
|
||||||
for (const _local_25 of _local_10.getAnimatedBodyPartIds(0, _arg_3.overridingAction))
|
for(const _local_25 of _local_10.getAnimatedBodyPartIds(0, _arg_3.overridingAction))
|
||||||
{
|
{
|
||||||
if (_local_25 === k)
|
if(_local_25 === k)
|
||||||
{
|
{
|
||||||
const _local_26 = this._geometry.getBodyPart(_arg_4, _local_25);
|
const _local_26 = this._geometry.getBodyPart(_arg_4, _local_25);
|
||||||
|
|
||||||
if (_local_26)
|
if(_local_26)
|
||||||
{
|
{
|
||||||
for (const _local_27 of _local_26.getDynamicParts(_arg_7))
|
for(const _local_27 of _local_26.getDynamicParts(_arg_7))
|
||||||
{
|
{
|
||||||
_local_9.push(_local_27.id);
|
_local_9.push(_local_27.id);
|
||||||
}
|
}
|
||||||
@ -390,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);
|
||||||
@ -403,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;
|
||||||
}
|
}
|
||||||
@ -439,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)]);
|
||||||
}
|
}
|
||||||
@ -465,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;
|
||||||
}
|
}
|
||||||
@ -484,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;
|
||||||
}
|
}
|
||||||
@ -528,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)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
@ -543,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;
|
||||||
}
|
}
|
||||||
@ -605,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);
|
||||||
|
|
||||||
@ -617,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;
|
||||||
}
|
}
|
||||||
|
@ -33,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;
|
||||||
|
|
||||||
@ -55,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));
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,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);
|
||||||
|
|
||||||
@ -91,17 +91,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);
|
||||||
|
|
||||||
@ -111,7 +111,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);
|
||||||
|
|
||||||
@ -121,7 +121,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]);
|
||||||
|
|
||||||
@ -130,13 +130,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);
|
||||||
|
|
||||||
@ -145,24 +145,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);
|
||||||
}
|
}
|
||||||
@ -172,34 +172,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));
|
||||||
}
|
}
|
||||||
@ -210,17 +210,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++;
|
||||||
@ -231,19 +231,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;
|
||||||
}
|
}
|
||||||
@ -257,17 +257,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,9 +276,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);
|
||||||
|
|
||||||
@ -287,7 +287,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];
|
||||||
|
|
||||||
|
@ -19,36 +19,36 @@ export class AvatarActionManager
|
|||||||
|
|
||||||
public updateActions(data: any): void
|
public updateActions(data: any): void
|
||||||
{
|
{
|
||||||
if (!data) return;
|
if(!data) return;
|
||||||
|
|
||||||
for (const action of data.actions)
|
for(const action of data.actions)
|
||||||
{
|
{
|
||||||
if (!action || !action.state) continue;
|
if(!action || !action.state) continue;
|
||||||
|
|
||||||
const definition = new ActionDefinition(action);
|
const definition = new ActionDefinition(action);
|
||||||
|
|
||||||
this._actions.set(definition.state, definition);
|
this._actions.set(definition.state, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.actionOffsets) this.parseActionOffsets(data.actionOffsets);
|
if(data.actionOffsets) this.parseActionOffsets(data.actionOffsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseActionOffsets(offsets: any): void
|
private parseActionOffsets(offsets: any): void
|
||||||
{
|
{
|
||||||
if (!offsets || !offsets.length) return;
|
if(!offsets || !offsets.length) return;
|
||||||
|
|
||||||
for (const offset of offsets)
|
for(const offset of offsets)
|
||||||
{
|
{
|
||||||
const action = this._actions.get(offset.action);
|
const action = this._actions.get(offset.action);
|
||||||
|
|
||||||
if (!action) continue;
|
if(!action) continue;
|
||||||
|
|
||||||
for (const canvasOffset of offset.offsets)
|
for(const canvasOffset of offset.offsets)
|
||||||
{
|
{
|
||||||
const size = (canvasOffset.size || '');
|
const size = (canvasOffset.size || '');
|
||||||
const direction = canvasOffset.direction;
|
const direction = canvasOffset.direction;
|
||||||
|
|
||||||
if ((size === '') || (direction === undefined)) continue;
|
if((size === '') || (direction === undefined)) continue;
|
||||||
|
|
||||||
const x = (canvasOffset.x || 0);
|
const x = (canvasOffset.x || 0);
|
||||||
const y = (canvasOffset.y || 0);
|
const y = (canvasOffset.y || 0);
|
||||||
@ -61,11 +61,11 @@ export class AvatarActionManager
|
|||||||
|
|
||||||
public getActionDefinition(id: string): ActionDefinition
|
public getActionDefinition(id: string): ActionDefinition
|
||||||
{
|
{
|
||||||
if (!id) return null;
|
if(!id) return null;
|
||||||
|
|
||||||
for (const action of this._actions.values())
|
for(const action of this._actions.values())
|
||||||
{
|
{
|
||||||
if (!action || (action.id !== id)) continue;
|
if(!action || (action.id !== id)) continue;
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -30,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));
|
||||||
}
|
}
|
||||||
@ -53,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;
|
||||||
}
|
}
|
||||||
@ -63,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);
|
||||||
|
|
||||||
@ -76,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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)];
|
||||||
}
|
}
|
||||||
@ -199,20 +199,20 @@ export class Animation implements IAnimation
|
|||||||
{
|
{
|
||||||
const _local_3: string[] = [];
|
const _local_3: string[] = [];
|
||||||
|
|
||||||
for (const layer of this.getFrame(k, _arg_2))
|
for(const layer of this.getFrame(k, _arg_2))
|
||||||
{
|
{
|
||||||
if (layer.type === AvatarAnimationLayerData.BODYPART)
|
if(layer.type === AvatarAnimationLayerData.BODYPART)
|
||||||
{
|
{
|
||||||
_local_3.push(layer.id);
|
_local_3.push(layer.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (layer.type === AvatarAnimationLayerData.FX)
|
else if(layer.type === AvatarAnimationLayerData.FX)
|
||||||
{
|
{
|
||||||
if (this._addData && this._addData.length)
|
if(this._addData && this._addData.length)
|
||||||
{
|
{
|
||||||
for (const _local_5 of this._addData)
|
for(const _local_5 of this._addData)
|
||||||
{
|
{
|
||||||
if (_local_5.id === layer.id) _local_3.push(_local_5.align);
|
if(_local_5.id === layer.id) _local_3.push(_local_5.align);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
152
src/nitro/avatar/cache/AvatarImageCache.ts
vendored
152
src/nitro/avatar/cache/AvatarImageCache.ts
vendored
@ -51,7 +51,7 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if (this._disposed) return;
|
if(this._disposed) return;
|
||||||
|
|
||||||
this._structure = null;
|
this._structure = null;
|
||||||
this._avatar = null;
|
this._avatar = null;
|
||||||
@ -59,11 +59,11 @@ export class AvatarImageCache
|
|||||||
this._canvas = null;
|
this._canvas = null;
|
||||||
this._disposed = true;
|
this._disposed = true;
|
||||||
|
|
||||||
if (this._cache)
|
if(this._cache)
|
||||||
{
|
{
|
||||||
for (const cache of this._cache.values())
|
for(const cache of this._cache.values())
|
||||||
{
|
{
|
||||||
if (!cache) continue;
|
if(!cache) continue;
|
||||||
|
|
||||||
cache.dispose();
|
cache.dispose();
|
||||||
}
|
}
|
||||||
@ -71,11 +71,11 @@ export class AvatarImageCache
|
|||||||
this._cache = null;
|
this._cache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._unionImages)
|
if(this._unionImages)
|
||||||
{
|
{
|
||||||
for (const image of this._unionImages)
|
for(const image of this._unionImages)
|
||||||
{
|
{
|
||||||
if (!image) continue;
|
if(!image) continue;
|
||||||
|
|
||||||
image.dispose();
|
image.dispose();
|
||||||
}
|
}
|
||||||
@ -88,11 +88,11 @@ export class AvatarImageCache
|
|||||||
{
|
{
|
||||||
const time = PixiApplicationProxy.instance.ticker.lastTime;
|
const time = PixiApplicationProxy.instance.ticker.lastTime;
|
||||||
|
|
||||||
if (this._cache)
|
if(this._cache)
|
||||||
{
|
{
|
||||||
for (const cache of this._cache.values())
|
for(const cache of this._cache.values())
|
||||||
{
|
{
|
||||||
if (!cache) continue;
|
if(!cache) continue;
|
||||||
|
|
||||||
cache.disposeActions(k, time);
|
cache.disposeActions(k, time);
|
||||||
}
|
}
|
||||||
@ -101,11 +101,11 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
public resetBodyPartCache(k: IActiveActionData): void
|
public resetBodyPartCache(k: IActiveActionData): void
|
||||||
{
|
{
|
||||||
if (this._cache)
|
if(this._cache)
|
||||||
{
|
{
|
||||||
for (const cache of this._cache.values())
|
for(const cache of this._cache.values())
|
||||||
{
|
{
|
||||||
if (!cache) continue;
|
if(!cache) continue;
|
||||||
|
|
||||||
cache.setAction(k, 0);
|
cache.setAction(k, 0);
|
||||||
}
|
}
|
||||||
@ -116,13 +116,13 @@ export class AvatarImageCache
|
|||||||
{
|
{
|
||||||
const parts = this._structure.getBodyPartsUnordered(k);
|
const parts = this._structure.getBodyPartsUnordered(k);
|
||||||
|
|
||||||
if (parts)
|
if(parts)
|
||||||
{
|
{
|
||||||
for (const part of parts)
|
for(const part of parts)
|
||||||
{
|
{
|
||||||
const actionCache = this.getBodyPartCache(part);
|
const actionCache = this.getBodyPartCache(part);
|
||||||
|
|
||||||
if (!actionCache) continue;
|
if(!actionCache) continue;
|
||||||
|
|
||||||
actionCache.setDirection(_arg_2);
|
actionCache.setDirection(_arg_2);
|
||||||
}
|
}
|
||||||
@ -133,19 +133,19 @@ export class AvatarImageCache
|
|||||||
{
|
{
|
||||||
const _local_3 = this._structure.getActiveBodyPartIds(k, this._avatar);
|
const _local_3 = this._structure.getActiveBodyPartIds(k, this._avatar);
|
||||||
|
|
||||||
for (const _local_4 of _local_3)
|
for(const _local_4 of _local_3)
|
||||||
{
|
{
|
||||||
const _local_5 = this.getBodyPartCache(_local_4);
|
const _local_5 = this.getBodyPartCache(_local_4);
|
||||||
|
|
||||||
if (_local_5) _local_5.setAction(k, _arg_2);
|
if(_local_5) _local_5.setAction(k, _arg_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setGeometryType(k: string): void
|
public setGeometryType(k: string): void
|
||||||
{
|
{
|
||||||
if (this._geometryType === k) return;
|
if(this._geometryType === k) return;
|
||||||
|
|
||||||
if ((((this._geometryType === GeometryType.SITTING) && (k === GeometryType.VERTICAL)) || ((this._geometryType === GeometryType.VERTICAL) && (k === GeometryType.SITTING)) || ((this._geometryType === GeometryType.SNOWWARS_HORIZONTAL) && (k = GeometryType.SNOWWARS_HORIZONTAL))))
|
if((((this._geometryType === GeometryType.SITTING) && (k === GeometryType.VERTICAL)) || ((this._geometryType === GeometryType.VERTICAL) && (k === GeometryType.SITTING)) || ((this._geometryType === GeometryType.SNOWWARS_HORIZONTAL) && (k = GeometryType.SNOWWARS_HORIZONTAL))))
|
||||||
{
|
{
|
||||||
this._geometryType = k;
|
this._geometryType = k;
|
||||||
this._canvas = null;
|
this._canvas = null;
|
||||||
@ -163,7 +163,7 @@ export class AvatarImageCache
|
|||||||
{
|
{
|
||||||
let _local_4 = this.getBodyPartCache(k);
|
let _local_4 = this.getBodyPartCache(k);
|
||||||
|
|
||||||
if (!_local_4)
|
if(!_local_4)
|
||||||
{
|
{
|
||||||
_local_4 = new AvatarImageBodyPartCache();
|
_local_4 = new AvatarImageBodyPartCache();
|
||||||
|
|
||||||
@ -174,48 +174,48 @@ export class AvatarImageCache
|
|||||||
let _local_7 = _local_4.getAction();
|
let _local_7 = _local_4.getAction();
|
||||||
let frameCount = frameNumber;
|
let frameCount = frameNumber;
|
||||||
|
|
||||||
if (_local_7.definition.startFromFrameZero) frameCount -= _local_7.startFrame;
|
if(_local_7.definition.startFromFrameZero) frameCount -= _local_7.startFrame;
|
||||||
|
|
||||||
let _local_8 = _local_7;
|
let _local_8 = _local_7;
|
||||||
let _local_9: string[] = [];
|
let _local_9: string[] = [];
|
||||||
let _local_10: Map<string, string> = new Map();
|
let _local_10: Map<string, string> = new Map();
|
||||||
const _local_11 = new Point();
|
const _local_11 = new Point();
|
||||||
|
|
||||||
if (!((!(_local_7)) || (!(_local_7.definition))))
|
if(!((!(_local_7)) || (!(_local_7.definition))))
|
||||||
{
|
{
|
||||||
if (_local_7.definition.isAnimation)
|
if(_local_7.definition.isAnimation)
|
||||||
{
|
{
|
||||||
let _local_15 = _local_5;
|
let _local_15 = _local_5;
|
||||||
|
|
||||||
const _local_16 = this._structure.getAnimation(((_local_7.definition.state + '.') + _local_7.actionParameter));
|
const _local_16 = this._structure.getAnimation(((_local_7.definition.state + '.') + _local_7.actionParameter));
|
||||||
const _local_17 = (frameNumber - _local_7.startFrame);
|
const _local_17 = (frameNumber - _local_7.startFrame);
|
||||||
|
|
||||||
if (_local_16)
|
if(_local_16)
|
||||||
{
|
{
|
||||||
const _local_18 = _local_16.getLayerData(_local_17, k, _local_7.overridingAction);
|
const _local_18 = _local_16.getLayerData(_local_17, k, _local_7.overridingAction);
|
||||||
|
|
||||||
if (_local_18)
|
if(_local_18)
|
||||||
{
|
{
|
||||||
_local_15 = (_local_5 + _local_18.dd);
|
_local_15 = (_local_5 + _local_18.dd);
|
||||||
|
|
||||||
if (_local_18.dd < 0)
|
if(_local_18.dd < 0)
|
||||||
{
|
{
|
||||||
if (_local_15 < 0)
|
if(_local_15 < 0)
|
||||||
{
|
{
|
||||||
_local_15 = (8 + _local_15);
|
_local_15 = (8 + _local_15);
|
||||||
}
|
}
|
||||||
else if (_local_15 > 7) _local_15 = (8 - _local_15);
|
else if(_local_15 > 7) _local_15 = (8 - _local_15);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_local_15 < 0)
|
if(_local_15 < 0)
|
||||||
{
|
{
|
||||||
_local_15 = (_local_15 + 8);
|
_local_15 = (_local_15 + 8);
|
||||||
}
|
}
|
||||||
else if (_local_15 > 7) _local_15 = (_local_15 - 8);
|
else if(_local_15 > 7) _local_15 = (_local_15 - 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._scale === AvatarScaleType.LARGE)
|
if(this._scale === AvatarScaleType.LARGE)
|
||||||
{
|
{
|
||||||
_local_11.x = _local_18.dx;
|
_local_11.x = _local_18.dx;
|
||||||
_local_11.y = _local_18.dy;
|
_local_11.y = _local_18.dy;
|
||||||
@ -228,21 +228,21 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
frameCount = _local_18.animationFrame;
|
frameCount = _local_18.animationFrame;
|
||||||
|
|
||||||
if (_local_18.action)
|
if(_local_18.action)
|
||||||
{
|
{
|
||||||
_local_7 = _local_18.action;
|
_local_7 = _local_18.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_local_18.type === AvatarAnimationLayerData.BODYPART)
|
if(_local_18.type === AvatarAnimationLayerData.BODYPART)
|
||||||
{
|
{
|
||||||
if (_local_18.action != null)
|
if(_local_18.action != null)
|
||||||
{
|
{
|
||||||
_local_8 = _local_18.action;
|
_local_8 = _local_18.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
_local_5 = _local_15;
|
_local_5 = _local_15;
|
||||||
}
|
}
|
||||||
else if (_local_18.type === AvatarAnimationLayerData.FX) _local_5 = _local_15;
|
else if(_local_18.type === AvatarAnimationLayerData.FX) _local_5 = _local_15;
|
||||||
|
|
||||||
_local_10 = _local_18.items;
|
_local_10 = _local_18.items;
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
let _local_12 = _local_4.getActionCache(_local_8);
|
let _local_12 = _local_4.getActionCache(_local_8);
|
||||||
|
|
||||||
if (!_local_12 || _arg_3)
|
if(!_local_12 || _arg_3)
|
||||||
{
|
{
|
||||||
_local_12 = new AvatarImageActionCache();
|
_local_12 = new AvatarImageActionCache();
|
||||||
_local_4.updateActionCache(_local_8, _local_12);
|
_local_4.updateActionCache(_local_8, _local_12);
|
||||||
@ -262,7 +262,7 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
let _local_13 = _local_12.getDirectionCache(_local_5);
|
let _local_13 = _local_12.getDirectionCache(_local_5);
|
||||||
|
|
||||||
if (!_local_13 || _arg_3)
|
if(!_local_13 || _arg_3)
|
||||||
{
|
{
|
||||||
const _local_19 = this._structure.getParts(k, this._avatar.getFigure(), _local_8, this._geometryType, _local_5, _local_9, this._avatar, _local_10);
|
const _local_19 = this._structure.getParts(k, this._avatar.getFigure(), _local_8, this._geometryType, _local_5, _local_9, this._avatar, _local_10);
|
||||||
|
|
||||||
@ -273,15 +273,15 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
let _local_14 = _local_13.getImageContainer(frameCount);
|
let _local_14 = _local_13.getImageContainer(frameCount);
|
||||||
|
|
||||||
if (!_local_14 || _arg_3)
|
if(!_local_14 || _arg_3)
|
||||||
{
|
{
|
||||||
const _local_20 = _local_13.getPartList();
|
const _local_20 = _local_13.getPartList();
|
||||||
|
|
||||||
_local_14 = this.renderBodyPart(_local_5, _local_20, frameCount, _local_7, _arg_3);
|
_local_14 = this.renderBodyPart(_local_5, _local_20, frameCount, _local_7, _arg_3);
|
||||||
|
|
||||||
if (_local_14 && !_arg_3)
|
if(_local_14 && !_arg_3)
|
||||||
{
|
{
|
||||||
if (_local_14.isCacheable) _local_13.updateImageContainer(_local_14, frameCount);
|
if(_local_14.isCacheable) _local_13.updateImageContainer(_local_14, frameCount);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -310,7 +310,7 @@ export class AvatarImageCache
|
|||||||
{
|
{
|
||||||
let existing = this._cache.get(k);
|
let existing = this._cache.get(k);
|
||||||
|
|
||||||
if (!existing)
|
if(!existing)
|
||||||
{
|
{
|
||||||
existing = new AvatarImageBodyPartCache();
|
existing = new AvatarImageBodyPartCache();
|
||||||
|
|
||||||
@ -322,13 +322,13 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
private renderBodyPart(direction: number, containers: AvatarImagePartContainer[], frameCount: number, _arg_4: IActiveActionData, renderServerData: boolean = false): AvatarImageBodyPartContainer
|
private renderBodyPart(direction: number, containers: AvatarImagePartContainer[], frameCount: number, _arg_4: IActiveActionData, renderServerData: boolean = false): AvatarImageBodyPartContainer
|
||||||
{
|
{
|
||||||
if (!containers || !containers.length) return null;
|
if(!containers || !containers.length) return null;
|
||||||
|
|
||||||
if (!this._canvas)
|
if(!this._canvas)
|
||||||
{
|
{
|
||||||
this._canvas = this._structure.getCanvas(this._scale, this._geometryType);
|
this._canvas = this._structure.getCanvas(this._scale, this._geometryType);
|
||||||
|
|
||||||
if (!this._canvas) return null;
|
if(!this._canvas) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFlipped = AvatarDirectionAngle.DIRECTION_IS_FLIPPED[direction] || false;
|
const isFlipped = AvatarDirectionAngle.DIRECTION_IS_FLIPPED[direction] || false;
|
||||||
@ -336,15 +336,15 @@ export class AvatarImageCache
|
|||||||
let isCacheable = true;
|
let isCacheable = true;
|
||||||
let containerIndex = (containers.length - 1);
|
let containerIndex = (containers.length - 1);
|
||||||
|
|
||||||
while (containerIndex >= 0)
|
while(containerIndex >= 0)
|
||||||
{
|
{
|
||||||
const container = containers[containerIndex];
|
const container = containers[containerIndex];
|
||||||
|
|
||||||
let color = 16777215;
|
let color = 16777215;
|
||||||
|
|
||||||
if (!((direction == 7) && ((container.partType === 'fc') || (container.partType === 'ey'))))
|
if(!((direction == 7) && ((container.partType === 'fc') || (container.partType === 'ey'))))
|
||||||
{
|
{
|
||||||
if (!((container.partType === 'ri') && !container.partId))
|
if(!((container.partType === 'ri') && !container.partId))
|
||||||
{
|
{
|
||||||
const partId = container.partId;
|
const partId = container.partId;
|
||||||
const animationFrame = container.getFrameDefinition(frameCount);
|
const animationFrame = container.getFrameDefinition(frameCount);
|
||||||
@ -352,59 +352,59 @@ export class AvatarImageCache
|
|||||||
let partType = container.partType;
|
let partType = container.partType;
|
||||||
let frameNumber = 0;
|
let frameNumber = 0;
|
||||||
|
|
||||||
if (animationFrame)
|
if(animationFrame)
|
||||||
{
|
{
|
||||||
frameNumber = animationFrame.number;
|
frameNumber = animationFrame.number;
|
||||||
|
|
||||||
if ((animationFrame.assetPartDefinition) && (animationFrame.assetPartDefinition !== '')) assetPartDefinition = animationFrame.assetPartDefinition;
|
if((animationFrame.assetPartDefinition) && (animationFrame.assetPartDefinition !== '')) assetPartDefinition = animationFrame.assetPartDefinition;
|
||||||
}
|
}
|
||||||
else frameNumber = container.getFrameIndex(frameCount);
|
else frameNumber = container.getFrameIndex(frameCount);
|
||||||
|
|
||||||
let assetDirection = direction;
|
let assetDirection = direction;
|
||||||
let flipH = false;
|
let flipH = false;
|
||||||
|
|
||||||
if (isFlipped)
|
if(isFlipped)
|
||||||
{
|
{
|
||||||
if (((assetPartDefinition === 'wav') && (((partType === AvatarFigurePartType.LEFT_HAND) || (partType === AvatarFigurePartType.LEFT_SLEEVE)) || (partType === AvatarFigurePartType.LEFT_COAT_SLEEVE))) || ((assetPartDefinition === 'drk') && (((partType === AvatarFigurePartType.RIGHT_HAND) || (partType === AvatarFigurePartType.RIGHT_SLEEVE)) || (partType === AvatarFigurePartType.RIGHT_COAT_SLEEVE))) || ((assetPartDefinition === 'blw') && (partType === AvatarFigurePartType.RIGHT_HAND)) || ((assetPartDefinition === 'sig') && (partType === AvatarFigurePartType.LEFT_HAND)) || ((assetPartDefinition === 'respect') && (partType === AvatarFigurePartType.LEFT_HAND)) || (partType === AvatarFigurePartType.RIGHT_HAND_ITEM) || (partType === AvatarFigurePartType.LEFT_HAND_ITEM) || (partType === AvatarFigurePartType.CHEST_PRINT))
|
if(((assetPartDefinition === 'wav') && (((partType === AvatarFigurePartType.LEFT_HAND) || (partType === AvatarFigurePartType.LEFT_SLEEVE)) || (partType === AvatarFigurePartType.LEFT_COAT_SLEEVE))) || ((assetPartDefinition === 'drk') && (((partType === AvatarFigurePartType.RIGHT_HAND) || (partType === AvatarFigurePartType.RIGHT_SLEEVE)) || (partType === AvatarFigurePartType.RIGHT_COAT_SLEEVE))) || ((assetPartDefinition === 'blw') && (partType === AvatarFigurePartType.RIGHT_HAND)) || ((assetPartDefinition === 'sig') && (partType === AvatarFigurePartType.LEFT_HAND)) || ((assetPartDefinition === 'respect') && (partType === AvatarFigurePartType.LEFT_HAND)) || (partType === AvatarFigurePartType.RIGHT_HAND_ITEM) || (partType === AvatarFigurePartType.LEFT_HAND_ITEM) || (partType === AvatarFigurePartType.CHEST_PRINT))
|
||||||
{
|
{
|
||||||
flipH = true;
|
flipH = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (direction === 4) assetDirection = 2;
|
if(direction === 4) assetDirection = 2;
|
||||||
else if (direction === 5) assetDirection = 1;
|
else if(direction === 5) assetDirection = 1;
|
||||||
else if (direction === 6) assetDirection = 0;
|
else if(direction === 6) assetDirection = 0;
|
||||||
|
|
||||||
if (container.flippedPartType !== partType) partType = container.flippedPartType;
|
if(container.flippedPartType !== partType) partType = container.flippedPartType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let assetName = (this._scale + '_' + assetPartDefinition + '_' + partType + '_' + partId + '_' + assetDirection + '_' + frameNumber);
|
let assetName = (this._scale + '_' + assetPartDefinition + '_' + partType + '_' + partId + '_' + assetDirection + '_' + frameNumber);
|
||||||
let asset = this._assets.getAsset(assetName);
|
let asset = this._assets.getAsset(assetName);
|
||||||
|
|
||||||
if (!asset)
|
if(!asset)
|
||||||
{
|
{
|
||||||
assetName = (this._scale + '_std_' + partType + '_' + partId + '_' + assetDirection + '_0');
|
assetName = (this._scale + '_std_' + partType + '_' + partId + '_' + assetDirection + '_0');
|
||||||
asset = this._assets.getAsset(assetName);
|
asset = this._assets.getAsset(assetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset)
|
if(asset)
|
||||||
{
|
{
|
||||||
const texture = asset.texture;
|
const texture = asset.texture;
|
||||||
|
|
||||||
if (!texture || !texture.valid || !texture.baseTexture)
|
if(!texture || !texture.valid || !texture.baseTexture)
|
||||||
{
|
{
|
||||||
isCacheable = false;
|
isCacheable = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (container.isColorable && container.color) color = container.color.rgb;
|
if(container.isColorable && container.color) color = container.color.rgb;
|
||||||
|
|
||||||
const offset = new Point(-(asset.x), -(asset.y));
|
const offset = new Point(-(asset.x), -(asset.y));
|
||||||
|
|
||||||
if (flipH) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 65 : 31));
|
if(flipH) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 65 : 31));
|
||||||
|
|
||||||
if (renderServerData)
|
if(renderServerData)
|
||||||
{
|
{
|
||||||
const spriteData = new RoomObjectSpriteData();
|
const spriteData = new RoomObjectSpriteData();
|
||||||
|
|
||||||
@ -416,17 +416,17 @@ export class AvatarImageCache
|
|||||||
spriteData.height = asset.rectangle.height;
|
spriteData.height = asset.rectangle.height;
|
||||||
spriteData.flipH = flipH;
|
spriteData.flipH = flipH;
|
||||||
|
|
||||||
if (assetPartDefinition === 'lay') spriteData.x = (spriteData.x + 53);
|
if(assetPartDefinition === 'lay') spriteData.x = (spriteData.x + 53);
|
||||||
|
|
||||||
if (isFlipped)
|
if(isFlipped)
|
||||||
{
|
{
|
||||||
spriteData.flipH = (!(spriteData.flipH));
|
spriteData.flipH = (!(spriteData.flipH));
|
||||||
|
|
||||||
if (spriteData.flipH) spriteData.x = (-(spriteData.x) - texture.width);
|
if(spriteData.flipH) spriteData.x = (-(spriteData.x) - texture.width);
|
||||||
else spriteData.x = (spriteData.x + 65);
|
else spriteData.x = (spriteData.x + 65);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.isColorable) spriteData.color = `${color}`;
|
if(container.isColorable) spriteData.color = `${color}`;
|
||||||
|
|
||||||
this._serverRenderData.push(spriteData);
|
this._serverRenderData.push(spriteData);
|
||||||
}
|
}
|
||||||
@ -440,21 +440,21 @@ export class AvatarImageCache
|
|||||||
containerIndex--;
|
containerIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._unionImages.length) return null;
|
if(!this._unionImages.length) return null;
|
||||||
|
|
||||||
const imageData = this.createUnionImage(this._unionImages, isFlipped);
|
const imageData = this.createUnionImage(this._unionImages, isFlipped);
|
||||||
const canvasOffset = ((this._scale === AvatarScaleType.LARGE) ? (this._canvas.height - 16) : (this._canvas.height - 8));
|
const canvasOffset = ((this._scale === AvatarScaleType.LARGE) ? (this._canvas.height - 16) : (this._canvas.height - 8));
|
||||||
const offset = new Point(-(imageData.regPoint.x), (canvasOffset - imageData.regPoint.y));
|
const offset = new Point(-(imageData.regPoint.x), (canvasOffset - imageData.regPoint.y));
|
||||||
|
|
||||||
if (isFlipped && (assetPartDefinition !== 'lay')) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 67 : 31));
|
if(isFlipped && (assetPartDefinition !== 'lay')) offset.x = (offset.x + ((this._scale === AvatarScaleType.LARGE) ? 67 : 31));
|
||||||
|
|
||||||
let imageIndex = (this._unionImages.length - 1);
|
let imageIndex = (this._unionImages.length - 1);
|
||||||
|
|
||||||
while (imageIndex >= 0)
|
while(imageIndex >= 0)
|
||||||
{
|
{
|
||||||
const _local_17 = this._unionImages.pop();
|
const _local_17 = this._unionImages.pop();
|
||||||
|
|
||||||
if (_local_17) _local_17.dispose();
|
if(_local_17) _local_17.dispose();
|
||||||
|
|
||||||
imageIndex--;
|
imageIndex--;
|
||||||
}
|
}
|
||||||
@ -465,7 +465,7 @@ export class AvatarImageCache
|
|||||||
private convertColorToHex(k: number): string
|
private convertColorToHex(k: number): string
|
||||||
{
|
{
|
||||||
let _local_2: string = (k * 0xFF).toString(16);
|
let _local_2: string = (k * 0xFF).toString(16);
|
||||||
if (_local_2.length < 2)
|
if(_local_2.length < 2)
|
||||||
{
|
{
|
||||||
_local_2 = ('0' + _local_2);
|
_local_2 = ('0' + _local_2);
|
||||||
}
|
}
|
||||||
@ -476,7 +476,7 @@ export class AvatarImageCache
|
|||||||
{
|
{
|
||||||
const bounds = new Rectangle();
|
const bounds = new Rectangle();
|
||||||
|
|
||||||
for (const data of k) data && bounds.enlarge(data.offsetRect);
|
for(const data of k) data && bounds.enlarge(data.offsetRect);
|
||||||
|
|
||||||
const point = new Point(-(bounds.x), -(bounds.y));
|
const point = new Point(-(bounds.x), -(bounds.y));
|
||||||
const container = new NitroContainer();
|
const container = new NitroContainer();
|
||||||
@ -488,9 +488,9 @@ export class AvatarImageCache
|
|||||||
|
|
||||||
container.addChild(sprite);
|
container.addChild(sprite);
|
||||||
|
|
||||||
for (const data of k)
|
for(const data of k)
|
||||||
{
|
{
|
||||||
if (!data) continue;
|
if(!data) continue;
|
||||||
|
|
||||||
const texture = data.texture;
|
const texture = data.texture;
|
||||||
const color = data.colorTransform;
|
const color = data.colorTransform;
|
||||||
@ -500,9 +500,9 @@ export class AvatarImageCache
|
|||||||
regPoint.x -= data.regPoint.x;
|
regPoint.x -= data.regPoint.x;
|
||||||
regPoint.y -= data.regPoint.y;
|
regPoint.y -= data.regPoint.y;
|
||||||
|
|
||||||
if (isFlipped) regPoint.x = (container.width - (regPoint.x + data.rect.width));
|
if(isFlipped) regPoint.x = (container.width - (regPoint.x + data.rect.width));
|
||||||
|
|
||||||
if (flipH)
|
if(flipH)
|
||||||
{
|
{
|
||||||
this._matrix.a = -1;
|
this._matrix.a = -1;
|
||||||
this._matrix.tx = ((data.rect.x + data.rect.width) + regPoint.x);
|
this._matrix.tx = ((data.rect.x + data.rect.width) + regPoint.x);
|
||||||
|
@ -29,7 +29,7 @@ export class PetFigureData
|
|||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < this._customLayerIds.length)
|
while(i < this._customLayerIds.length)
|
||||||
{
|
{
|
||||||
this._customParts.push(new PetCustomPart(this._customLayerIds[i], this._customPartIds[i], this._customPaletteIds[i]));
|
this._customParts.push(new PetCustomPart(this._customLayerIds[i], this._customPartIds[i], this._customPaletteIds[i]));
|
||||||
|
|
||||||
@ -74,11 +74,11 @@ export class PetFigureData
|
|||||||
|
|
||||||
public getCustomPart(k: number): IPetCustomPart
|
public getCustomPart(k: number): IPetCustomPart
|
||||||
{
|
{
|
||||||
if (this._customParts)
|
if(this._customParts)
|
||||||
{
|
{
|
||||||
for (const _local_2 of this._customParts)
|
for(const _local_2 of this._customParts)
|
||||||
{
|
{
|
||||||
if (_local_2.layerId === k) return _local_2;
|
if(_local_2.layerId === k) return _local_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ export class PetFigureData
|
|||||||
|
|
||||||
figure = (figure + (' ' + this.customParts.length));
|
figure = (figure + (' ' + this.customParts.length));
|
||||||
|
|
||||||
for (const _local_2 of this.customParts)
|
for(const _local_2 of this.customParts)
|
||||||
{
|
{
|
||||||
figure = (figure + (((((' ' + _local_2.layerId) + ' ') + _local_2.partId) + ' ') + _local_2.paletteId));
|
figure = (figure + (((((' ' + _local_2.layerId) + ' ') + _local_2.partId) + ' ') + _local_2.paletteId));
|
||||||
}
|
}
|
||||||
@ -113,13 +113,13 @@ export class PetFigureData
|
|||||||
{
|
{
|
||||||
let _local_2: string[] = [];
|
let _local_2: string[] = [];
|
||||||
|
|
||||||
if (k)
|
if(k)
|
||||||
{
|
{
|
||||||
const _local_3 = k.split(' ');
|
const _local_3 = k.split(' ');
|
||||||
const _local_4 = ((this._headOnly) ? 1 : 0);
|
const _local_4 = ((this._headOnly) ? 1 : 0);
|
||||||
const _local_5 = (4 + _local_4);
|
const _local_5 = (4 + _local_4);
|
||||||
|
|
||||||
if (_local_3.length > _local_5)
|
if(_local_3.length > _local_5)
|
||||||
{
|
{
|
||||||
const _local_6 = (3 + _local_4);
|
const _local_6 = (3 + _local_4);
|
||||||
const _local_7 = parseInt(_local_3[_local_6]);
|
const _local_7 = parseInt(_local_3[_local_6]);
|
||||||
@ -137,7 +137,7 @@ export class PetFigureData
|
|||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < data.length)
|
while(i < data.length)
|
||||||
{
|
{
|
||||||
layerIds.push(parseInt(data[(i + 0)]));
|
layerIds.push(parseInt(data[(i + 0)]));
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ export class PetFigureData
|
|||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < data.length)
|
while(i < data.length)
|
||||||
{
|
{
|
||||||
partIds.push(parseInt(data[(i + 1)]));
|
partIds.push(parseInt(data[(i + 1)]));
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ export class PetFigureData
|
|||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while (i < data.length)
|
while(i < data.length)
|
||||||
{
|
{
|
||||||
paletteIds.push(parseInt(data[(i + 2)]));
|
paletteIds.push(parseInt(data[(i + 2)]));
|
||||||
|
|
||||||
@ -181,11 +181,11 @@ export class PetFigureData
|
|||||||
|
|
||||||
private getTypeId(data: string): number
|
private getTypeId(data: string): number
|
||||||
{
|
{
|
||||||
if (data)
|
if(data)
|
||||||
{
|
{
|
||||||
const parts = data.split(' ');
|
const parts = data.split(' ');
|
||||||
|
|
||||||
if (parts.length >= 1) return parseInt(parts[0]);
|
if(parts.length >= 1) return parseInt(parts[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -193,11 +193,11 @@ export class PetFigureData
|
|||||||
|
|
||||||
private getPaletteId(data: string): number
|
private getPaletteId(data: string): number
|
||||||
{
|
{
|
||||||
if (data)
|
if(data)
|
||||||
{
|
{
|
||||||
const parts = data.split(' ');
|
const parts = data.split(' ');
|
||||||
|
|
||||||
if (parts.length >= 2) return parseInt(parts[1]);
|
if(parts.length >= 2) return parseInt(parts[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -205,11 +205,11 @@ export class PetFigureData
|
|||||||
|
|
||||||
private getColor(data: string): number
|
private getColor(data: string): number
|
||||||
{
|
{
|
||||||
if (data)
|
if(data)
|
||||||
{
|
{
|
||||||
const parts = data.split(' ');
|
const parts = data.split(' ');
|
||||||
|
|
||||||
if (parts.length >= 3) return parseInt(parts[2], 16);
|
if(parts.length >= 3) return parseInt(parts[2], 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0xFFFFFF;
|
return 0xFFFFFF;
|
||||||
@ -217,11 +217,11 @@ export class PetFigureData
|
|||||||
|
|
||||||
private getHeadOnly(data: string): boolean
|
private getHeadOnly(data: string): boolean
|
||||||
{
|
{
|
||||||
if (data)
|
if(data)
|
||||||
{
|
{
|
||||||
const parts = data.split(' ');
|
const parts = data.split(' ');
|
||||||
|
|
||||||
if (parts.length >= 4) return parts[3] === 'head';
|
if(parts.length >= 4) return parts[3] === 'head';
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -30,9 +30,9 @@ export class AvatarStructureDownload extends EventDispatcher
|
|||||||
{
|
{
|
||||||
const response = request.responseText;
|
const response = request.responseText;
|
||||||
|
|
||||||
if (!response || !response.length) throw new Error('invalid_figure_data');
|
if(!response || !response.length) throw new Error('invalid_figure_data');
|
||||||
|
|
||||||
if (this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response));
|
if(this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response));
|
||||||
|
|
||||||
this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE));
|
this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE));
|
||||||
};
|
};
|
||||||
|
@ -13,7 +13,7 @@ export class SetType implements ISetType
|
|||||||
|
|
||||||
constructor(data: IFigureDataSetType)
|
constructor(data: IFigureDataSetType)
|
||||||
{
|
{
|
||||||
if (!data) throw new Error('invalid_data');
|
if(!data) throw new Error('invalid_data');
|
||||||
|
|
||||||
this._type = data.type;
|
this._type = data.type;
|
||||||
this._paletteId = data.paletteId;
|
this._paletteId = data.paletteId;
|
||||||
@ -27,7 +27,7 @@ export class SetType implements ISetType
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
for (const set of this._partSets.getValues())
|
for(const set of this._partSets.getValues())
|
||||||
{
|
{
|
||||||
const partSet = set as FigurePartSet;
|
const partSet = set as FigurePartSet;
|
||||||
|
|
||||||
@ -39,12 +39,12 @@ export class SetType implements ISetType
|
|||||||
|
|
||||||
public cleanUp(data: IFigureDataSetType): void
|
public cleanUp(data: IFigureDataSetType): void
|
||||||
{
|
{
|
||||||
for (const set of data.sets)
|
for(const set of data.sets)
|
||||||
{
|
{
|
||||||
const setId = set.id.toString();
|
const setId = set.id.toString();
|
||||||
const partSet = (this._partSets.getValue(setId) as FigurePartSet);
|
const partSet = (this._partSets.getValue(setId) as FigurePartSet);
|
||||||
|
|
||||||
if (partSet)
|
if(partSet)
|
||||||
{
|
{
|
||||||
partSet.dispose();
|
partSet.dispose();
|
||||||
|
|
||||||
@ -55,18 +55,18 @@ export class SetType implements ISetType
|
|||||||
|
|
||||||
public append(setType: IFigureDataSetType): void
|
public append(setType: IFigureDataSetType): void
|
||||||
{
|
{
|
||||||
if (!setType || !setType.sets) return;
|
if(!setType || !setType.sets) return;
|
||||||
|
|
||||||
for (const set of setType.sets) this._partSets.add(set.id.toString(), new FigurePartSet(this._type, set));
|
for(const set of setType.sets) this._partSets.add(set.id.toString(), new FigurePartSet(this._type, set));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDefaultPartSet(gender: string): IFigurePartSet
|
public getDefaultPartSet(gender: string): IFigurePartSet
|
||||||
{
|
{
|
||||||
for (const set of this._partSets.getValues())
|
for(const set of this._partSets.getValues())
|
||||||
{
|
{
|
||||||
if (!set) continue;
|
if(!set) continue;
|
||||||
|
|
||||||
if ((set.clubLevel === 0) && ((set.gender === gender) || (set.gender === 'U'))) return set;
|
if((set.clubLevel === 0) && ((set.gender === gender) || (set.gender === 'U'))) return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -22,20 +22,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;
|
||||||
}
|
}
|
||||||
@ -58,22 +58,22 @@ export class RoomCameraWidgetManager implements IRoomCameraWidgetManager
|
|||||||
|
|
||||||
container.addChild(sprite);
|
container.addChild(sprite);
|
||||||
|
|
||||||
if (isZoomed) sprite.scale.set(2);
|
if(isZoomed) sprite.scale.set(2);
|
||||||
|
|
||||||
for (const selectedEffect of selectedEffects)
|
for(const selectedEffect of selectedEffects)
|
||||||
{
|
{
|
||||||
const effect = selectedEffect.effect;
|
const effect = selectedEffect.effect;
|
||||||
|
|
||||||
if (!effect) continue;
|
if(!effect) continue;
|
||||||
|
|
||||||
if (effect.colorMatrix)
|
if(effect.colorMatrix)
|
||||||
{
|
{
|
||||||
const filter = new ColorMatrixFilter();
|
const filter = new ColorMatrixFilter();
|
||||||
|
|
||||||
filter.matrix = effect.colorMatrix;
|
filter.matrix = effect.colorMatrix;
|
||||||
filter.alpha = selectedEffect.alpha;
|
filter.alpha = selectedEffect.alpha;
|
||||||
|
|
||||||
if (!sprite.filters) sprite.filters = [];
|
if(!sprite.filters) sprite.filters = [];
|
||||||
|
|
||||||
sprite.filters.push(filter);
|
sprite.filters.push(filter);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
|
|||||||
|
|
||||||
protected onInit(): void
|
protected onInit(): void
|
||||||
{
|
{
|
||||||
if (this._connection) return;
|
if(this._connection) return;
|
||||||
|
|
||||||
Nitro.instance.events.addEventListener(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, this.onConnectionAuthenticatedEvent);
|
Nitro.instance.events.addEventListener(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, this.onConnectionAuthenticatedEvent);
|
||||||
|
|
||||||
@ -42,16 +42,16 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
|
|||||||
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||||
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
|
this._connection.addEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
|
||||||
|
|
||||||
if (this._demo) this._demo.init();
|
if(this._demo) this._demo.init();
|
||||||
|
|
||||||
this._connection.init(Nitro.instance.getConfiguration<string>('socket.url'));
|
this._connection.init(Nitro.instance.getConfiguration<string>('socket.url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onDispose(): void
|
protected onDispose(): void
|
||||||
{
|
{
|
||||||
if (this._demo) this._demo.dispose();
|
if(this._demo) this._demo.dispose();
|
||||||
|
|
||||||
if (this._connection)
|
if(this._connection)
|
||||||
{
|
{
|
||||||
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
||||||
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
this._connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||||
@ -82,7 +82,7 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
|
|||||||
{
|
{
|
||||||
this.logger.log('Connection Authenticated');
|
this.logger.log('Connection Authenticated');
|
||||||
|
|
||||||
if (this._connection) this._connection.authenticated();
|
if(this._connection) this._connection.authenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
public connectionInit(socketUrl: string): void
|
public connectionInit(socketUrl: string): void
|
||||||
@ -92,14 +92,14 @@ export class NitroCommunicationManager extends NitroManager implements INitroCom
|
|||||||
|
|
||||||
public registerMessageEvent(event: IMessageEvent): IMessageEvent
|
public registerMessageEvent(event: IMessageEvent): IMessageEvent
|
||||||
{
|
{
|
||||||
if (this._connection) this._connection.addMessageEvent(event);
|
if(this._connection) this._connection.addMessageEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeMessageEvent(event: IMessageEvent): void
|
public removeMessageEvent(event: IMessageEvent): void
|
||||||
{
|
{
|
||||||
if (!this._connection) return;
|
if(!this._connection) return;
|
||||||
|
|
||||||
this._connection.removeMessageEvent(event);
|
this._connection.removeMessageEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
{
|
{
|
||||||
const connection = this._communication.connection;
|
const connection = this._communication.connection;
|
||||||
|
|
||||||
if (connection)
|
if(connection)
|
||||||
{
|
{
|
||||||
connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
||||||
connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||||
@ -49,7 +49,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
{
|
{
|
||||||
const connection = this._communication.connection;
|
const connection = this._communication.connection;
|
||||||
|
|
||||||
if (connection)
|
if(connection)
|
||||||
{
|
{
|
||||||
connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
connection.removeEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
|
||||||
connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
connection.removeEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
|
||||||
@ -67,13 +67,13 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
{
|
{
|
||||||
const connection = this._communication.connection;
|
const connection = this._communication.connection;
|
||||||
|
|
||||||
if (!connection) return;
|
if(!connection) return;
|
||||||
|
|
||||||
this._didConnect = true;
|
this._didConnect = true;
|
||||||
|
|
||||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
|
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
|
||||||
|
|
||||||
if (Nitro.instance.getConfiguration<boolean>('system.pong.manually', false)) this.startPonging();
|
if(Nitro.instance.getConfiguration<boolean>('system.pong.manually', false)) this.startPonging();
|
||||||
|
|
||||||
this.startHandshake(connection);
|
this.startHandshake(connection);
|
||||||
|
|
||||||
@ -86,18 +86,18 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
{
|
{
|
||||||
const connection = this._communication.connection;
|
const connection = this._communication.connection;
|
||||||
|
|
||||||
if (!connection) return;
|
if(!connection) return;
|
||||||
|
|
||||||
this.stopPonging();
|
this.stopPonging();
|
||||||
|
|
||||||
if (this._didConnect) this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, connection);
|
if(this._didConnect) this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onConnectionErrorEvent(event: CloseEvent): void
|
private onConnectionErrorEvent(event: CloseEvent): void
|
||||||
{
|
{
|
||||||
const connection = this._communication.connection;
|
const connection = this._communication.connection;
|
||||||
|
|
||||||
if (!connection) return;
|
if(!connection) return;
|
||||||
|
|
||||||
this.stopPonging();
|
this.stopPonging();
|
||||||
|
|
||||||
@ -106,9 +106,9 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
|
|
||||||
private tryAuthentication(connection: IConnection): void
|
private tryAuthentication(connection: IConnection): void
|
||||||
{
|
{
|
||||||
if (!connection || !this.getSSO())
|
if(!connection || !this.getSSO())
|
||||||
{
|
{
|
||||||
if (!this.getSSO())
|
if(!this.getSSO())
|
||||||
{
|
{
|
||||||
this.logger.error('Login without an SSO ticket is not supported');
|
this.logger.error('Login without an SSO ticket is not supported');
|
||||||
}
|
}
|
||||||
@ -123,14 +123,14 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
|
|
||||||
private onClientPingEvent(event: ClientPingEvent): void
|
private onClientPingEvent(event: ClientPingEvent): void
|
||||||
{
|
{
|
||||||
if (!event || !event.connection) return;
|
if(!event || !event.connection) return;
|
||||||
|
|
||||||
this.sendPong(event.connection);
|
this.sendPong(event.connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onAuthenticatedEvent(event: AuthenticatedEvent): void
|
private onAuthenticatedEvent(event: AuthenticatedEvent): void
|
||||||
{
|
{
|
||||||
if (!event || !event.connection) return;
|
if(!event || !event.connection) return;
|
||||||
|
|
||||||
this.completeHandshake(event.connection);
|
this.completeHandshake(event.connection);
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
|
|
||||||
private stopPonging(): void
|
private stopPonging(): void
|
||||||
{
|
{
|
||||||
if (!this._pongInterval) return;
|
if(!this._pongInterval) return;
|
||||||
|
|
||||||
clearInterval(this._pongInterval);
|
clearInterval(this._pongInterval);
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
|
|||||||
{
|
{
|
||||||
connection = ((connection || this._communication.connection) || null);
|
connection = ((connection || this._communication.connection) || null);
|
||||||
|
|
||||||
if (!connection) return;
|
if(!connection) return;
|
||||||
|
|
||||||
connection.send(new PongMessageComposer());
|
connection.send(new PongMessageComposer());
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export class RenderRoomMessageComposer implements IMessageComposer<ConstructorPa
|
|||||||
{
|
{
|
||||||
const url = TextureUtils.generateImageUrl(texture);
|
const url = TextureUtils.generateImageUrl(texture);
|
||||||
|
|
||||||
if (!url) return;
|
if(!url) return;
|
||||||
|
|
||||||
const base64Data = url.split(',')[1];
|
const base64Data = url.split(',')[1];
|
||||||
const binaryData = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0));
|
const binaryData = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0));
|
||||||
|
@ -9,11 +9,11 @@ export class AuthenticationMessageComposer implements IMessageComposer<string[]>
|
|||||||
{
|
{
|
||||||
this._type = type;
|
this._type = type;
|
||||||
|
|
||||||
if (keys.length !== values.length) return;
|
if(keys.length !== values.length) return;
|
||||||
|
|
||||||
this._data = [];
|
this._data = [];
|
||||||
|
|
||||||
for (let i = 0; i < keys.length; i++)
|
for(let i = 0; i < keys.length; i++)
|
||||||
{
|
{
|
||||||
this._data.push(keys[i]);
|
this._data.push(keys[i]);
|
||||||
this._data.push(values[i]);
|
this._data.push(values[i]);
|
||||||
|
@ -8,9 +8,9 @@ export class SetActivatedBadgesComposer implements IMessageComposer<any[]>
|
|||||||
{
|
{
|
||||||
const data = [];
|
const data = [];
|
||||||
|
|
||||||
for (let i = 0; i < this._badges.length; i++)
|
for(let i = 0; i < this._badges.length; i++)
|
||||||
{
|
{
|
||||||
if (i <= this._badges.length)
|
if(i <= this._badges.length)
|
||||||
{
|
{
|
||||||
data.push(i + 1);
|
data.push(i + 1);
|
||||||
data.push(this._badges[i]);
|
data.push(this._badges[i]);
|
||||||
|
@ -8,7 +8,7 @@ export class DefaultSanctionMessageComposer implements IMessageComposer<Construc
|
|||||||
constructor(k: number, _arg_2: number, _arg_3: string, _arg_4: number = -1)
|
constructor(k: number, _arg_2: number, _arg_3: string, _arg_4: number = -1)
|
||||||
{
|
{
|
||||||
this._data = [k, _arg_2, _arg_3];
|
this._data = [k, _arg_2, _arg_3];
|
||||||
if (_arg_4 != ModBanMessageComposer.NO_ISSUE_ID)
|
if(_arg_4 != ModBanMessageComposer.NO_ISSUE_ID)
|
||||||
{
|
{
|
||||||
this._data.push(_arg_4);
|
this._data.push(_arg_4);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ export class ModAlertMessageComposer implements IMessageComposer<ConstructorPara
|
|||||||
constructor(k: number, arg2: string, arg3: number, arg4: number = -1)
|
constructor(k: number, arg2: string, arg3: number, arg4: number = -1)
|
||||||
{
|
{
|
||||||
this._data = [k, arg2, arg3];
|
this._data = [k, arg2, arg3];
|
||||||
if (arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
if(arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
||||||
{
|
{
|
||||||
this._data.push(arg4);
|
this._data.push(arg4);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ export class ModBanMessageComposer implements IMessageComposer<ConstructorParame
|
|||||||
constructor(k: number, arg2: string, arg3: number, arg4: number, arg5: boolean, arg6: number = -1)
|
constructor(k: number, arg2: string, arg3: number, arg4: number, arg5: boolean, arg6: number = -1)
|
||||||
{
|
{
|
||||||
this._data = [k, arg2, arg3, arg4, arg5];
|
this._data = [k, arg2, arg3, arg4, arg5];
|
||||||
if (arg6 != ModBanMessageComposer.NO_ISSUE_ID)
|
if(arg6 != ModBanMessageComposer.NO_ISSUE_ID)
|
||||||
{
|
{
|
||||||
this._data.push(arg6);
|
this._data.push(arg6);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ export class ModKickMessageComposer implements IMessageComposer<ConstructorParam
|
|||||||
{
|
{
|
||||||
this._data = [k, arg2, arg3];
|
this._data = [k, arg2, arg3];
|
||||||
|
|
||||||
if (arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
if(arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
||||||
{
|
{
|
||||||
this._data.push(arg4);
|
this._data.push(arg4);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ export class ModMessageMessageComposer implements IMessageComposer<any>
|
|||||||
this._data.push('');
|
this._data.push('');
|
||||||
this._data.push('');
|
this._data.push('');
|
||||||
this._data.push(arg3);
|
this._data.push(arg3);
|
||||||
if (arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
if(arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
||||||
{
|
{
|
||||||
this._data.push(arg4);
|
this._data.push(arg4);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ export class ModMuteMessageComposer implements IMessageComposer<ConstructorParam
|
|||||||
constructor(k: number, arg2: string, arg3: number, arg4: number = -1)
|
constructor(k: number, arg2: string, arg3: number, arg4: number = -1)
|
||||||
{
|
{
|
||||||
this._data = [k, arg2, arg3];
|
this._data = [k, arg2, arg3];
|
||||||
if (arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
if(arg4 != ModBanMessageComposer.NO_ISSUE_ID)
|
||||||
{
|
{
|
||||||
this._data.push(arg4);
|
this._data.push(arg4);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ export class ModTradingLockMessageComposer implements IMessageComposer<Construct
|
|||||||
{
|
{
|
||||||
this._data = [k, arg2, arg3, arg4];
|
this._data = [k, arg2, arg3, arg4];
|
||||||
|
|
||||||
if (arg5 != ModBanMessageComposer.NO_ISSUE_ID)
|
if(arg5 != ModBanMessageComposer.NO_ISSUE_ID)
|
||||||
{
|
{
|
||||||
this._data.push(arg5);
|
this._data.push(arg5);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { IMessageComposer } from '../../../../../../api';
|
import { IMessageComposer } from '../../../../../../api';
|
||||||
|
|
||||||
export class SaveRoomSettingsComposer
|
export class SaveRoomSettingsComposer
|
||||||
implements
|
implements
|
||||||
IMessageComposer<
|
IMessageComposer<
|
||||||
ConstructorParameters<typeof SaveRoomSettingsComposer>
|
ConstructorParameters<typeof SaveRoomSettingsComposer>
|
||||||
>
|
>
|
||||||
|
@ -8,7 +8,7 @@ export class SetObjectDataMessageComposer implements IMessageComposer<any[]>
|
|||||||
{
|
{
|
||||||
this._data = [objectId, (data.size * 2)];
|
this._data = [objectId, (data.size * 2)];
|
||||||
|
|
||||||
for (const [key, value] of data.entries()) this._data.push(key, value);
|
for(const [key, value] of data.entries()) this._data.push(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMessageArray()
|
public getMessageArray()
|
||||||
|
@ -21,7 +21,7 @@ export class FurniturePlaceComposer implements IMessageComposer<string[]>
|
|||||||
|
|
||||||
public getMessageArray()
|
public getMessageArray()
|
||||||
{
|
{
|
||||||
switch (this._category)
|
switch(this._category)
|
||||||
{
|
{
|
||||||
case RoomObjectCategory.FLOOR:
|
case RoomObjectCategory.FLOOR:
|
||||||
return [`${this._itemId} ${this._x} ${this._y} ${this._direction}`];
|
return [`${this._itemId} ${this._x} ${this._y} ${this._direction}`];
|
||||||
|
@ -13,7 +13,7 @@ export class InterstitialMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._canShowInterstitial = wrapper.readBoolean();
|
this._canShowInterstitial = wrapper.readBoolean();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export class RoomAdErrorMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._errorCode = wrapper.readInt();
|
this._errorCode = wrapper.readInt();
|
||||||
this._filteredText = wrapper.readString();
|
this._filteredText = wrapper.readString();
|
||||||
|
@ -17,12 +17,12 @@ export class AvailabilityStatusMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._isOpen = wrapper.readBoolean();
|
this._isOpen = wrapper.readBoolean();
|
||||||
this._onShutdown = wrapper.readBoolean();
|
this._onShutdown = wrapper.readBoolean();
|
||||||
|
|
||||||
if (wrapper.bytesAvailable)
|
if(wrapper.bytesAvailable)
|
||||||
{
|
{
|
||||||
this._isAuthenticUser = wrapper.readBoolean();
|
this._isAuthenticUser = wrapper.readBoolean();
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export class AvailabilityTimeMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._isOpen = (wrapper.readInt() > 0);
|
this._isOpen = (wrapper.readInt() > 0);
|
||||||
this._minutesUntilChange = wrapper.readInt();
|
this._minutesUntilChange = wrapper.readInt();
|
||||||
|
@ -15,7 +15,7 @@ export class HotelClosedAndOpensMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._openHour = wrapper.readInt();
|
this._openHour = wrapper.readInt();
|
||||||
this._openMinute = wrapper.readInt();
|
this._openMinute = wrapper.readInt();
|
||||||
|
@ -17,7 +17,7 @@ export class HotelClosesAndWillOpenAtMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._openHour = wrapper.readInt();
|
this._openHour = wrapper.readInt();
|
||||||
this._openMinute = wrapper.readInt();
|
this._openMinute = wrapper.readInt();
|
||||||
|
@ -13,7 +13,7 @@ export class HotelWillCloseInMinutesMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._minutes = wrapper.readInt();
|
this._minutes = wrapper.readInt();
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ export class MaintenanceStatusMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._isInMaintenance = wrapper.readBoolean();
|
this._isInMaintenance = wrapper.readBoolean();
|
||||||
this._minutesUntilMaintenance = wrapper.readInt();
|
this._minutesUntilMaintenance = wrapper.readInt();
|
||||||
|
|
||||||
if (wrapper.bytesAvailable)
|
if(wrapper.bytesAvailable)
|
||||||
{
|
{
|
||||||
this._duration = wrapper.readInt();
|
this._duration = wrapper.readInt();
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,14 @@ export class ChangeUserNameResultMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._resultCode = wrapper.readInt();
|
this._resultCode = wrapper.readInt();
|
||||||
this._name = wrapper.readString();
|
this._name = wrapper.readString();
|
||||||
|
|
||||||
let totalSuggestions = wrapper.readInt();
|
let totalSuggestions = wrapper.readInt();
|
||||||
|
|
||||||
while (totalSuggestions > 0)
|
while(totalSuggestions > 0)
|
||||||
{
|
{
|
||||||
this._nameSuggestions.push(wrapper.readString());
|
this._nameSuggestions.push(wrapper.readString());
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ export class CheckUserNameResultMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._resultCode = wrapper.readInt();
|
this._resultCode = wrapper.readInt();
|
||||||
this._name = wrapper.readString();
|
this._name = wrapper.readString();
|
||||||
|
|
||||||
let totalSuggestions = wrapper.readInt();
|
let totalSuggestions = wrapper.readInt();
|
||||||
|
|
||||||
while (totalSuggestions > 0)
|
while(totalSuggestions > 0)
|
||||||
{
|
{
|
||||||
this._nameSuggestions.push(wrapper.readString());
|
this._nameSuggestions.push(wrapper.readString());
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@ export class FigureUpdateParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._figure = wrapper.readString();
|
this._figure = wrapper.readString();
|
||||||
this._gender = wrapper.readString();
|
this._gender = wrapper.readString();
|
||||||
|
|
||||||
if (this._gender) this._gender = this._gender.toUpperCase();
|
if(this._gender) this._gender = this._gender.toUpperCase();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,13 @@ export class WardrobeMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._state = wrapper.readInt();
|
this._state = wrapper.readInt();
|
||||||
|
|
||||||
let count = wrapper.readInt();
|
let count = wrapper.readInt();
|
||||||
|
|
||||||
while (count > 0)
|
while(count > 0)
|
||||||
{
|
{
|
||||||
this._outfits.push(new OutfitData(wrapper));
|
this._outfits.push(new OutfitData(wrapper));
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ export class BotAddedToInventoryParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._item = new BotData(wrapper);
|
this._item = new BotData(wrapper);
|
||||||
this._openInventory = wrapper.readBoolean();
|
this._openInventory = wrapper.readBoolean();
|
||||||
|
@ -10,7 +10,7 @@ export class BotData
|
|||||||
|
|
||||||
constructor(wrapper: IMessageDataWrapper)
|
constructor(wrapper: IMessageDataWrapper)
|
||||||
{
|
{
|
||||||
if (!wrapper) throw new Error('invalid_parser');
|
if(!wrapper) throw new Error('invalid_parser');
|
||||||
|
|
||||||
this._id = wrapper.readInt();
|
this._id = wrapper.readInt();
|
||||||
this._name = wrapper.readString();
|
this._name = wrapper.readString();
|
||||||
|
@ -18,7 +18,7 @@ export class BotInventoryMessageParser implements IMessageParser
|
|||||||
|
|
||||||
let count = wrapper.readInt();
|
let count = wrapper.readInt();
|
||||||
|
|
||||||
while (count > 0)
|
while(count > 0)
|
||||||
{
|
{
|
||||||
const data = new BotData(wrapper);
|
const data = new BotData(wrapper);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ export class BotReceivedMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._boughtAsGift = wrapper.readBoolean();
|
this._boughtAsGift = wrapper.readBoolean();
|
||||||
this._item = new BotData(wrapper);
|
this._item = new BotData(wrapper);
|
||||||
|
@ -13,7 +13,7 @@ export class BotRemovedFromInventoryParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._itemId = wrapper.readInt();
|
this._itemId = wrapper.readInt();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export class CallForHelpCategoryData implements INamed, IDisposable
|
|||||||
|
|
||||||
let count = wrapper.readInt();
|
let count = wrapper.readInt();
|
||||||
|
|
||||||
while (count > 0)
|
while(count > 0)
|
||||||
{
|
{
|
||||||
this._topics.push(new CallForHelpTopicData(wrapper));
|
this._topics.push(new CallForHelpTopicData(wrapper));
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ export class CallForHelpCategoryData implements INamed, IDisposable
|
|||||||
|
|
||||||
public dispose(): void
|
public dispose(): void
|
||||||
{
|
{
|
||||||
if (this._disposed) return;
|
if(this._disposed) return;
|
||||||
|
|
||||||
this._disposed = true;
|
this._disposed = true;
|
||||||
this._topics = null;
|
this._topics = null;
|
||||||
|
@ -18,7 +18,7 @@ export class CfhSanctionMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._issueId = wrapper.readInt();
|
this._issueId = wrapper.readInt();
|
||||||
this._accountId = wrapper.readInt();
|
this._accountId = wrapper.readInt();
|
||||||
|
@ -17,9 +17,9 @@ export class CfhSanctionTypeData implements INamed
|
|||||||
this._probationDays = wrapper.readInt();
|
this._probationDays = wrapper.readInt();
|
||||||
this._avatarOnly = wrapper.readBoolean();
|
this._avatarOnly = wrapper.readBoolean();
|
||||||
|
|
||||||
if (wrapper.bytesAvailable) this._tradeLockInfo = wrapper.readString();
|
if(wrapper.bytesAvailable) this._tradeLockInfo = wrapper.readString();
|
||||||
|
|
||||||
if (wrapper.bytesAvailable) this._machineBanInfo = wrapper.readString();
|
if(wrapper.bytesAvailable) this._machineBanInfo = wrapper.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get name(): string
|
public get name(): string
|
||||||
|
@ -14,13 +14,13 @@ export class CfhTopicsInitMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._callForHelpCategories = [];
|
this._callForHelpCategories = [];
|
||||||
|
|
||||||
let count = wrapper.readInt();
|
let count = wrapper.readInt();
|
||||||
|
|
||||||
while (count > 0)
|
while(count > 0)
|
||||||
{
|
{
|
||||||
this._callForHelpCategories.push(new CallForHelpCategoryData(wrapper));
|
this._callForHelpCategories.push(new CallForHelpCategoryData(wrapper));
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export class SanctionStatusMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._isSanctionNew = wrapper.readBoolean();
|
this._isSanctionNew = wrapper.readBoolean();
|
||||||
this._isSanctionActive = wrapper.readBoolean();
|
this._isSanctionActive = wrapper.readBoolean();
|
||||||
@ -52,7 +52,7 @@ export class SanctionStatusMessageParser implements IMessageParser
|
|||||||
|
|
||||||
this._hasCustomMute = wrapper.readBoolean();
|
this._hasCustomMute = wrapper.readBoolean();
|
||||||
|
|
||||||
if (wrapper.bytesAvailable) this._tradeLockExpiryTime = wrapper.readString();
|
if(wrapper.bytesAvailable) this._tradeLockExpiryTime = wrapper.readString();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ export class CameraPublishStatusMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._ok = wrapper.readBoolean();
|
this._ok = wrapper.readBoolean();
|
||||||
this._secondsToWait = wrapper.readInt();
|
this._secondsToWait = wrapper.readInt();
|
||||||
|
|
||||||
if (this._ok && wrapper.bytesAvailable) this._extraDataId = wrapper.readString();
|
if(this._ok && wrapper.bytesAvailable) this._extraDataId = wrapper.readString();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ export class CameraPurchaseOKMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ export class CameraStorageUrlMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._url = wrapper.readString();
|
this._url = wrapper.readString();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export class CompetitionStatusMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._ok = wrapper.readBoolean();
|
this._ok = wrapper.readBoolean();
|
||||||
this._errorReason = wrapper.readString();
|
this._errorReason = wrapper.readString();
|
||||||
|
@ -17,12 +17,12 @@ export class InitCameraMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._creditPrice = wrapper.readInt();
|
this._creditPrice = wrapper.readInt();
|
||||||
this._ducketPrice = wrapper.readInt();
|
this._ducketPrice = wrapper.readInt();
|
||||||
|
|
||||||
if (wrapper.bytesAvailable) this._publishDucketPrice = wrapper.readInt();
|
if(wrapper.bytesAvailable) this._publishDucketPrice = wrapper.readInt();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ export class ThumbnailStatusMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
if (wrapper.bytesAvailable)
|
if(wrapper.bytesAvailable)
|
||||||
{
|
{
|
||||||
this._ok = wrapper.readBoolean();
|
this._ok = wrapper.readBoolean();
|
||||||
this._renderLimitHit = wrapper.readBoolean();
|
this._renderLimitHit = wrapper.readBoolean();
|
||||||
|
@ -11,7 +11,7 @@ export class CampaignCalendarData
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._campaignName = wrapper.readString();
|
this._campaignName = wrapper.readString();
|
||||||
this._campaignImage = wrapper.readString();
|
this._campaignImage = wrapper.readString();
|
||||||
@ -21,7 +21,7 @@ export class CampaignCalendarData
|
|||||||
|
|
||||||
let count = wrapper.readInt();
|
let count = wrapper.readInt();
|
||||||
|
|
||||||
for (let i = 0; i < count; i++)
|
for(let i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
this._openedDays.push(wrapper.readInt());
|
this._openedDays.push(wrapper.readInt());
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ export class CampaignCalendarData
|
|||||||
|
|
||||||
count = wrapper.readInt();
|
count = wrapper.readInt();
|
||||||
|
|
||||||
for (let i = 0; i < count; i++)
|
for(let i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
this._missedDays.push(wrapper.readInt());
|
this._missedDays.push(wrapper.readInt());
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export class CampaignCalendarDataMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._calendarData = new CampaignCalendarData();
|
this._calendarData = new CampaignCalendarData();
|
||||||
this._calendarData.parse(wrapper);
|
this._calendarData.parse(wrapper);
|
||||||
|
@ -19,7 +19,7 @@ export class CampaignCalendarDoorOpenedMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._doorOpened = wrapper.readBoolean();
|
this._doorOpened = wrapper.readBoolean();
|
||||||
this._productName = wrapper.readString();
|
this._productName = wrapper.readString();
|
||||||
|
@ -18,7 +18,7 @@ export class BonusRareInfoMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._productType = wrapper.readString();
|
this._productType = wrapper.readString();
|
||||||
this._productClassId = wrapper.readInt();
|
this._productClassId = wrapper.readInt();
|
||||||
|
@ -13,7 +13,7 @@ export class BuildersClubFurniCountMessageParser implements IMessageParser
|
|||||||
|
|
||||||
public parse(wrapper: IMessageDataWrapper): boolean
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
{
|
{
|
||||||
if (!wrapper) return false;
|
if(!wrapper) return false;
|
||||||
|
|
||||||
this._furniCount = wrapper.readInt();
|
this._furniCount = wrapper.readInt();
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user