Minor improvements
This commit is contained in:
parent
130df8f144
commit
fa12ce2ec8
@ -8,7 +8,7 @@
|
|||||||
import { useScene } from 'phavuer'
|
import { useScene } from 'phavuer'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
import { useGameStore } from '@/stores/gameStore'
|
||||||
import { useZoneStore } from '@/stores/zoneStore'
|
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 type { Character as CharacterT, Zone as ZoneT, ExtendedCharacter as ExtendedCharacterT } from '@/types'
|
||||||
import Tiles from '@/components/zone/Tiles.vue'
|
import Tiles from '@/components/zone/Tiles.vue'
|
||||||
import Objects from '@/components/zone/Objects.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) => {
|
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)
|
zoneStore.addCharacter(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -59,12 +61,7 @@ gameStore.connection!.on('character:move', (data: ExtendedCharacterT) => {
|
|||||||
zoneStore.updateCharacter(data)
|
zoneStore.updateCharacter(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onMounted(() => {
|
||||||
/**
|
|
||||||
* @TODO, when returning from the zone editor, the emit is not s
|
|
||||||
*/
|
|
||||||
console.log('before mount')
|
|
||||||
|
|
||||||
gameStore.connection!.emit('zone:character:join', async (response: zoneLoadData) => {
|
gameStore.connection!.emit('zone:character:join', async (response: zoneLoadData) => {
|
||||||
// Fetch assets for new zone
|
// Fetch assets for new zone
|
||||||
await gameStore.fetchZoneAssets(response.zone.id)
|
await gameStore.fetchZoneAssets(response.zone.id)
|
||||||
|
@ -42,7 +42,8 @@ export const useZoneStore = defineStore('zone', {
|
|||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
this.zone = null
|
this.zone = null
|
||||||
;(this.characters = []), (this.characterLoaded = false)
|
this.characters = []
|
||||||
|
this.characterLoaded = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user