fix: 显伤层报错

This commit is contained in:
unanmed 2024-12-08 21:32:03 +08:00
parent d535fe82c0
commit dbae5a7c7d
2 changed files with 7 additions and 10 deletions

View File

@ -130,10 +130,8 @@ export class BlockCacher<
if (deep & (1 << i)) { if (deep & (1 << i)) {
const nowIndex = index * this.cacheDepth + i; const nowIndex = index * this.cacheDepth + i;
const item = this.cache.get(nowIndex); const item = this.cache.get(nowIndex);
if (item) { item?.destroy();
item.destroy(); this.cache.delete(nowIndex);
this.cache.delete(nowIndex);
}
} }
} }
} }
@ -141,12 +139,10 @@ export class BlockCacher<
/** /**
* {@link clearCache} ->void * {@link clearCache} ->void
*/ */
clearCacheByIndex(index: number, func: (item: T) => void) { clearCacheByIndex(index: number) {
const item = this.cache.get(index); const item = this.cache.get(index);
if (item) { item?.destroy();
item.destroy(); this.cache.delete(index);
this.cache.delete(index);
}
} }
/** /**

View File

@ -503,7 +503,8 @@ export class Damage extends RenderItem<EDamageEvent> {
this.emit('dirtyUpdate', v); this.emit('dirtyUpdate', v);
// 否则依次渲染并写入缓存 // 否则依次渲染并写入缓存
const temp = cache?.canvas ?? new MotaOffscreenCanvas2D(); const temp =
block.cache.get(v)?.canvas ?? new MotaOffscreenCanvas2D();
temp.clear(); temp.clear();
temp.setHD(true); temp.setHD(true);
temp.setAntiAliasing(true); temp.setAntiAliasing(true);