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

Method apply

src/actions/Unload.ts:202–248  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

200 }
201
202 override async apply(): Promise<void> {
203 if (this.isAll) {
204 // Clear all memory caches
205 this.engine.clearAllCaches();
206
207 // If permanent, also clear IndexedDB
208 if (this.isPermanent) {
209 await this.engine.clearAudioBufferPersistent();
210 }
211 } else if (this.isBlock) {
212 // Unload block from memory
213 this.unloadBlock(this.blockId);
214
215 // If permanent, also clear audio assets from IndexedDB
216 if (this.isPermanent) {
217 const blocks = Preload.blocks() as PreloadBlocks;
218 const block = blocks[this.blockId];
219 if (block) {
220 for (const [category, assets] of Object.entries(block)) {
221 if (this.isAudioCategory(category) && Array.isArray(assets)) {
222 for (const assetName of assets) {
223 await this.unloadPersistent(category, assetName);
224 }
225 }
226 }
227 }
228 }
229 } else if (this.isCategoryOnly) {
230 // Unload entire category from memory
231 this.unloadCategoryAssets(this.category);
232
233 if (this.isPermanent) {
234 await this.unloadPersistent(this.category);
235 }
236 } else if (this.category === 'characters') {
237 this.unloadCharacter(this.characterId, this.assetName || undefined);
238 } else if (Preload.hasLoader(this.category)) {
239 // Unload single asset from memory
240 this.unloadAsset(this.category, this.assetName);
241
242 if (this.isPermanent) {
243 await this.unloadPersistent(this.category, this.assetName);
244 }
245 } else {
246 console.warn(`Unload: No loader registered for category "${this.category}"`);
247 }
248 }
249
250 override async didApply(): Promise<ActionApplyResult> {
251 return { advance: true };

Callers

nothing calls this directly

Calls 10

unloadBlockMethod · 0.95
isAudioCategoryMethod · 0.95
unloadPersistentMethod · 0.95
unloadCategoryAssetsMethod · 0.95
unloadCharacterMethod · 0.95
unloadAssetMethod · 0.95
clearAllCachesMethod · 0.80
blocksMethod · 0.80
hasLoaderMethod · 0.80

Tested by

no test coverage detected