You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-20 07:26:18 +00:00
Move to Renderer V2
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { IAssetAnimationAdd } from '@nitrots/api';
|
||||
|
||||
export class AddDataContainer
|
||||
{
|
||||
private _id: string;
|
||||
private _align: string;
|
||||
private _base: string;
|
||||
private _ink: number;
|
||||
private _blend: number;
|
||||
|
||||
constructor(k: IAssetAnimationAdd)
|
||||
{
|
||||
this._id = k.id || '';
|
||||
this._align = k.align || '';
|
||||
this._base = k.base || '';
|
||||
this._ink = k.ink || 0;
|
||||
this._blend = 0;
|
||||
|
||||
const _local_2 = k.blend;
|
||||
|
||||
if(_local_2)
|
||||
{
|
||||
if(_local_2.length > 0)
|
||||
{
|
||||
this._blend = parseInt(_local_2);
|
||||
|
||||
if(this._blend > 1) this._blend = (this._blend / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public get id(): string
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get align(): string
|
||||
{
|
||||
return this._align;
|
||||
}
|
||||
|
||||
public get base(): string
|
||||
{
|
||||
return this._base;
|
||||
}
|
||||
|
||||
public get ink(): number
|
||||
{
|
||||
return this._ink;
|
||||
}
|
||||
|
||||
public get blend(): number
|
||||
{
|
||||
return this._blend;
|
||||
}
|
||||
|
||||
public get isBlended(): boolean
|
||||
{
|
||||
return this._blend !== 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
import { IAnimation, IAssetAnimation, IAssetAnimationFrame } from '@nitrots/api';
|
||||
import { AvatarStructure } from '../AvatarStructure';
|
||||
import { AddDataContainer } from './AddDataContainer';
|
||||
import { AvatarAnimationLayerData } from './AvatarAnimationLayerData';
|
||||
import { AvatarDataContainer } from './AvatarDataContainer';
|
||||
import { DirectionDataContainer } from './DirectionDataContainer';
|
||||
import { SpriteDataContainer } from './SpriteDataContainer';
|
||||
|
||||
export class Animation implements IAnimation
|
||||
{
|
||||
private static EMPTY_ARRAY: any[] = [];
|
||||
|
||||
private _id: string;
|
||||
private _description: string;
|
||||
private _frames: AvatarAnimationLayerData[][];
|
||||
private _spriteData: SpriteDataContainer[];
|
||||
private _avatarData: AvatarDataContainer;
|
||||
private _directionData: DirectionDataContainer;
|
||||
private _removeData: string[];
|
||||
private _addData: AddDataContainer[];
|
||||
private _overriddenActions: Map<string, string>;
|
||||
private _overrideFrames: Map<string, AvatarAnimationLayerData[][]>;
|
||||
private _resetOnToggle: boolean;
|
||||
|
||||
constructor(k: AvatarStructure, _arg_2: IAssetAnimation)
|
||||
{
|
||||
this._id = _arg_2.name;
|
||||
this._description = this._id;
|
||||
this._frames = [];
|
||||
this._spriteData = null;
|
||||
this._avatarData = null;
|
||||
this._directionData = null;
|
||||
this._removeData = null;
|
||||
this._addData = null;
|
||||
this._overriddenActions = null;
|
||||
this._overrideFrames = null;
|
||||
this._resetOnToggle = (_arg_2.resetOnToggle || false);
|
||||
|
||||
if(_arg_2.sprites && _arg_2.sprites.length)
|
||||
{
|
||||
this._spriteData = [];
|
||||
|
||||
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.directions && _arg_2.directions.length) this._directionData = new DirectionDataContainer(_arg_2.directions[0]);
|
||||
|
||||
if(_arg_2.removes && _arg_2.removes.length)
|
||||
{
|
||||
this._removeData = [];
|
||||
|
||||
for(const remove of _arg_2.removes) this._removeData.push(remove.id);
|
||||
}
|
||||
|
||||
if(_arg_2.adds && _arg_2.adds.length)
|
||||
{
|
||||
this._addData = [];
|
||||
|
||||
for(const add of _arg_2.adds) this._addData.push(new AddDataContainer(add));
|
||||
}
|
||||
|
||||
if(_arg_2.overrides && _arg_2.overrides.length)
|
||||
{
|
||||
this._overrideFrames = new Map();
|
||||
this._overriddenActions = new Map();
|
||||
|
||||
for(const override of _arg_2.overrides)
|
||||
{
|
||||
const name = override.name;
|
||||
const value = override.override;
|
||||
|
||||
this._overriddenActions.set(value, name);
|
||||
|
||||
const frames: AvatarAnimationLayerData[][] = [];
|
||||
|
||||
this.parseFrames(frames, override.frames, k);
|
||||
|
||||
this._overrideFrames.set(name, frames);
|
||||
}
|
||||
}
|
||||
|
||||
this.parseFrames(this._frames, _arg_2.frames, k);
|
||||
}
|
||||
|
||||
private parseFrames(frames: AvatarAnimationLayerData[][], _arg_2: IAssetAnimationFrame[], _arg_3: AvatarStructure): void
|
||||
{
|
||||
if(!_arg_2 || !_arg_2.length) return;
|
||||
|
||||
for(const frame of _arg_2)
|
||||
{
|
||||
let repeats = 1;
|
||||
|
||||
if(frame.repeats && (frame.repeats > 1)) repeats = frame.repeats;
|
||||
|
||||
let index = 0;
|
||||
|
||||
while(index < repeats)
|
||||
{
|
||||
const layers: AvatarAnimationLayerData[] = [];
|
||||
|
||||
if(frame.bodyparts && frame.bodyparts.length)
|
||||
{
|
||||
for(const bodyPart of frame.bodyparts)
|
||||
{
|
||||
const definition = _arg_3.getActionDefinition(bodyPart.action);
|
||||
const layer = new AvatarAnimationLayerData(bodyPart, AvatarAnimationLayerData.BODYPART, definition);
|
||||
|
||||
layers.push(layer);
|
||||
}
|
||||
}
|
||||
|
||||
if(frame.fxs && frame.fxs.length)
|
||||
{
|
||||
for(const fx of frame.fxs)
|
||||
{
|
||||
const definition = _arg_3.getActionDefinition(fx.action);
|
||||
const layer = new AvatarAnimationLayerData(fx, AvatarAnimationLayerData.FX, definition);
|
||||
|
||||
layers.push(layer);
|
||||
}
|
||||
}
|
||||
|
||||
frames.push(layers);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public frameCount(k: string = null): number
|
||||
{
|
||||
if(!k) return this._frames.length;
|
||||
|
||||
if(this._overrideFrames)
|
||||
{
|
||||
const _local_2 = this._overrideFrames.get(k);
|
||||
|
||||
if(_local_2) return _local_2.length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public hasOverriddenActions(): boolean
|
||||
{
|
||||
if(!this._overriddenActions) return false;
|
||||
|
||||
return (this._overriddenActions.size > 0);
|
||||
}
|
||||
|
||||
public overriddenActionNames(): string[]
|
||||
{
|
||||
if(!this._overriddenActions) return null;
|
||||
|
||||
const keys: string[] = [];
|
||||
|
||||
for(const key of this._overriddenActions.keys()) keys.push(key);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public overridingAction(k: string): string
|
||||
{
|
||||
if(!this._overriddenActions) return null;
|
||||
|
||||
return this._overriddenActions.get(k);
|
||||
}
|
||||
|
||||
private getFrame(frameCount: number, _arg_2: string = null): AvatarAnimationLayerData[]
|
||||
{
|
||||
if(frameCount < 0) frameCount = 0;
|
||||
|
||||
let layers: AvatarAnimationLayerData[] = [];
|
||||
|
||||
if(!_arg_2)
|
||||
{
|
||||
if(this._frames.length > 0)
|
||||
{
|
||||
layers = this._frames[(frameCount % this._frames.length)];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const overrideLayers = this._overrideFrames.get(_arg_2);
|
||||
|
||||
if(overrideLayers && (overrideLayers.length > 0))
|
||||
{
|
||||
layers = overrideLayers[(frameCount % overrideLayers.length)];
|
||||
}
|
||||
}
|
||||
|
||||
return layers;
|
||||
}
|
||||
|
||||
public getAnimatedBodyPartIds(k: number, _arg_2: string = null): string[]
|
||||
{
|
||||
const _local_3: string[] = [];
|
||||
|
||||
for(const layer of this.getFrame(k, _arg_2))
|
||||
{
|
||||
if(layer.type === AvatarAnimationLayerData.BODYPART)
|
||||
{
|
||||
_local_3.push(layer.id);
|
||||
}
|
||||
|
||||
else if(layer.type === AvatarAnimationLayerData.FX)
|
||||
{
|
||||
if(this._addData && this._addData.length)
|
||||
{
|
||||
for(const _local_5 of this._addData)
|
||||
{
|
||||
if(_local_5.id === layer.id) _local_3.push(_local_5.align);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _local_3;
|
||||
}
|
||||
|
||||
public getLayerData(frameCount: number, spriteId: string, _arg_3: string = null): AvatarAnimationLayerData
|
||||
{
|
||||
for(const layer of this.getFrame(frameCount, _arg_3))
|
||||
{
|
||||
if(layer.id === spriteId) return layer;
|
||||
|
||||
if(layer.type === AvatarAnimationLayerData.FX)
|
||||
{
|
||||
if(this._addData && this._addData.length)
|
||||
{
|
||||
for(const addData of this._addData)
|
||||
{
|
||||
if(((addData.align === spriteId) && (addData.id === layer.id))) return layer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public hasAvatarData(): boolean
|
||||
{
|
||||
return this._avatarData !== null;
|
||||
}
|
||||
|
||||
public hasDirectionData(): boolean
|
||||
{
|
||||
return this._directionData !== null;
|
||||
}
|
||||
|
||||
public hasAddData(): boolean
|
||||
{
|
||||
return this._addData !== null;
|
||||
}
|
||||
|
||||
public getAddData(k: string): AddDataContainer
|
||||
{
|
||||
if(this._addData)
|
||||
{
|
||||
for(const _local_2 of this._addData)
|
||||
{
|
||||
if(_local_2.id === k) return _local_2;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public get id(): string
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get spriteData(): SpriteDataContainer[]
|
||||
{
|
||||
return this._spriteData || Animation.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public get avatarData(): AvatarDataContainer
|
||||
{
|
||||
return this._avatarData;
|
||||
}
|
||||
|
||||
public get directionData(): DirectionDataContainer
|
||||
{
|
||||
return this._directionData;
|
||||
}
|
||||
|
||||
public get removeData(): string[]
|
||||
{
|
||||
return this._removeData || Animation.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public get addData(): AddDataContainer[]
|
||||
{
|
||||
return this._addData || Animation.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public toString(): string
|
||||
{
|
||||
return this._description;
|
||||
}
|
||||
|
||||
public get resetOnToggle(): boolean
|
||||
{
|
||||
return this._resetOnToggle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { IAnimation, IAnimationLayerData, IAnimationManager, IAssetAnimation } from '@nitrots/api';
|
||||
import { AvatarStructure } from '../AvatarStructure';
|
||||
import { Animation } from './Animation';
|
||||
|
||||
export class AnimationManager implements IAnimationManager
|
||||
{
|
||||
private _animations: Map<string, Animation>;
|
||||
|
||||
constructor()
|
||||
{
|
||||
this._animations = new Map();
|
||||
}
|
||||
|
||||
public registerAnimation(structure: AvatarStructure, _arg_2: { [index: string]: IAssetAnimation }): boolean
|
||||
{
|
||||
if(!_arg_2) return false;
|
||||
|
||||
const animationData = _arg_2[Object.keys(_arg_2)[0]];
|
||||
|
||||
const animation = new Animation(structure, animationData);
|
||||
|
||||
this._animations.set(animationData.name, animation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public getAnimation(animation: string): Animation
|
||||
{
|
||||
const existing = this._animations.get(animation);
|
||||
|
||||
if(!existing) return null;
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
public getLayerData(animation: string, frameCount: number, spriteId: string): IAnimationLayerData
|
||||
{
|
||||
const existing = this.getAnimation(animation);
|
||||
|
||||
if(!existing) return null;
|
||||
|
||||
return existing.getLayerData(frameCount, spriteId);
|
||||
}
|
||||
|
||||
public get animations(): Map<string, IAnimation>
|
||||
{
|
||||
return this._animations;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { IActionDefinition, IActiveActionData, IAnimationLayerData, IAssetAnimationFramePart } from '@nitrots/api';
|
||||
import { ActiveActionData } from '../actions';
|
||||
|
||||
export class AvatarAnimationLayerData implements IAnimationLayerData
|
||||
{
|
||||
public static BODYPART: string = 'bodypart';
|
||||
public static FX: string = 'fx';
|
||||
|
||||
private _id: string;
|
||||
private _action: IActiveActionData;
|
||||
private _animationFrame: number;
|
||||
private _dx: number;
|
||||
private _dy: number;
|
||||
private _dz: number;
|
||||
private _directionOffset: number;
|
||||
private _type: string;
|
||||
private _base: string;
|
||||
private _items: Map<string, string>;
|
||||
|
||||
constructor(k: IAssetAnimationFramePart, _arg_2: string, _arg_3: IActionDefinition)
|
||||
{
|
||||
this._id = k.id;
|
||||
this._animationFrame = (k.frame || 0);
|
||||
this._dx = (k.dx || 0);
|
||||
this._dy = (k.dy || 0);
|
||||
this._dz = (k.dz || 0);
|
||||
this._directionOffset = (k.dd || 0);
|
||||
this._type = _arg_2;
|
||||
this._base = (k.base || '');
|
||||
this._items = new Map();
|
||||
|
||||
if(k.items) for(const _local_4 of k.items) this._items.set(_local_4.id, _local_4.base);
|
||||
|
||||
let _local_5 = '';
|
||||
|
||||
if(this._base !== '') _local_5 = this.baseAsInt().toString();
|
||||
|
||||
if(_arg_3)
|
||||
{
|
||||
this._action = new ActiveActionData(_arg_3.state, this.base);
|
||||
this._action.definition = _arg_3;
|
||||
}
|
||||
}
|
||||
|
||||
public get items(): Map<string, string>
|
||||
{
|
||||
return this._items;
|
||||
}
|
||||
|
||||
private baseAsInt(): number
|
||||
{
|
||||
let k = 0;
|
||||
let index = 0;
|
||||
|
||||
while(index < this._base.length)
|
||||
{
|
||||
k = (k + this._base.charCodeAt(index));
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
public get id(): string
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get animationFrame(): number
|
||||
{
|
||||
return this._animationFrame;
|
||||
}
|
||||
|
||||
public get dx(): number
|
||||
{
|
||||
return this._dx;
|
||||
}
|
||||
|
||||
public get dy(): number
|
||||
{
|
||||
return this._dy;
|
||||
}
|
||||
|
||||
public get dz(): number
|
||||
{
|
||||
return this._dz;
|
||||
}
|
||||
|
||||
public get dd(): number
|
||||
{
|
||||
return this._directionOffset;
|
||||
}
|
||||
|
||||
public get type(): string
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public get base(): string
|
||||
{
|
||||
return this._base;
|
||||
}
|
||||
|
||||
public get action(): IActiveActionData
|
||||
{
|
||||
return this._action;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import { IAssetAnimationAvatar, IAvatarDataContainer } from '@nitrots/api';
|
||||
import { AdjustmentFilter } from 'pixi-filters';
|
||||
|
||||
export class AvatarDataContainer implements IAvatarDataContainer
|
||||
{
|
||||
private _ink: number;
|
||||
private _foreGround: number;
|
||||
private _backGround: number;
|
||||
private _colorTransform: AdjustmentFilter;
|
||||
private _rgb: number;
|
||||
private _r: number;
|
||||
private _g: number;
|
||||
private _b: number;
|
||||
private _redMultiplier: number;
|
||||
private _greenMultiplier: number;
|
||||
private _blueMultiplier: number;
|
||||
private _alphaMultiplier: number;
|
||||
private _colorMap: Map<string, number[]>;
|
||||
private _paletteIsGrayscale: boolean;
|
||||
|
||||
constructor(k: IAssetAnimationAvatar)
|
||||
{
|
||||
this._ink = k.ink;
|
||||
|
||||
let foreground = k.foreground;
|
||||
let background = k.background;
|
||||
|
||||
foreground = foreground.replace('#', '');
|
||||
background = background.replace('#', '');
|
||||
|
||||
this._foreGround = parseInt(foreground, 16);
|
||||
this._backGround = parseInt(background, 16);
|
||||
this._colorTransform = null;
|
||||
this._rgb = parseInt(foreground, 16);
|
||||
this._r = ((this._rgb >> 16) & 0xFF);
|
||||
this._g = ((this._rgb >> 8) & 0xFF);
|
||||
this._b = ((this._rgb >> 0) & 0xFF);
|
||||
this._redMultiplier = ((this._r / 0xFF) * 1);
|
||||
this._greenMultiplier = ((this._g / 0xFF) * 1);
|
||||
this._blueMultiplier = ((this._b / 0xFF) * 1);
|
||||
this._alphaMultiplier = 1;
|
||||
this._paletteIsGrayscale = true;
|
||||
|
||||
if(this._ink === 37)
|
||||
{
|
||||
this._alphaMultiplier = 0.5;
|
||||
this._paletteIsGrayscale = false;
|
||||
}
|
||||
|
||||
this._colorTransform = new AdjustmentFilter({ red: (this._r / 255), green: (this._g / 255), blue: (this._b / 255), alpha: this._alphaMultiplier });
|
||||
this._colorMap = this.generatePaletteMapForGrayscale(this._backGround, this._foreGround);
|
||||
}
|
||||
|
||||
public get ink(): number
|
||||
{
|
||||
return this._ink;
|
||||
}
|
||||
|
||||
public get colorTransform(): AdjustmentFilter
|
||||
{
|
||||
return this._colorTransform;
|
||||
}
|
||||
|
||||
public get reds(): number[]
|
||||
{
|
||||
return this._colorMap.get('reds');
|
||||
}
|
||||
|
||||
public get greens(): number[]
|
||||
{
|
||||
return this._colorMap.get('greens');
|
||||
}
|
||||
|
||||
public get blues(): number[]
|
||||
{
|
||||
return this._colorMap.get('blues');
|
||||
}
|
||||
|
||||
public get alphas(): number[]
|
||||
{
|
||||
return this._colorMap.get('alphas');
|
||||
}
|
||||
|
||||
public get paletteIsGrayscale(): boolean
|
||||
{
|
||||
return this._paletteIsGrayscale;
|
||||
}
|
||||
|
||||
private generatePaletteMapForGrayscale(background: number, foreground: number): Map<string, number[]>
|
||||
{
|
||||
const alphaBackground = ((background >> 24) & 0xFF);
|
||||
const redBackground = ((background >> 16) & 0xFF);
|
||||
const greenBackground = ((background >> 8) & 0xFF);
|
||||
const blueBackground = ((background >> 0) & 0xFF);
|
||||
const alphaForeground = ((foreground >> 24) & 0xFF);
|
||||
const redForeground = ((foreground >> 16) & 0xFF);
|
||||
const greenForeground = ((foreground >> 8) & 0xFF);
|
||||
const blueForeground = ((foreground >> 0) & 0xFF);
|
||||
const alphaDifference = ((alphaForeground - alphaBackground) / 0xFF);
|
||||
const redDifference = ((redForeground - redBackground) / 0xFF);
|
||||
const greenDifference = ((greenForeground - greenBackground) / 0xFF);
|
||||
const blueDifference = ((blueForeground - blueBackground) / 0xFF);
|
||||
const _local_15: Map<string, number[]> = new Map();
|
||||
const _local_16: number[] = [];
|
||||
const _local_17: number[] = [];
|
||||
const _local_18: number[] = [];
|
||||
const _local_19: number[] = [];
|
||||
let _local_20 = alphaBackground;
|
||||
let _local_21 = redBackground;
|
||||
let _local_22 = greenBackground;
|
||||
let _local_23 = blueBackground;
|
||||
|
||||
for(let i = 0; i < 256; i++)
|
||||
{
|
||||
if((((_local_21 == redBackground) && (_local_22 == greenBackground)) && (_local_23 == blueBackground)))
|
||||
{
|
||||
_local_20 = 0;
|
||||
}
|
||||
_local_20 = (_local_20 + alphaDifference);
|
||||
_local_21 = (_local_21 + redDifference);
|
||||
_local_22 = (_local_22 + greenDifference);
|
||||
_local_23 = (_local_23 + blueDifference);
|
||||
_local_19.push((_local_20 << 24));
|
||||
_local_16.push(((((_local_20 << 24) | (_local_21 << 16)) | (_local_22 << 8)) | _local_23));
|
||||
_local_17.push(((((_local_20 << 24) | (_local_21 << 16)) | (_local_22 << 8)) | _local_23));
|
||||
_local_18.push(((((_local_20 << 24) | (_local_21 << 16)) | (_local_22 << 8)) | _local_23));
|
||||
}
|
||||
|
||||
_local_15.set('alphas', _local_16);
|
||||
_local_15.set('reds', _local_16);
|
||||
_local_15.set('greens', _local_17);
|
||||
_local_15.set('blues', _local_18);
|
||||
|
||||
return _local_15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { IAssetAnimationDirection } from '@nitrots/api';
|
||||
|
||||
export class DirectionDataContainer
|
||||
{
|
||||
private _offset: number;
|
||||
|
||||
constructor(k: IAssetAnimationDirection)
|
||||
{
|
||||
this._offset = k.offset;
|
||||
}
|
||||
|
||||
public get offset(): number
|
||||
{
|
||||
return this._offset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import { IAnimation, IAssetAnimationSprite, ISpriteDataContainer } from '@nitrots/api';
|
||||
|
||||
export class SpriteDataContainer implements ISpriteDataContainer
|
||||
{
|
||||
private _animation: IAnimation;
|
||||
private _id: string;
|
||||
private _ink: number;
|
||||
private _member: string;
|
||||
private _hasDirections: boolean;
|
||||
private _hasStaticY: boolean;
|
||||
private _dx: number[];
|
||||
private _dy: number[];
|
||||
private _dz: number[];
|
||||
|
||||
constructor(k: IAnimation, _arg_2: IAssetAnimationSprite)
|
||||
{
|
||||
this._animation = k;
|
||||
this._id = _arg_2.id;
|
||||
this._ink = _arg_2.ink;
|
||||
this._member = _arg_2.member;
|
||||
this._hasStaticY = _arg_2.staticY ? true : false;
|
||||
this._hasDirections = _arg_2.directions ? true : false;
|
||||
this._dx = [];
|
||||
this._dy = [];
|
||||
this._dz = [];
|
||||
|
||||
const directions = _arg_2.directionList;
|
||||
|
||||
if(directions && directions.length)
|
||||
{
|
||||
for(const direction of directions)
|
||||
{
|
||||
const id = direction.id;
|
||||
|
||||
if(id === undefined) continue;
|
||||
|
||||
this._dx[id] = (direction.dx || 0);
|
||||
this._dy[id] = (direction.dy || 0);
|
||||
this._dz[id] = (direction.dz || 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getDirectionOffsetX(k: number): number
|
||||
{
|
||||
if(k < this._dx.length) return this._dx[k];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public getDirectionOffsetY(k: number): number
|
||||
{
|
||||
if(k < this._dy.length) return this._dy[k];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public getDirectionOffsetZ(k: number): number
|
||||
{
|
||||
if(k < this._dz.length) return this._dz[k];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public get animation(): IAnimation
|
||||
{
|
||||
return this._animation;
|
||||
}
|
||||
|
||||
public get id(): string
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get ink(): number
|
||||
{
|
||||
return this._ink;
|
||||
}
|
||||
|
||||
public get member(): string
|
||||
{
|
||||
return this._member;
|
||||
}
|
||||
|
||||
public get hasDirections(): boolean
|
||||
{
|
||||
return this._hasDirections;
|
||||
}
|
||||
|
||||
public get hasStaticY(): boolean
|
||||
{
|
||||
return this._hasStaticY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from './AddDataContainer';
|
||||
export * from './Animation';
|
||||
export * from './AnimationManager';
|
||||
export * from './AvatarAnimationLayerData';
|
||||
export * from './AvatarDataContainer';
|
||||
export * from './DirectionDataContainer';
|
||||
export * from './SpriteDataContainer';
|
||||
Reference in New Issue
Block a user