Started streamlining map editor with regular map logic

This commit is contained in:
2025-01-22 20:34:56 +01:00
parent 41005735f9
commit ebd6d96e54
4 changed files with 83 additions and 99 deletions

View File

@ -1,5 +1,4 @@
import type { Map, MapEffect, MapObject, PlacedMapObject, Tile } from '@/application/types'
import { useGameStore } from '@/stores/gameStore'
import type { Map, MapEffect, MapObject, Tile, UUID } from '@/application/types'
import { defineStore } from 'pinia'
export type TeleportSettings = {
@ -12,8 +11,8 @@ export type TeleportSettings = {
export const useMapEditorStore = defineStore('mapEditor', {
state: () => {
return {
active: false,
map: null as Map | null,
active: true,
mapId: '',
tool: 'move',
drawMode: 'tile',
eraserMode: 'tile',
@ -45,13 +44,11 @@ export const useMapEditorStore = defineStore('mapEditor', {
},
actions: {
toggleActive() {
const gameStore = useGameStore()
if (!this.active) gameStore.connection?.emit('map:character:leave')
if (this.active) this.reset()
this.active = !this.active
},
setMap(map: Map | null) {
this.map = map
setMapId(mapId: UUID) {
this.mapId = mapId
},
setMapName(name: string) {
this.mapSettings.name = name
@ -63,11 +60,9 @@ export const useMapEditorStore = defineStore('mapEditor', {
this.mapSettings.height = height
},
setMapPvp(pvp: boolean) {
if (!this.map) return
this.map.pvp = pvp
this.mapSettings.pvp = pvp
},
setMapEffects(mapEffects: MapEffect[]) {
if (!this.map) return
this.mapSettings.mapEffects = mapEffects
},
setTool(tool: string) {
@ -113,8 +108,8 @@ export const useMapEditorStore = defineStore('mapEditor', {
resetClearTilesFlag() {
this.shouldClearTiles = false
},
reset(resetMap = false) {
if (resetMap) this.map = null
reset() {
this.mapId = ''
this.mapList = []
this.tileList = []
this.mapObjectList = []