Small cleanup

This commit is contained in:
2024-10-27 18:50:13 +01:00
parent 4f8517a50c
commit 4aa1309797
3 changed files with 12 additions and 10 deletions

View File

@ -13,8 +13,7 @@ import type { Character as CharacterT, Zone as ZoneT, ExtendedCharacter as Exten
import ZoneTiles from '@/components/zone/ZoneTiles.vue'
import ZoneObjects from '@/components/zone/ZoneObjects.vue'
import Characters from '@/components/zone/Characters.vue'
import { unduplicateArray } from '@/utilities'
import { FlattenZoneArray, loadZoneTileTexture } from '@/composables/zoneComposable'
import { loadZoneTiles } from '@/composables/zoneComposable'
const scene = useScene()
const gameStore = useGameStore()
@ -37,6 +36,7 @@ gameStore.connection!.on('zone:character:teleport', async (data: zoneLoadData) =
zoneId: data.zone.id
})
await loadZoneTiles(response.zone, scene)
zoneStore.setZone(data.zone)
zoneStore.setCharacters(data.characters)
})
@ -55,13 +55,6 @@ gameStore.connection!.on('character:move', (data: ExtendedCharacterT) => {
zoneStore.updateCharacter(data)
})
async function loadZoneTiles(zone: ZoneT, scene: Phaser.Scene) {
const tileArray = unduplicateArray(FlattenZoneArray(zone.tiles))
for (const tile of tileArray) {
await loadZoneTileTexture(scene, tile, new Date())
}
}
onMounted(async () => {
// Emit zone:character:join event to server and wait for response, then set zone and characters
gameStore!.connection!.emit('zone:character:join', async (response: zoneLoadData) => {