1
0
forked from noxious/client

Minor improvements

This commit is contained in:
Dennis Postma 2025-02-12 21:11:17 +01:00
parent e6412d8a65
commit 41e7832cbe
4 changed files with 8 additions and 59 deletions

View File

@ -1,51 +0,0 @@
<template>
<Image v-bind="imageProps" v-if="gameStore.getLoadedAsset(texture)" />
</template>
<script lang="ts" setup>
import type { MapCharacter, Sprite as SpriteT } from '@/application/types'
import { loadSpriteTextures } from '@/services/textureService'
import { useGameStore } from '@/stores/gameStore'
import { Image, useScene } from 'phavuer'
import { computed } from 'vue'
const props = defineProps<{
mapCharacter: MapCharacter
currentX: number
currentY: number
}>()
const gameStore = useGameStore()
const scene = useScene()
const texture = computed(() => {
const { rotation, characterHair } = props.mapCharacter.character
const spriteId = characterHair?.sprite?.id
const direction = [0, 6].includes(rotation) ? 'back' : 'front'
return `${spriteId}-${direction}`
})
const isFlippedX = computed(() => [6, 4].includes(props.mapCharacter.character.rotation ?? 0))
const imageProps = computed(() => {
// Get the current sprite action based on direction
const direction = [0, 6].includes(props.mapCharacter.character.rotation ?? 0) ? 'back' : 'front'
const spriteAction = props.mapCharacter.character.characterHair?.sprite?.spriteActions?.find((spriteAction) => spriteAction.action === direction)
return {
depth: 1,
originX: Number(spriteAction?.originX) ?? 0,
originY: Number(spriteAction?.originY) ?? 0,
flipX: isFlippedX.value,
texture: texture.value
// y: props.mapCharacter.isMoving ? Math.floor(Date.now() / 250) % 2 : 0
}
})
loadSpriteTextures(scene, props.mapCharacter.character.characterHair?.sprite as SpriteT)
.then(() => {})
.catch((error) => {
console.error('Error loading texture:', error)
})
</script>

View File

@ -30,13 +30,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { SocketEvent } from '@/application/enums' import { SocketEvent } from '@/application/enums'
import type { Map, UUID } from '@/application/types' import type { Map } from '@/application/types'
import CreateMap from '@/components/gameMaster/mapEditor/partials/CreateMap.vue' import CreateMap from '@/components/gameMaster/mapEditor/partials/CreateMap.vue'
import Modal from '@/components/utilities/Modal.vue' import Modal from '@/components/utilities/Modal.vue'
import { useMapEditorComposable } from '@/composables/useMapEditorComposable' import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
import { MapStorage } from '@/storage/storages' import { MapStorage } from '@/storage/storages'
import { useGameStore } from '@/stores/gameStore' import { useGameStore } from '@/stores/gameStore'
import { useMapEditorStore } from '@/stores/mapEditorStore'
import { onMounted, ref, useTemplateRef } from 'vue' import { onMounted, ref, useTemplateRef } from 'vue'
const gameStore = useGameStore() const gameStore = useGameStore()
@ -61,14 +60,14 @@ async function fetchMaps() {
mapList.value = await mapStorage.getAll() mapList.value = await mapStorage.getAll()
} }
function loadMap(id: UUID) { function loadMap(id: string) {
gameStore.connection?.emit(SocketEvent.GM_MAP_REQUEST, { mapId: id }, (response: Map) => { gameStore.connection?.emit(SocketEvent.GM_MAP_REQUEST, { mapId: id }, (response: Map) => {
mapEditor.loadMap(response) mapEditor.loadMap(response)
}) })
modalRef.value?.close() modalRef.value?.close()
} }
async function deleteMap(id: UUID) { async function deleteMap(id: string) {
gameStore.connection?.emit(SocketEvent.GM_MAP_DELETE, { mapId: id }, async (response: boolean) => { gameStore.connection?.emit(SocketEvent.GM_MAP_DELETE, { mapId: id }, async (response: boolean) => {
if (!response) { if (!response) {
gameStore.addNotification({ gameStore.addNotification({

View File

@ -47,6 +47,7 @@ import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
import { MapObjectStorage } from '@/storage/storages' import { MapObjectStorage } from '@/storage/storages'
import { useGameStore } from '@/stores/gameStore' import { useGameStore } from '@/stores/gameStore'
import { onMounted, ref } from 'vue' import { onMounted, ref } from 'vue'
import {SocketEvent} from "@/application/enums";
const props = defineProps<{ const props = defineProps<{
placedMapObject: PlacedMapObject placedMapObject: PlacedMapObject
@ -81,7 +82,7 @@ async function handleUpdate() {
if (!mapObject.value) return if (!mapObject.value) return
gameStore.connection?.emit( gameStore.connection?.emit(
'gm:mapObject:update', SocketEvent.GM_MAPOBJECT_UPDATE,
{ {
id: props.placedMapObject.mapObject as string, id: props.placedMapObject.mapObject as string,
name: mapObjectName.value, name: mapObjectName.value,

View File

@ -59,9 +59,9 @@ defineExpose({
onMounted(fetchMaps) onMounted(fetchMaps)
function fetchMaps() { function fetchMaps() {
gameStore.connection?.emit(SocketEvent.GM_MAP_LIST, {}, (response: Map[]) => { // gameStore.connection?.emit(SocketEvent.GM_MAP_LIST, {}, (response: Map[]) => {
mapList.value = response // mapList.value = response
}) // })
} }
const { toPositionX, toPositionY, toRotation, toMap } = useRefTeleportSettings() const { toPositionX, toPositionY, toRotation, toMap } = useRefTeleportSettings()