forked from noxious/client
Fixed object moving when its not supposed to
This commit is contained in:
parent
c82db9813e
commit
5e243e5201
@ -39,8 +39,8 @@ const props = defineProps<{
|
|||||||
const previewPosition = ref({ x: 0, y: 0 })
|
const previewPosition = ref({ x: 0, y: 0 })
|
||||||
|
|
||||||
const previewPlacedMapObject = computed(() => ({
|
const previewPlacedMapObject = computed(() => ({
|
||||||
id: mapEditor.selectedMapObject.value?.id ?? uuidv4(),
|
id: mapEditor.selectedMapObject.value!.id,
|
||||||
mapObject: mapEditor.selectedMapObject.value?.id,
|
mapObject: mapEditor.selectedMapObject.value!,
|
||||||
isRotated: false,
|
isRotated: false,
|
||||||
positionX: previewPosition.value.x,
|
positionX: previewPosition.value.x,
|
||||||
positionY: previewPosition.value.y
|
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_MOVE, handlePointerMove)
|
||||||
|
scene.input.on(Phaser.Input.Events.POINTER_UP, handlePointerUp)
|
||||||
|
|
||||||
function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
||||||
scene.input.off(Phaser.Input.Events.POINTER_MOVE, handlePointerMove)
|
scene.input.off(Phaser.Input.Events.POINTER_MOVE, handlePointerMove)
|
||||||
|
|
||||||
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
|
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
|
||||||
if (!tile) return
|
if (!tile) return
|
||||||
|
console.log(id)
|
||||||
map.placedMapObjects.map((placed) => {
|
map.placedMapObjects.map((placed) => {
|
||||||
if (placed.id === id) {
|
if (placed.id === id) {
|
||||||
placed.positionX = tile.x
|
placed.positionX = tile.x
|
||||||
@ -132,10 +133,9 @@ function moveMapObject(id: string, map: MapT) {
|
|||||||
}})
|
}})
|
||||||
|
|
||||||
mapEditor.movingPlacedObject.value = null
|
mapEditor.movingPlacedObject.value = null
|
||||||
}
|
|
||||||
emit('updateAndCommit', map)
|
emit('updateAndCommit', map)
|
||||||
|
scene.input.off(Phaser.Input.Events.POINTER_UP, handlePointerUp)
|
||||||
scene.input.on(Phaser.Input.Events.POINTER_UP, handlePointerUp)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function rotatePlacedMapObject(id: string, map: MapT) {
|
function rotatePlacedMapObject(id: string, map: MapT) {
|
||||||
|
@ -6,19 +6,6 @@
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
<Map v-if="mapEditor.currentMap.value" :key="mapEditor.currentMap.value?.id" />
|
<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="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" />
|
<MapList ref="mapModal" @open-create-map="mapSettingsModal?.open" />
|
||||||
<TileList />
|
<TileList />
|
||||||
<MapObjectList />
|
<MapObjectList />
|
||||||
@ -101,8 +88,7 @@ function save() {
|
|||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
...currentMap,
|
...currentMap,
|
||||||
mapId: currentMap.id,
|
mapId: currentMap.id
|
||||||
placedMapObjects: currentMap.placedMapObjects.map(({ id, mapObject, depth, isRotated, positionX, positionY }) => ({ id, mapObject, depth, isRotated, positionX, positionY })) ?? []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gameStore.connection?.emit('gm:map:update', data, (response: MapT) => {
|
gameStore.connection?.emit('gm:map:update', data, (response: MapT) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user