forked from noxious/client
Work for teleports
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<TilemapLayerC :tilemap="zoneTilemap" :tileset="tileArray" :layerIndex="0" :cull-padding="10" />
|
||||
<Controls :layer="tiles" />
|
||||
<TilemapLayerC :tilemap="zoneTilemap as Tilemap" :tileset="tileArray as any" :layerIndex="0" :cull-padding="10" />
|
||||
<Controls :layer="tiles as TilemapLayer" />
|
||||
|
||||
<Container :depth="2">
|
||||
<Image v-for="object in sortedZoneObjects" :key="object.id" v-bind="getObjectImageProps(object)" @pointerup="() => zoneEditorStore.setSelectedZoneObject(object)" />
|
||||
@ -40,6 +40,8 @@ import ZoneSettings from '@/components/utilities/zoneEditor/partials/ZoneSetting
|
||||
import Objects from '@/components/utilities/zoneEditor/partials/ObjectList.vue'
|
||||
import ZoneList from '@/components/utilities/zoneEditor/partials/ZoneList.vue'
|
||||
import TeleportModal from '@/components/utilities/zoneEditor/partials/TeleportModal.vue'
|
||||
import Tilemap = Phaser.Tilemaps.Tilemap
|
||||
import TilemapLayer = Phaser.Tilemaps.TilemapLayer
|
||||
|
||||
const scene = useScene()
|
||||
const gameStore = useGameStore()
|
||||
@ -72,7 +74,7 @@ function createTilemap() {
|
||||
function createTileLayer() {
|
||||
const tilesetImages = assetStore.assets.filter((asset) => asset.group === 'tiles').map((asset, index) => zoneTilemap.value.addTilesetImage(asset.key, asset.key, config.tile_size.x, config.tile_size.y, 0, 0, index + 1))
|
||||
tilesetImages.push(zoneTilemap.value.addTilesetImage('blank_tile', 'blank_tile', config.tile_size.x, config.tile_size.y, 0, 0, 0))
|
||||
return zoneTilemap.value.createBlankLayer('tiles', tilesetImages, 0, config.tile_size.y)
|
||||
return zoneTilemap.value.createBlankLayer('tiles', tilesetImages as any, 0, config.tile_size.y)
|
||||
}
|
||||
|
||||
function createTileArray() {
|
||||
@ -82,8 +84,8 @@ function createTileArray() {
|
||||
function getObjectImageProps(object: ZoneObject) {
|
||||
return {
|
||||
tint: selectedZoneObject.value?.id === object.id ? 0x00ff00 : 0xffffff,
|
||||
x: tileToWorldX(zoneTilemap.value, object.positionX, object.positionY),
|
||||
y: tileToWorldY(zoneTilemap.value, object.positionX, object.positionY),
|
||||
x: tileToWorldX(zoneTilemap.value as Tilemap, object.positionX, object.positionY),
|
||||
y: tileToWorldY(zoneTilemap.value as Tilemap, object.positionX, object.positionY),
|
||||
texture: object.object.id,
|
||||
originY: Number(object.object.originX),
|
||||
originX: Number(object.object.originY)
|
||||
@ -100,7 +102,7 @@ function getEventTileImageProps(tile: ZoneEventTile) {
|
||||
|
||||
function eraser(tile: Phaser.Tilemaps.Tile) {
|
||||
if (eraserMode.value === 'tile') {
|
||||
placeTile(zoneTilemap.value, tiles.value, tile.x, tile.y, 'blank_tile')
|
||||
placeTile(zoneTilemap.value as Tilemap, tiles.value as TilemapLayer, tile.x, tile.y, 'blank_tile')
|
||||
tileArray.value[tile.y][tile.x] = 'blank_tile'
|
||||
} else if (eraserMode.value === 'object') {
|
||||
zoneObjects.value = zoneObjects.value.filter((object) => object.positionX !== tile.x || object.positionY !== tile.y)
|
||||
@ -111,7 +113,7 @@ function eraser(tile: Phaser.Tilemaps.Tile) {
|
||||
|
||||
function pencil(tile: Phaser.Tilemaps.Tile) {
|
||||
if (drawMode.value === 'tile' && selectedTile.value) {
|
||||
placeTile(zoneTilemap.value, tiles.value, tile.x, tile.y, selectedTile.value.id)
|
||||
placeTile(zoneTilemap.value as Tilemap, tiles.value as TilemapLayer, tile.x, tile.y, selectedTile.value.id)
|
||||
tileArray.value[tile.y][tile.x] = selectedTile.value.id
|
||||
} else if (drawMode.value === 'object' && selectedObject.value) {
|
||||
addZoneObject(tile)
|
||||
@ -151,14 +153,14 @@ function addZoneEventTile(tile: Phaser.Tilemaps.Tile) {
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
zoneEventTiles.value = [...new Set([...zoneEventTiles.value, newEventTile])]
|
||||
zoneEventTiles.value = [...new Set([...zoneEventTiles.value, newEventTile])] as any
|
||||
}
|
||||
|
||||
function paint() {
|
||||
if (!selectedTile.value) return
|
||||
tileArray.value.forEach((row, y) =>
|
||||
row.forEach((_, x) => {
|
||||
placeTile(zoneTilemap.value, tiles.value, x, y, selectedTile.value!.id)
|
||||
placeTile(zoneTilemap.value as Tilemap, tiles.value as TilemapLayer, x, y, selectedTile.value!.id)
|
||||
tileArray.value[y][x] = selectedTile.value!.id
|
||||
})
|
||||
)
|
||||
@ -184,7 +186,7 @@ function save() {
|
||||
}
|
||||
|
||||
function clear() {
|
||||
tileArray.value.forEach((row, y) => row.forEach((_, x) => placeTile(zoneTilemap.value, tiles.value, x, y, 'blank_tile')))
|
||||
tileArray.value.forEach((row, y) => row.forEach((_, x) => placeTile(zoneTilemap.value as Tilemap, tiles.value as TilemapLayer, x, y, 'blank_tile')))
|
||||
tileArray.value = createTileArray()
|
||||
zoneEventTiles.value = []
|
||||
zoneObjects.value = []
|
||||
|
@ -29,7 +29,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onMounted } from 'vue'
|
||||
import { useGameStore } from '@/stores/game'
|
||||
import Modal from '@/components/utilities/Modal.vue'
|
||||
import type { Zone } from '@/types'
|
||||
@ -50,7 +50,6 @@ function fetchZones() {
|
||||
}
|
||||
|
||||
function loadZone(id: number) {
|
||||
console.log('loadZone', id)
|
||||
gameStore.connection?.emit('gm:zone_editor:zone:request', { zoneId: id }, (response: Zone) => {
|
||||
zoneEditorStore.setZone(response)
|
||||
})
|
||||
|
Reference in New Issue
Block a user