1
0
forked from noxious/client

Almost finalised refactoring

This commit is contained in:
2025-01-03 14:35:08 +01:00
parent 145143cdc5
commit 700bd57e67
29 changed files with 264 additions and 273 deletions

View File

@ -6,8 +6,8 @@
<script setup lang="ts">
import type { PlacedMapObject as MapObjectT } from '@/application/types'
import { uuidv4 } from '@/application/utilities'
import SelectedMapObject from '@/components/gameMaster/mapEditor/partials/SelectedMapObject.vue'
import MapObject from '@/components/gameMaster/mapEditor/mapPartials/MapObject.vue'
import SelectedMapObject from '@/components/gameMaster/mapEditor/partials/SelectedMapObject.vue'
import { getTile } from '@/composables/mapComposable'
import { useMapEditorStore } from '@/stores/mapEditorStore'
import { useScene } from 'phavuer'
@ -65,7 +65,7 @@ function pencil(pointer: Phaser.Input.Pointer) {
}
// Add new object to mapObjects
mapEditorStore.map.mapObjects = mapEditorStore.map.mapObjects.concat(newObject as MapObjectT)
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.concat(newObject as MapObjectT)
}
function eraser(pointer: Phaser.Input.Pointer) {
@ -92,11 +92,11 @@ function eraser(pointer: Phaser.Input.Pointer) {
if (!tile) return
// Check if object already exists on position
const existingObject = mapEditorStore.map.mapObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
const existingObject = mapEditorStore.map.placedMapObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
if (!existingObject) return
// Remove existing object
mapEditorStore.map.mapObjects = mapEditorStore.map.mapObjects.filter((object) => object.id !== existingObject.id)
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.filter((object) => object.id !== existingObject.id)
}
function objectPicker(pointer: Phaser.Input.Pointer) {
@ -123,7 +123,7 @@ function objectPicker(pointer: Phaser.Input.Pointer) {
if (!tile) return
// Check if object already exists on position
const existingObject = mapEditorStore.map.mapObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
const existingObject = mapEditorStore.map.placedMapObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y)
if (!existingObject) return
// Select the object
@ -134,7 +134,7 @@ function moveMapObject(id: string) {
// Check if map is set
if (!mapEditorStore.map) return
movingMapObject.value = mapEditorStore.map.mapObjects.find((object) => object.id === id) as MapObjectT
movingMapObject.value = mapEditorStore.map.placedMapObjects.find((object) => object.id === id) as MapObjectT
function handlePointerMove(pointer: Phaser.Input.Pointer) {
if (!movingMapObject.value) return
@ -160,7 +160,7 @@ function rotateMapObject(id: string) {
// Check if map is set
if (!mapEditorStore.map) return
mapEditorStore.map.mapObjects = mapEditorStore.map.mapObjects.map((object) => {
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.map((object) => {
if (object.id === id) {
return {
...object,
@ -175,7 +175,7 @@ function deleteMapObject(id: string) {
// Check if map is set
if (!mapEditorStore.map) return
mapEditorStore.map.mapObjects = mapEditorStore.map.mapObjects.filter((object) => object.id !== id)
mapEditorStore.map.placedMapObjects = mapEditorStore.map.placedMapObjects.filter((object) => object.id !== id)
selectedMapObject.value = null
}
@ -210,7 +210,8 @@ watch(
(newObjects) => {
if (!mapEditorStore.map) return
const updatedMapObjects = mapEditorStore.map.mapObjects.map((mapObject) => {
console.log(mapEditorStore.map.placedMapObjects)
const updatedMapObjects = mapEditorStore.map.placedMapObjects.map((mapObject) => {
const updatedObject = newObjects.find((obj) => obj.id === mapObject.object.id)
if (updatedObject) {
return {