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