You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 23:16:20 +00:00
Move to Renderer V2
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { IAssetAlias } from '@nitrots/api';
|
||||
|
||||
export class AssetAlias
|
||||
{
|
||||
private _name: string;
|
||||
private _link: string;
|
||||
private _flipH: boolean;
|
||||
private _flipV: boolean;
|
||||
|
||||
constructor(name: string, alias: IAssetAlias)
|
||||
{
|
||||
this._name = name;
|
||||
this._link = alias.link;
|
||||
this._flipH = alias.flipH;
|
||||
this._flipV = alias.flipV;
|
||||
}
|
||||
|
||||
public get name(): string
|
||||
{
|
||||
return this._name;
|
||||
}
|
||||
|
||||
public get link(): string
|
||||
{
|
||||
return this._link;
|
||||
}
|
||||
|
||||
public get flipH(): boolean
|
||||
{
|
||||
return this._flipH;
|
||||
}
|
||||
|
||||
public get flipV(): boolean
|
||||
{
|
||||
return this._flipV;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { IAssetManager, IGraphicAsset } from '@nitrots/api';
|
||||
import { AvatarRenderManager } from '../AvatarRenderManager';
|
||||
import { AssetAlias } from './AssetAlias';
|
||||
|
||||
export class AssetAliasCollection
|
||||
{
|
||||
private _assets: IAssetManager;
|
||||
private _aliases: Map<string, AssetAlias>;
|
||||
private _avatarRenderManager: AvatarRenderManager;
|
||||
private _missingAssetNames: string[];
|
||||
|
||||
constructor(k: AvatarRenderManager, _arg_2: IAssetManager)
|
||||
{
|
||||
this._avatarRenderManager = k;
|
||||
this._aliases = new Map();
|
||||
this._assets = _arg_2;
|
||||
this._missingAssetNames = [];
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
this._assets = null;
|
||||
this._aliases = null;
|
||||
}
|
||||
|
||||
public reset(): void
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
public init(): void
|
||||
{
|
||||
for(const collection of this._assets.collections.values())
|
||||
{
|
||||
if(!collection) continue;
|
||||
|
||||
const aliases = collection.data && collection.data.aliases;
|
||||
|
||||
if(!aliases) continue;
|
||||
|
||||
for(const name in aliases)
|
||||
{
|
||||
const alias = aliases[name];
|
||||
|
||||
if(!alias) continue;
|
||||
|
||||
this._aliases.set(name, new AssetAlias(name, alias));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public hasAlias(k: string): boolean
|
||||
{
|
||||
const alias = this._aliases.get(k);
|
||||
|
||||
if(alias) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public getAssetName(k: string): string
|
||||
{
|
||||
let _local_2 = k;
|
||||
let _local_3 = 5;
|
||||
|
||||
while(this.hasAlias(_local_2) && (_local_3 >= 0))
|
||||
{
|
||||
const _local_4 = this._aliases.get(_local_2);
|
||||
|
||||
_local_2 = _local_4.link;
|
||||
_local_3--;
|
||||
}
|
||||
|
||||
return _local_2;
|
||||
}
|
||||
|
||||
public getAsset(name: string): IGraphicAsset
|
||||
{
|
||||
if(!this._assets) return null;
|
||||
|
||||
name = this.getAssetName(name);
|
||||
|
||||
const asset = this._assets.getAsset(name);
|
||||
|
||||
if(!asset) return null;
|
||||
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './AssetAlias';
|
||||
export * from './AssetAliasCollection';
|
||||
Reference in New Issue
Block a user