forked from noxious/client
32 lines
646 B
TypeScript
32 lines
646 B
TypeScript
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
|
|
}
|
|
}
|