mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-10 15:34:30 +08:00
feat: 勇士贴图打包
This commit is contained in:
1 parent
efe6931799
commit
37cd85cd1e
9 files changed
+154
-232
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { ITexture } from '@motajs/render-assets';
|
||||
import { materials } from './ins';
|
||||
import { IBlockIdentifier, IIndexedIdentifier } from './types';
|
||||
|
||||
@@ -118,8 +119,16 @@ export function fallbackLoad() {
|
||||
addAutotile(autotileSet, floor.fg2map);
|
||||
});
|
||||
|
||||
const heroTextures: ITexture[] = [];
|
||||
|
||||
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.heroImages.forEach(v => {
|
||||
const tex = materials.getImageByAlias(v);
|
||||
if (tex) heroTextures.push(tex);
|
||||
});
|
||||
|
||||
materials.buildAssets();
|
||||
|
||||
materials.cacheAutotileList(autotileSet);
|
||||
materials.cacheTilesetList(tilesetSet);
|
||||
materials.buildListToAsset(heroTextures);
|
||||
}
|
||||
@@ -430,13 +430,32 @@ export class MaterialManager implements IMaterialManager {
|
||||
return [];
|
||||
}
|
||||
this.built = true;
|
||||
const data = this.assetBuilder.addTextureList(this.tileStore.values());
|
||||
return this.buildListToAsset(this.tileStore.values());
|
||||
}
|
||||
|
||||
buildToAsset(texture: ITexture): IMaterialAssetData {
|
||||
const data = this.assetBuilder.addTexture(texture);
|
||||
const assetData: IMaterialAssetData = {
|
||||
data: data,
|
||||
identifier: data.index,
|
||||
alias: `asset-${data.index}`,
|
||||
store: this.assetStore
|
||||
};
|
||||
this.checkAssetDirty(data);
|
||||
return assetData;
|
||||
}
|
||||
|
||||
buildListToAsset(
|
||||
texture: Iterable<ITexture>
|
||||
): Iterable<IMaterialAssetData> {
|
||||
const data = this.assetBuilder.addTextureList(texture);
|
||||
const arr = [...data];
|
||||
const res: IMaterialAssetData[] = [];
|
||||
arr.forEach(v => {
|
||||
const alias = `asset-${v.index}`;
|
||||
this.assetStore.alias(v.index, alias);
|
||||
this.assetDataStore.set(v.index, v);
|
||||
if (!this.assetDataStore.has(v.index)) {
|
||||
this.assetDataStore.set(v.index, v);
|
||||
}
|
||||
const data: IMaterialAssetData = {
|
||||
data: v,
|
||||
identifier: v.index,
|
||||
@@ -448,6 +467,9 @@ export class MaterialManager implements IMaterialManager {
|
||||
}
|
||||
res.push(data);
|
||||
});
|
||||
arr.forEach(v => {
|
||||
this.checkAssetDirty(v);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -397,6 +397,18 @@ export interface IMaterialManager
|
||||
*/
|
||||
buildAssets(): Iterable<IMaterialAssetData>;
|
||||
|
||||
/**
|
||||
* 将指定贴图打包进图集
|
||||
* @param texture 贴图对象
|
||||
*/
|
||||
buildToAsset(texture: ITexture): IMaterialAssetData;
|
||||
|
||||
/**
|
||||
* 将一系列贴图打包进贴图对象
|
||||
* @param texture 贴图列表
|
||||
*/
|
||||
buildListToAsset(texture: Iterable<ITexture>): Iterable<IMaterialAssetData>;
|
||||
|
||||
/**
|
||||
* 根据图块标识符在图集中获取对应的可渲染对象
|
||||
* @param identifier 图块标识符,即图块数字
|
||||
|
||||
Reference in new issue
Block a user