Map editor teleport enhancements
This commit is contained in:
parent
af5a97f66d
commit
bfb2bcb939
@ -88,20 +88,17 @@ function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
|
||||
if (existingEventTile) return
|
||||
|
||||
// If teleport, check if there is a selected map
|
||||
if (mapEditor.drawMode.value === 'teleport' && !mapEditor.teleportSettings.value.toMapId) return
|
||||
|
||||
console.log(mapEditor.teleportSettings.value.toMapId)
|
||||
if (mapEditor.drawMode.value === 'teleport' && !mapEditor.teleportSettings.value.toMap) return
|
||||
|
||||
const newEventTile = {
|
||||
id: uuidv4() as UUID,
|
||||
map: map.id,
|
||||
type: mapEditor.drawMode.value === 'blocking tile' ? MapEventTileType.BLOCK : MapEventTileType.TELEPORT,
|
||||
positionX: tile.x,
|
||||
positionY: tile.y,
|
||||
teleport:
|
||||
mapEditor.drawMode.value === 'teleport'
|
||||
? {
|
||||
toMapId: mapEditor.teleportSettings.value.toMapId,
|
||||
toMap: mapEditor.teleportSettings.value.toMap,
|
||||
toPositionX: mapEditor.teleportSettings.value.toPositionX,
|
||||
toPositionY: mapEditor.teleportSettings.value.toPositionY,
|
||||
toRotation: mapEditor.teleportSettings.value.toRotation
|
||||
|
@ -129,7 +129,7 @@ function moveMapObject(id: string, map: MapT) {
|
||||
|
||||
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
|
||||
|
@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class="form-field-full">
|
||||
<label for="toMap">Map to teleport to</label>
|
||||
<select v-model="toMapId" class="input-field" name="toMap" id="toMap">
|
||||
<select v-model="toMap" class="input-field" name="toMap" id="toMap">
|
||||
<option :value="null">Select map</option>
|
||||
<option v-for="map in mapList" :key="map.id" :value="map.id">{{ map.name }}</option>
|
||||
</select>
|
||||
@ -55,7 +55,7 @@ defineExpose({
|
||||
open: () => modalRef.value?.open()
|
||||
})
|
||||
|
||||
const { toPositionX, toPositionY, toRotation, toMapId } = useRefTeleportSettings()
|
||||
const { toPositionX, toPositionY, toRotation, toMap } = useRefTeleportSettings()
|
||||
|
||||
function useRefTeleportSettings() {
|
||||
const settings = mapEditor.teleportSettings.value
|
||||
@ -63,18 +63,18 @@ function useRefTeleportSettings() {
|
||||
toPositionX: ref(settings.toPositionX),
|
||||
toPositionY: ref(settings.toPositionY),
|
||||
toRotation: ref(settings.toRotation),
|
||||
toMapId: ref(settings.toMapId)
|
||||
toMap: ref(settings.toMap)
|
||||
}
|
||||
}
|
||||
|
||||
watch([toPositionX, toPositionY, toRotation, toMapId], updateTeleportSettings)
|
||||
watch([toPositionX, toPositionY, toRotation, toMap], updateTeleportSettings)
|
||||
|
||||
function updateTeleportSettings() {
|
||||
mapEditor.setTeleportSettings({
|
||||
toPositionX: toPositionX.value,
|
||||
toPositionY: toPositionY.value,
|
||||
toRotation: toRotation.value,
|
||||
toMapId: toMapId.value
|
||||
toMap: toMap.value
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,6 @@ function save() {
|
||||
...currentMap,
|
||||
mapId: currentMap.id
|
||||
}
|
||||
console.log(data)
|
||||
|
||||
gameStore.connection?.emit(SocketEvent.GM_MAP_UPDATE, data, (response: MapT) => {
|
||||
mapStorage.update(response.id, response)
|
||||
|
@ -3,7 +3,7 @@ import { useGameStore } from '@/stores/gameStore'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export type TeleportSettings = {
|
||||
toMapId: string
|
||||
toMap: string
|
||||
toPositionX: number
|
||||
toPositionY: number
|
||||
toRotation: number
|
||||
@ -21,7 +21,7 @@ const movingPlacedObject = ref<PlacedMapObject | null>(null)
|
||||
const selectedPlacedObject = ref<PlacedMapObject | null>(null)
|
||||
const shouldClearTiles = ref(false)
|
||||
const teleportSettings = ref<TeleportSettings>({
|
||||
toMapId: '1000',
|
||||
toMap: '1000',
|
||||
toPositionX: 0,
|
||||
toPositionY: 0,
|
||||
toRotation: 0
|
||||
|
@ -2,7 +2,7 @@ import type { MapObject, Map as MapT } from '@/application/types'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export type TeleportSettings = {
|
||||
toMapId: string
|
||||
toMap: string
|
||||
toPositionX: number
|
||||
toPositionY: number
|
||||
toRotation: number
|
||||
@ -18,7 +18,7 @@ export const useMapEditorStore = defineStore('mapEditor', {
|
||||
selectedMapObject: null as MapObject | null,
|
||||
shouldClearTiles: false,
|
||||
teleportSettings: {
|
||||
toMapId: '',
|
||||
toMap: '',
|
||||
toPositionX: 0,
|
||||
toPositionY: 0,
|
||||
toRotation: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user