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.status.floorId ---------- //
core.drawMap(floorId);
// 设置勇士的位置
heroLoc.direction = core.turnDirection(heroLoc.direction);
core.setHeroLoc('x', heroLoc.x);
core.setHeroLoc('y', heroLoc.y);
core.setHeroLoc('direction', heroLoc.direction);
// ---------- 重绘新地图这一步将会设置core.status.floorId ---------- //
core.drawMap(floorId);
// 切换楼层BGM
if (core.status.maps[floorId].bgm) {
var bgm = core.status.maps[floorId].bgm;

View File

@ -134,17 +134,17 @@ hook.once('reset', () => {
});
hook.on('reset', () => {
Shadow.update(true);
LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite));
LayerShadowExtends.shadowList.forEach(v => v.update());
})
hook.on('setBlock', () => {
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.update();
setCanvasFilterByFloorId(floorId);
LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite));
LayerShadowExtends.shadowList.forEach(v => v.update());
})
// 深度测试着色器
@ -1305,21 +1305,29 @@ export class LayerShadowExtends implements ILayerRenderExtends {
static shadowList: Set<LayerShadowExtends> = new Set();
id: string = 'shadow';
layer!: Layer
hero!: HeroRenderer
sprite!: Sprite;
update() {
this.sprite.update(this.sprite);
}
private onMoveTick = (x: number, y: number) => {
const now = Shadow.now();
if (!now) return;
if (now.followHero.size === 0) return;
if (now.followHero.size === 0) return;
now.followHero.forEach(v => {
now.modifyLight(v, {
x: x * 32 + 16,
y: y * 32 + 16
});
});
now.requestRefresh();
this.sprite.update(this.sprite);
now.requestRefresh();
this.layer.requestAfterFrame(() => {
this.sprite.update(this.sprite);
});
}
private listen() {
@ -1334,6 +1342,7 @@ export class LayerShadowExtends implements ILayerRenderExtends {
return;
}
this.hero = ex as HeroRenderer;
this.layer = layer;
this.listen();
LayerShadowExtends.shadowList.add(this);
this.sprite = new Sprite('static', false);