mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-18 06:26:27 +01:00
More updates
This commit is contained in:
parent
feae4d4542
commit
23c0d29688
@ -10,6 +10,7 @@ export interface IRoomContentLoader
|
||||
{
|
||||
init(): Promise<void>;
|
||||
processFurnitureData(furnitureData: IFurnitureData[]): void;
|
||||
downloadAssetSync(type: string): void
|
||||
downloadAsset(type: string): Promise<void>;
|
||||
isLoaderType(type: string): boolean;
|
||||
getCollection(name: string): IGraphicAssetCollection;
|
||||
|
@ -57,7 +57,7 @@ export class AssetManager implements IAssetManager
|
||||
{
|
||||
if(!name) return null;
|
||||
|
||||
return this._collections.get(name);
|
||||
return this._collections.get(name) ?? null;
|
||||
}
|
||||
|
||||
public createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection
|
||||
|
@ -330,6 +330,54 @@ export class RoomContentLoader implements IRoomContentLoader
|
||||
return false;
|
||||
}
|
||||
|
||||
public downloadAssetSync(type: string): void
|
||||
{
|
||||
const assetUrl: string = this.getAssetUrls(type)?.[0];
|
||||
|
||||
if(!assetUrl || !assetUrl.length) return;
|
||||
|
||||
if((this._pendingContentTypes.indexOf(type) >= 0)) return;
|
||||
|
||||
this._pendingContentTypes.push(type);
|
||||
|
||||
GetAssetManager()
|
||||
.downloadAsset(assetUrl)
|
||||
.then(() =>
|
||||
{
|
||||
const petIndex = this._pets[type];
|
||||
|
||||
if(petIndex !== undefined)
|
||||
{
|
||||
const collection = this.getCollection(type);
|
||||
const keys = collection.getPaletteNames();
|
||||
const palettes: Map<number, IPetColorResult> = new Map();
|
||||
|
||||
for(const key of keys)
|
||||
{
|
||||
const palette = collection.getPalette(key);
|
||||
const paletteData = collection.data.palettes[key];
|
||||
|
||||
const primaryColor = palette.primaryColor;
|
||||
const secondaryColor = palette.secondaryColor;
|
||||
const breed = ((paletteData.breed !== undefined) ? paletteData.breed : 0);
|
||||
const tag = ((paletteData.colorTag !== undefined) ? paletteData.colorTag : -1);
|
||||
const master = ((paletteData.master !== undefined) ? paletteData.master : false);
|
||||
const layerTags = ((paletteData.tags !== undefined) ? paletteData.tags : []);
|
||||
|
||||
palettes.set(parseInt(key), new PetColorResult(primaryColor, secondaryColor, breed, tag, key, master, layerTags));
|
||||
}
|
||||
|
||||
this._petColors.set(petIndex, palettes);
|
||||
}
|
||||
|
||||
GetEventDispatcher().dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_SUCCESS, type));
|
||||
})
|
||||
.catch((err) =>
|
||||
{
|
||||
GetEventDispatcher().dispatchEvent(new RoomContentLoadedEvent(RoomContentLoadedEvent.RCLE_FAILURE, type));
|
||||
});
|
||||
}
|
||||
|
||||
public async downloadAsset(type: string): Promise<void>
|
||||
{
|
||||
const assetUrl: string = this.getAssetUrls(type)?.[0];
|
||||
|
@ -3230,7 +3230,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
|
||||
|
||||
public isRoomContentTypeLoaded(name: string): boolean
|
||||
{
|
||||
return (this._roomContentLoader.getCollection(name) !== null);
|
||||
return !!this._roomContentLoader.getCollection(name);
|
||||
}
|
||||
|
||||
public getPetColorResult(petIndex: number, paletteIndex: number): IPetColorResult
|
||||
|
@ -98,7 +98,7 @@ export class RoomManager implements IRoomManager, IRoomInstanceContainer
|
||||
{
|
||||
isLoading = true;
|
||||
|
||||
GetRoomContentLoader().downloadAsset(type);
|
||||
GetRoomContentLoader().downloadAssetSync(type);
|
||||
|
||||
assetName = GetRoomContentLoader().getPlaceholderName(type);
|
||||
asset = GetRoomContentLoader().getCollection(assetName);
|
||||
|
Loading…
Reference in New Issue
Block a user