import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { Tile, Object, Sprite } from '@/types'

export const useAssetManagerStore = defineStore('assetManager', () => {
  const tileList = ref<Tile[]>([])
  const selectedTile = ref<Tile | null>(null)

  const objectList = ref<Object[]>([])
  const selectedObject = ref<Object | null>(null)

  const spriteList = ref<Sprite[]>([])
  const selectedSprite = ref<Sprite | null>(null)

  function setTileList(tiles: Tile[]) {
    tileList.value = tiles
  }

  function setSelectedTile(tile: Tile | null) {
    selectedTile.value = tile
  }

  function setObjectList(objects: Object[]) {
    objectList.value = objects
  }

  function setSelectedObject(object: Object | null) {
    selectedObject.value = object
  }

  function setSpriteList(sprites: Sprite[]) {
    spriteList.value = sprites
  }

  function setSelectedSprite(sprite: Sprite | null) {
    selectedSprite.value = sprite
  }

  return {
    tileList,
    selectedTile,
    objectList,
    selectedObject,
    spriteList,
    selectedSprite,
    setTileList,
    setSelectedTile,
    setObjectList,
    setSelectedObject,
    setSpriteList,
    setSelectedSprite
  }
})
