1
0
forked from noxious/client

Minor improvements

This commit is contained in:
Dennis Postma 2024-09-28 02:52:36 +02:00
parent 130df8f144
commit fa12ce2ec8
2 changed files with 6 additions and 8 deletions

View File

@ -8,7 +8,7 @@
import { useScene } from 'phavuer'
import { useGameStore } from '@/stores/gameStore'
import { useZoneStore } from '@/stores/zoneStore'
import { onBeforeMount, onBeforeUnmount, ref } from 'vue'
import { onBeforeMount, onBeforeUnmount, onMounted, ref } from 'vue'
import type { Character as CharacterT, Zone as ZoneT, ExtendedCharacter as ExtendedCharacterT } from '@/types'
import Tiles from '@/components/zone/Tiles.vue'
import Objects from '@/components/zone/Objects.vue'
@ -48,6 +48,8 @@ gameStore.connection!.on('zone:character:teleport', async (data: zoneLoadData) =
})
gameStore.connection!.on('zone:character:join', async (data: ExtendedCharacterT) => {
// If data is from the current user, don't add it to the store
if (data.id === gameStore.character?.id) return
zoneStore.addCharacter(data)
})
@ -59,12 +61,7 @@ gameStore.connection!.on('character:move', (data: ExtendedCharacterT) => {
zoneStore.updateCharacter(data)
})
onBeforeMount(() => {
/**
* @TODO, when returning from the zone editor, the emit is not s
*/
console.log('before mount')
onMounted(() => {
gameStore.connection!.emit('zone:character:join', async (response: zoneLoadData) => {
// Fetch assets for new zone
await gameStore.fetchZoneAssets(response.zone.id)

View File

@ -42,7 +42,8 @@ export const useZoneStore = defineStore('zone', {
},
reset() {
this.zone = null
;(this.characters = []), (this.characterLoaded = false)
this.characters = []
this.characterLoaded = false
}
}
})