Merge pull request 'fix(portal): 修正背包打开时右击回城书生成传送门遮挡、pointerEvents 穿透与城镇变体坐标同步 (#394)' (#490) from fix/issue-394-portal-visibility into main
This commit is contained in:
commit
7cc56ed967
|
|
@ -6827,10 +6827,12 @@ async function runScene(initialRuntime: MapRuntime, renderer: SpriteRenderer, st
|
||||||
|
|
||||||
const here = playerSubTile()
|
const here = playerSubTile()
|
||||||
const candidateOffsets = [
|
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: -1 },
|
||||||
{ dx: 2, dy: 0 },
|
{ dx: 2, dy: 0 },
|
||||||
{ dx: 0, dy: -2 },
|
|
||||||
{ dx: -2, dy: 1 },
|
|
||||||
{ dx: 1, dy: -1 },
|
{ dx: 1, dy: -1 },
|
||||||
{ dx: 0, dy: 0 },
|
{ dx: 0, dy: 0 },
|
||||||
]
|
]
|
||||||
|
|
@ -7192,12 +7194,34 @@ async function runScene(initialRuntime: MapRuntime, renderer: SpriteRenderer, st
|
||||||
await next.loadPages(renderer, next.priorityPages, () => {
|
await next.loadPages(renderer, next.priorityPages, () => {
|
||||||
state.pagesLoaded = countLoadedPages(next.pages)
|
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
|
// 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
|
// spot; an override wins, because a waypoint or a portal lands somewhere
|
||||||
// that no edge describes.
|
// that no edge describes.
|
||||||
const back = next.entrances.find(entrance => entrance.toLevelId === fromLevelId)
|
const back = next.entrances.find(entrance => entrance.toLevelId === fromLevelId)
|
||||||
?? next.warps.find(warp => warp.toLevelId === fromLevelId)
|
?? next.warps.find(warp => warp.toLevelId === fromLevelId)
|
||||||
const rawLanding = override
|
const rawLanding = effectiveOverride
|
||||||
?? (back === undefined
|
?? (back === undefined
|
||||||
? {
|
? {
|
||||||
x: Math.floor(next.grid.cellsX * SUB_TILES_PER_TILE / 2),
|
x: Math.floor(next.grid.cellsX * SUB_TILES_PER_TILE / 2),
|
||||||
|
|
|
||||||
|
|
@ -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()
|
this.cursor.handleMouseDown()
|
||||||
|
if (e.target !== this.hudCanvas && e.target instanceof HTMLCanvasElement) {
|
||||||
|
handleHudMouseDown(e)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
window.addEventListener('mouseup', () => {
|
window.addEventListener('mouseup', () => {
|
||||||
|
|
@ -761,7 +768,7 @@ export class HudManager {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.hudCanvas.addEventListener('mousedown', (e) => {
|
const handleHudMouseDown = (e: MouseEvent): void => {
|
||||||
if (e.button !== 0 && e.button !== 2) return
|
if (e.button !== 0 && e.button !== 2) return
|
||||||
const pt = this.clientToLogical(e.clientX, e.clientY)
|
const pt = this.clientToLogical(e.clientX, e.clientY)
|
||||||
if (!this.isPointInterceptedByHud(pt.x, pt.y)) {
|
if (!this.isPointInterceptedByHud(pt.x, pt.y)) {
|
||||||
|
|
@ -997,7 +1004,9 @@ export class HudManager {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
this.hudCanvas.addEventListener('mousedown', handleHudMouseDown)
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleSkillAllocated(skillId: number): void {
|
private handleSkillAllocated(skillId: number): void {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue