Load map data inside a composable instead of Pinia store

This commit is contained in:
2025-01-25 02:38:40 +01:00
parent 807bc2066e
commit 7a51323682
14 changed files with 120 additions and 125 deletions

View File

@ -0,0 +1,31 @@
import type { Map } from '@/application/types'
import { ref } from 'vue'
const currentMap = ref<Map | null>(null)
export function useMapEditorComposable() {
const loadMap = (map: Map) => {
currentMap.value = map
}
const updateProperty = <K extends keyof Map>(property: K, value: Map[K]) => {
if (currentMap.value) {
currentMap.value[property] = value
}
}
const clearMap = () => {
if (!currentMap.value) return
currentMap.value.placedMapObjects = []
currentMap.value.mapEventTiles = []
currentMap.value.tiles = []
}
return {
currentMap,
loadMap,
updateProperty,
clearMap
}
}