fix(portal): 修正背包打开时右击回城书生成传送门遮挡、pointerEvents 穿透与城镇变体坐标同步 (#394)

This commit is contained in:
troytt 2026-09-27 05:32:13 +00:00
parent e29d743f38
commit 5c19d92334
2 changed files with 39 additions and 6 deletions

View File

@ -6827,10 +6827,12 @@ async function runScene(initialRuntime: MapRuntime, renderer: SpriteRenderer, st
const here = playerSubTile()
const candidateOffsets = [
{ dx: -2, dy: 2 },
{ dx: -2, dy: 1 },
{ dx: -1, dy: 2 },
{ dx: 0, dy: -2 },
{ dx: 2, dy: -1 },
{ dx: 2, dy: 0 },
{ dx: 0, dy: -2 },
{ dx: -2, dy: 1 },
{ dx: 1, dy: -1 },
{ dx: 0, dy: 0 },
]
@ -7192,12 +7194,34 @@ async function runScene(initialRuntime: MapRuntime, renderer: SpriteRenderer, st
await next.loadPages(renderer, next.priorityPages, () => {
state.pagesLoaded = countLoadedPages(next.pages)
})
let effectiveOverride = override
if (isTownLevel(next.levelId) && next.variant) {
townVariantByAct.set(next.act, next.variant)
const openPortal = portalSlot.current()
if (openPortal !== null && openPortal.townLevelId === next.levelId) {
const exactTownSub = resolveTownPortalSubTile(next.levelId, next.variant)
if (openPortal.townX !== exactTownSub.x || openPortal.townY !== exactTownSub.y) {
const wasHeadingToPortal =
effectiveOverride !== undefined &&
effectiveOverride.x === openPortal.townX &&
effectiveOverride.y === openPortal.townY
portalSlot.cast({
...openPortal,
townX: exactTownSub.x,
townY: exactTownSub.y,
})
if (wasHeadingToPortal) {
effectiveOverride = exactTownSub
}
}
}
}
// The destination's own opening back to where we came from is the landing
// spot; an override wins, because a waypoint or a portal lands somewhere
// that no edge describes.
const back = next.entrances.find(entrance => entrance.toLevelId === fromLevelId)
?? next.warps.find(warp => warp.toLevelId === fromLevelId)
const rawLanding = override
const rawLanding = effectiveOverride
?? (back === undefined
? {
x: Math.floor(next.grid.cellsX * SUB_TILES_PER_TILE / 2),

View File

@ -746,10 +746,17 @@ export class HudManager {
}
}
}
const intercept =
this.isPointInterceptedByHud(this.mouseX, this.mouseY) || this.inventory.cursorItem !== null
this.hudCanvas.style.pointerEvents = intercept ? 'auto' : 'none'
})
window.addEventListener('mousedown', () => {
window.addEventListener('mousedown', (e) => {
this.cursor.handleMouseDown()
if (e.target !== this.hudCanvas && e.target instanceof HTMLCanvasElement) {
handleHudMouseDown(e)
}
})
window.addEventListener('mouseup', () => {
@ -761,7 +768,7 @@ export class HudManager {
e.preventDefault()
})
this.hudCanvas.addEventListener('mousedown', (e) => {
const handleHudMouseDown = (e: MouseEvent): void => {
if (e.button !== 0 && e.button !== 2) return
const pt = this.clientToLogical(e.clientX, e.clientY)
if (!this.isPointInterceptedByHud(pt.x, pt.y)) {
@ -997,7 +1004,9 @@ export class HudManager {
return
}
}
})
}
this.hudCanvas.addEventListener('mousedown', handleHudMouseDown)
}
private handleSkillAllocated(skillId: number): void {