Fixed object moving when its not supposed to

This commit is contained in:
Andrei 2025-02-13 12:19:09 -06:00
parent c82db9813e
commit 5e243e5201
2 changed files with 7 additions and 21 deletions

View File

@ -39,8 +39,8 @@ const props = defineProps<{
const previewPosition = ref({ x: 0, y: 0 })
const previewPlacedMapObject = computed(() => ({
id: mapEditor.selectedMapObject.value?.id ?? uuidv4(),
mapObject: mapEditor.selectedMapObject.value?.id,
id: mapEditor.selectedMapObject.value!.id,
mapObject: mapEditor.selectedMapObject.value!,
isRotated: false,
positionX: previewPosition.value.x,
positionY: previewPosition.value.y
@ -118,13 +118,14 @@ function moveMapObject(id: string, map: MapT) {
}
scene.input.on(Phaser.Input.Events.POINTER_MOVE, handlePointerMove)
scene.input.on(Phaser.Input.Events.POINTER_UP, handlePointerUp)
function handlePointerUp(pointer: Phaser.Input.Pointer) {
scene.input.off(Phaser.Input.Events.POINTER_MOVE, handlePointerMove)
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
if (!tile) return
console.log(id)
map.placedMapObjects.map((placed) => {
if (placed.id === id) {
placed.positionX = tile.x
@ -132,10 +133,9 @@ function moveMapObject(id: string, map: MapT) {
}})
mapEditor.movingPlacedObject.value = null
}
emit('updateAndCommit', map)
scene.input.on(Phaser.Input.Events.POINTER_UP, handlePointerUp)
scene.input.off(Phaser.Input.Events.POINTER_UP, handlePointerUp)
}
}
function rotatePlacedMapObject(id: string, map: MapT) {

View File

@ -6,19 +6,6 @@
<div v-else>
<Map v-if="mapEditor.currentMap.value" :key="mapEditor.currentMap.value?.id" />
<Toolbar ref="toolbar" @save="save" @clear="clear" @open-maps="mapModal?.open" @open-settings="mapSettingsModal?.open" @open-teleport="teleportModal?.open"/>
<Toolbar
ref="toolbar"
@save="save"
@clear="clear"
@open-maps="mapModal?.open"
@open-settings="mapSettingsModal?.open"
@open-teleport-settings="teleportModal?.open"
@close-editor="mapEditor.toggleActive"
@close-lists="tileList?.close"
@closeLists="objectList?.close"
@open-tile-list="tileList?.open"
@open-map-object-list="objectList?.open"
/>
<MapList ref="mapModal" @open-create-map="mapSettingsModal?.open" />
<TileList />
<MapObjectList />
@ -101,8 +88,7 @@ function save() {
const data = {
...currentMap,
mapId: currentMap.id,
placedMapObjects: currentMap.placedMapObjects.map(({ id, mapObject, depth, isRotated, positionX, positionY }) => ({ id, mapObject, depth, isRotated, positionX, positionY })) ?? []
mapId: currentMap.id
}
gameStore.connection?.emit('gm:map:update', data, (response: MapT) => {