fix: 光影地图更新

This commit is contained in:
unanmed 2024-08-27 00:23:00 +08:00
parent 27923851bd
commit 8440f222ac
2 changed files with 20 additions and 10 deletions

View File

@ -136,15 +136,16 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
// 重置画布尺寸 // 重置画布尺寸
core.maps.resizeMap(floorId); core.maps.resizeMap(floorId);
// ---------- 重绘新地图这一步将会设置core.status.floorId ---------- //
core.drawMap(floorId);
// 设置勇士的位置 // 设置勇士的位置
heroLoc.direction = core.turnDirection(heroLoc.direction); heroLoc.direction = core.turnDirection(heroLoc.direction);
core.setHeroLoc('x', heroLoc.x); core.setHeroLoc('x', heroLoc.x);
core.setHeroLoc('y', heroLoc.y); core.setHeroLoc('y', heroLoc.y);
core.setHeroLoc('direction', heroLoc.direction); core.setHeroLoc('direction', heroLoc.direction);
// ---------- 重绘新地图这一步将会设置core.status.floorId ---------- //
core.drawMap(floorId);
// 切换楼层BGM // 切换楼层BGM
if (core.status.maps[floorId].bgm) { if (core.status.maps[floorId].bgm) {
var bgm = core.status.maps[floorId].bgm; var bgm = core.status.maps[floorId].bgm;

View File

@ -134,17 +134,17 @@ hook.once('reset', () => {
}); });
hook.on('reset', () => { hook.on('reset', () => {
Shadow.update(true); Shadow.update(true);
LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite)); LayerShadowExtends.shadowList.forEach(v => v.update());
}) })
hook.on('setBlock', () => { hook.on('setBlock', () => {
Shadow.update(true); Shadow.update(true);
LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite)); LayerShadowExtends.shadowList.forEach(v => v.update());
}) })
hook.on('changingFloor', floorId => { hook.on('changingFloor', floorId => {
Shadow.clearBuffer(); Shadow.clearBuffer();
Shadow.update(); Shadow.update();
setCanvasFilterByFloorId(floorId); setCanvasFilterByFloorId(floorId);
LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite)); LayerShadowExtends.shadowList.forEach(v => v.update());
}) })
// 深度测试着色器 // 深度测试着色器
@ -1305,9 +1305,14 @@ export class LayerShadowExtends implements ILayerRenderExtends {
static shadowList: Set<LayerShadowExtends> = new Set(); static shadowList: Set<LayerShadowExtends> = new Set();
id: string = 'shadow'; id: string = 'shadow';
layer!: Layer
hero!: HeroRenderer hero!: HeroRenderer
sprite!: Sprite; sprite!: Sprite;
update() {
this.sprite.update(this.sprite);
}
private onMoveTick = (x: number, y: number) => { private onMoveTick = (x: number, y: number) => {
const now = Shadow.now(); const now = Shadow.now();
if (!now) return; if (!now) return;
@ -1319,7 +1324,10 @@ export class LayerShadowExtends implements ILayerRenderExtends {
}); });
}); });
now.requestRefresh(); now.requestRefresh();
this.layer.requestAfterFrame(() => {
this.sprite.update(this.sprite); this.sprite.update(this.sprite);
});
} }
private listen() { private listen() {
@ -1334,6 +1342,7 @@ export class LayerShadowExtends implements ILayerRenderExtends {
return; return;
} }
this.hero = ex as HeroRenderer; this.hero = ex as HeroRenderer;
this.layer = layer;
this.listen(); this.listen();
LayerShadowExtends.shadowList.add(this); LayerShadowExtends.shadowList.add(this);
this.sprite = new Sprite('static', false); this.sprite = new Sprite('static', false);