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

Method unloadCharacter

src/actions/Unload.ts:85–108  ·  view source on GitHub ↗

* Unload a character sprite or all sprites for a character * Uses the registered 'image' loader

(characterId: string, spriteName?: string)

Source from the content-addressed store, hash-verified

83 * Uses the registered 'image' loader
84 */
85 private unloadCharacter(characterId: string, spriteName?: string): void {
86 const loaderConfig = Preload.getLoader('image');
87 if (!loaderConfig) {
88 console.warn(`Unload: Image loader not registered`);
89 return;
90 }
91
92 if (spriteName) {
93 // Unload single sprite
94 if (!loaderConfig.cache.delete) {
95 console.warn(`Unload: Image loader does not support delete operation`);
96 return;
97 }
98 const cacheKey = `characters/${characterId}/${spriteName}`;
99 loaderConfig.cache.delete(this.engine, cacheKey);
100 } else {
101 // Unload all sprites for this character
102 if (!loaderConfig.cache.clear) {
103 console.warn(`Unload: Image loader does not support clear operation`);
104 return;
105 }
106 loaderConfig.cache.clear(this.engine, `characters/${characterId}/`);
107 }
108 }
109
110 /**
111 * Unload all assets in a block

Callers 2

unloadBlockMethod · 0.95
applyMethod · 0.95

Calls 2

getLoaderMethod · 0.80
clearMethod · 0.65

Tested by

no test coverage detected