Load map data inside a composable instead of Pinia store
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user