Started streamlining map editor with regular map logic
This commit is contained in:
@ -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 = []
|
||||
|
Reference in New Issue
Block a user