feat: load remote map config and constrain tile bounds

This commit is contained in:
2026-03-20 16:19:12 +08:00
parent 8e6291885d
commit 1ecb4809df
8 changed files with 552 additions and 15 deletions

View File

@@ -1,10 +1,12 @@
import { MapEngine, type MapEngineStageRect, type MapEngineViewState } from '../../engine/map/mapEngine'
import { loadRemoteMapConfig } from '../../utils/remoteMapConfig'
type MapPageData = MapEngineViewState & {
showDebugPanel: boolean
}
const INTERNAL_BUILD_VERSION = 'map-build-75'
const INTERNAL_BUILD_VERSION = 'map-build-82'
const REMOTE_GAME_CONFIG_URL = 'https://oss-mbh5.colormaprun.com/wxmini/test/qyds-001/game.json'
let mapEngine: MapEngine | null = null
@@ -36,6 +38,7 @@ Page({
onReady() {
this.measureStageAndCanvas()
this.loadMapConfigFromRemote()
},
onUnload() {
@@ -45,6 +48,33 @@ Page({
}
},
loadMapConfigFromRemote() {
const currentEngine = mapEngine
if (!currentEngine) {
return
}
loadRemoteMapConfig(REMOTE_GAME_CONFIG_URL)
.then((config) => {
if (mapEngine !== currentEngine) {
return
}
currentEngine.applyRemoteMapConfig(config)
})
.catch((error) => {
if (mapEngine !== currentEngine) {
return
}
const errorMessage = error && error.message ? error.message : '未知错误'
this.setData({
configStatusText: `载入失败: ${errorMessage}`,
statusText: `远程地图配置载入失败: ${errorMessage} (${INTERNAL_BUILD_VERSION})`,
})
})
},
measureStageAndCanvas() {
const page = this
const applyStage = (rawRect?: Partial<WechatMiniprogram.BoundingClientRectCallbackResult>) => {
@@ -179,6 +209,18 @@ Page({