diff --git a/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue b/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue index 76fd9e0..ca613b9 100644 --- a/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue +++ b/src/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue @@ -7,7 +7,7 @@ import { MapEventTileType, type MapEventTile, type Map as MapT, type UUID } from import { uuidv4 } from '@/application/utilities' import { useMapEditorComposable } from '@/composables/useMapEditorComposable' import { getTile, tileToWorldX, tileToWorldY } from '@/services/mapService' -import { Image, useScene } from 'phavuer' +import { Image } from 'phavuer' import { shallowRef } from 'vue' const mapEditor = useMapEditorComposable() @@ -63,14 +63,18 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) { } function erase(pointer: Phaser.Input.Pointer, map: MapT) { - if (!tileLayer.value) return // Check if there is a tile - const tile = getTile(tileLayer.value, pointer.worldX, pointer.worldY) + const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY) if (!tile) return // Check if event tile already exists on position const existingEventTile = map.mapEventTiles.find((eventTile) => eventTile.positionX === tile.x && eventTile.positionY === tile.y) if (!existingEventTile) return + + if (mapEditor.drawMode.value !== existingEventTile.type.toLowerCase()) { + if (mapEditor.drawMode.value === 'blocking tile' && existingEventTile.type === MapEventTileType.BLOCK) null //skip this case + else return; + } // Remove existing event tile map.mapEventTiles = map.mapEventTiles.filter((eventTile) => eventTile.id !== existingEventTile.id) diff --git a/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue b/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue index 52ddc97..63096e1 100644 --- a/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue +++ b/src/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue @@ -1,5 +1,5 @@ @@ -14,9 +14,11 @@ import { useScene } from 'phavuer' import Tilemap = Phaser.Tilemaps.Tilemap import TilemapLayer = Phaser.Tilemaps.TilemapLayer +import { computed } from 'vue' const scene = useScene() const mapEditor = useMapEditorComposable() +const map = computed(() => mapEditor.currentMap.value) defineExpose({ handlePointer }) diff --git a/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue b/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue index 6700d56..df2323b 100644 --- a/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue +++ b/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue @@ -11,23 +11,24 @@