MCPcopy Create free account
hub / github.com/esengine/esengine / AssetManager

Class AssetManager

packages/asset-system/src/core/AssetManager.ts:50–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 * 资产管理器实现
49 */
50export class AssetManager implements IAssetManager {
51 private readonly _assets = new Map<AssetGUID, AssetEntry>();
52 private readonly _handleToGuid = new Map<AssetHandle, AssetGUID>();
53 private readonly _pathToGuid = new Map<string, AssetGUID>();
54 private readonly _cache: AssetCache;
55 private readonly _loadQueue: IAssetLoadQueue;
56 private readonly _loaderFactory: IAssetLoaderFactory;
57 private readonly _database: AssetDatabase;
58
59 /** Asset reader for file operations. | 用于文件操作的资产读取器。 */
60 private _reader: IAssetReader | null = null;
61
62 private _nextHandle: AssetHandle = 1;
63
64 private _statistics = {
65 loadedCount: 0,
66 failedCount: 0
67 };
68
69 private _isDisposed = false;
70 private _loadingCount = 0;
71
72 constructor(catalog?: IAssetCatalog) {
73 this._cache = new AssetCache();
74 this._loadQueue = new AssetLoadQueue();
75 this._loaderFactory = new AssetLoaderFactory();
76 this._database = new AssetDatabase();
77
78 if (catalog) {
79 this.initializeFromCatalog(catalog);
80 }
81 }
82
83 /**
84 * Set asset reader.
85 * 设置资产读取器。
86 */
87 setReader(reader: IAssetReader): void {
88 this._reader = reader;
89 }
90
91 /**
92 * Set project root path for resolving relative paths.
93 * 设置项目根路径用于解析相对路径。
94 */
95 setProjectRoot(path: string): void {
96 this._database.setProjectRoot(path);
97 }
98
99 /**
100 * Get the asset database.
101 * 获取资产数据库。
102 */
103 getDatabase(): AssetDatabase {
104 return this._database;
105 }
106
107 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected