fix: 道具显伤

This commit is contained in:
unanmed 2024-10-03 17:00:53 +08:00
parent 3baee32c51
commit 970600f97b
4 changed files with 10 additions and 4 deletions

View File

@ -496,11 +496,13 @@ export class Damage extends Sprite<EDamageEvent> {
// todo: 是否真的需要缓存 // todo: 是否真的需要缓存
// 检查有没有缓存 // 检查有没有缓存
const cache = block.cache.get(v * block.cacheDepth); const cache = block.cache.get(v);
if (cache && cache.symbol === cache.canvas.symbol) { if (cache && cache.symbol === cache.canvas.symbol) {
ctx.drawImage(cache.canvas.canvas, px, py, size, size); ctx.drawImage(cache.canvas.canvas, px, py, size, size);
return; return;
} }
this.updateBlock(v, true);
this.emit('dirtyUpdate', v); this.emit('dirtyUpdate', v);
// 否则依次渲染并写入缓存 // 否则依次渲染并写入缓存
@ -512,7 +514,10 @@ export class Damage extends Sprite<EDamageEvent> {
temp.size(size, size); temp.size(size, size);
const { ctx: ct } = temp; const { ctx: ct } = temp;
ct.translate(-px, -py);
const render = this.renderable.get(v); const render = this.renderable.get(v);
render?.forEach(v => { render?.forEach(v => {
if (!v) return; if (!v) return;
ct.fillStyle = v.color; ct.fillStyle = v.color;

View File

@ -341,8 +341,8 @@ export function calNeedRenderOf(
const [px3, py3] = Transform.untransformed(transform, w - 1, h - 1); const [px3, py3] = Transform.untransformed(transform, w - 1, h - 1);
const [px4, py4] = Transform.untransformed(transform, 0, h - 1); const [px4, py4] = Transform.untransformed(transform, 0, h - 1);
const maxX = block.width * cell; const maxX = block.width * cell - 1;
const maxY = block.height * cell; const maxY = block.height * cell - 1;
const res: Set<number> = new Set(); const res: Set<number> = new Set();
// 实际上不太可能一次性渲染非常多的图块,因此不需要非常细致地算出所有的格点,整体包含即可 // 实际上不太可能一次性渲染非常多的图块,因此不需要非常细致地算出所有的格点,整体包含即可

View File

@ -690,6 +690,7 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
if ( if (
block && block &&
block.event.noPass && block.event.noPass &&
block.event.cls !== 'enemys' &&
block.id !== 141 && block.id !== 141 &&
block.id !== 151 block.id !== 151
) { ) {

View File

@ -100,7 +100,7 @@ export class FloorItemDetail implements ILayerGroupRenderExtends {
// 预留blockData // 预留blockData
const [x, y] = this.sprite.block.getBlockXY(width, height); const [x, y] = this.sprite.block.getBlockXY(width, height);
const num = x * y; const num = x * y;
for (let i = 0; i < num; i++) { for (let i = 0; i <= num; i++) {
this.blockData.set(i, new Map()); this.blockData.set(i, new Map());
this.detailData.set(i, new Map()); this.detailData.set(i, new Map());
this.dirtyBlock.add(i); this.dirtyBlock.add(i);