forked from noxious/client
Minor improvements
This commit is contained in:
parent
130df8f144
commit
fa12ce2ec8
@ -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)
|
||||
|
@ -42,7 +42,8 @@ export const useZoneStore = defineStore('zone', {
|
||||
},
|
||||
reset() {
|
||||
this.zone = null
|
||||
;(this.characters = []), (this.characterLoaded = false)
|
||||
this.characters = []
|
||||
this.characterLoaded = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user