* Unload all assets in a block
(blockId: string)
| 111 | * Unload all assets in a block |
| 112 | */ |
| 113 | private unloadBlock(blockId: string): void { |
| 114 | const blocks = Preload.blocks() as PreloadBlocks; |
| 115 | const block = blocks[blockId]; |
| 116 | if (!block) { |
| 117 | console.warn(`Unload: Block "${blockId}" not found`); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | for (const [category, assets] of Object.entries(block)) { |
| 122 | // Handle characters separately (nested structure) |
| 123 | if (category === 'characters' && typeof assets === 'object' && !Array.isArray(assets)) { |
| 124 | for (const [charId, sprites] of Object.entries(assets as Record<string, string[]>)) { |
| 125 | for (const spriteName of sprites) { |
| 126 | this.unloadCharacter(charId, spriteName); |
| 127 | } |
| 128 | } |
| 129 | continue; |
| 130 | } |
| 131 | |
| 132 | if (!Array.isArray(assets)) continue; |
| 133 | |
| 134 | // Use registered loader for this category |
| 135 | if (Preload.hasLoader(category)) { |
| 136 | for (const assetName of assets) { |
| 137 | this.unloadAsset(category, assetName); |
| 138 | } |
| 139 | } else { |
| 140 | console.warn(`Unload: No loader registered for category "${category}" in block "${blockId}"`); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Unload all assets in a category using the registered loader |
no test coverage detected