import { defineStore } from 'pinia' import type { Object, ZoneObject } from '@/types' export const useZoneEditorStore = defineStore('zoneEditor', { state: () => ({ active: true, name: '', width: 10, height: 10, tileList: [] as string[], tiles: [] as string[][], objectList: [] as Object[], objects: [] as ZoneObject[], tool: 'move', drawMode: 'tile', selectedTile: '', selectedObject: null as Object | null, isSettingsModalShown: false }), actions: { toggleActive() { this.active = !this.active }, setName(name: string) { this.name = name }, setWidth(width: number) { this.width = width }, setHeight(height: number) { this.height = height }, setTileList(tiles: string[]) { this.tileList = tiles }, setTiles(tiles: string[][]) { this.tiles = tiles }, updateTile(x: number, y: number, tile: string) { this.tiles[y][x] = tile }, setObjectList(objects: Object[]) { this.objectList = objects }, setObjects(objects: ZoneObject[]) { this.objects = objects }, updateObject(index: number, object: ZoneObject) { this.objects[index] = object }, setTool(tool: string) { this.tool = tool }, setDrawMode(mode: string) { this.drawMode = mode }, setSelectedTile(tile: string) { this.selectedTile = tile }, setSelectedObject(object: any) { this.selectedObject = object }, toggleSettingsModal() { this.isSettingsModalShown = !this.isSettingsModalShown }, reset() { this.name = '' this.width = 10 this.height = 10 this.tileList = [] this.tiles = [] this.objectList = [] this.objects = [] this.tool = 'move' this.drawMode = 'tile' this.selectedTile = '' this.selectedObject = null this.isSettingsModalShown = false } } }) /** * Resources: * https://www.html5gamedevs.com/topic/21908-phaser-is-there-any-tutorial-on-how-to-do-an-isometric-game/ * http://murdochcarpenter.com/isometric-starling-part-i/ */