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

Method parse

packages/tilemap/src/loaders/TilemapLoader.ts:63–77  ·  view source on GitHub ↗

* Parse tilemap asset from text content * 从文本内容解析瓦片地图资产

(content: IAssetContent, _context: IAssetParseContext)

Source from the content-addressed store, hash-verified

61 * 从文本内容解析瓦片地图资产
62 */
63 async parse(content: IAssetContent, _context: IAssetParseContext): Promise<ITilemapAsset> {
64 if (!content.text) {
65 throw new Error('Tilemap content is empty');
66 }
67
68 const jsonData = JSON.parse(content.text) as ITilemapAsset;
69
70 // 验证必要字段
71 // Validate required fields
72 if (!jsonData.width || !jsonData.height || !jsonData.data) {
73 throw new Error('Invalid tilemap format: missing required fields');
74 }
75
76 return jsonData;
77 }
78
79 /**
80 * Dispose loaded asset

Callers

nothing calls this directly

Calls 1

parseMethod · 0.65

Tested by

no test coverage detected