MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / unloadBlock

Method unloadBlock

src/actions/Unload.ts:113–143  ·  view source on GitHub ↗

* Unload all assets in a block

(blockId: string)

Source from the content-addressed store, hash-verified

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

Callers 1

applyMethod · 0.95

Calls 4

unloadCharacterMethod · 0.95
unloadAssetMethod · 0.95
blocksMethod · 0.80
hasLoaderMethod · 0.80

Tested by

no test coverage detected