bruhmoment

This commit is contained in:
Dennis Postma 2024-09-20 16:49:47 +02:00
parent be4c201d81
commit f3b56ef5fa
3 changed files with 17 additions and 5 deletions

View File

@ -24,12 +24,20 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, onBeforeMount, onUnmounted, ref, watch } from 'vue' import { computed, onBeforeMount, onMounted, onUnmounted, ref, watch } from 'vue'
import { Container, Image, useScene } from 'phavuer' import { Container, Image, useScene } from 'phavuer'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useGameStore } from '@/stores/game' import { useGameStore } from '@/stores/game'
import { useZoneEditorStore } from '@/stores/zoneEditor' import { useZoneEditorStore } from '@/stores/zoneEditor'
import { calculateIsometricDepth, placeTile, setAllTiles, sortByIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/zoneComposable' import {
calculateIsometricDepth,
loadAssets,
placeTile,
setAllTiles,
sortByIsometricDepth,
tileToWorldX,
tileToWorldY
} from '@/composables/zoneComposable'
import { ZoneEventTileType, type ZoneObject, type ZoneEventTile, type Zone } from '@/types' import { ZoneEventTileType, type ZoneObject, type ZoneEventTile, type Zone } from '@/types'
import { uuidv4 } from '@/utilities' import { uuidv4 } from '@/utilities'
import config from '@/config' import config from '@/config'
@ -312,4 +320,9 @@ const setSelectedZoneObject = (zoneObject: ZoneObject | null) => {
if (zoneEditorStore.tool !== 'move') return if (zoneEditorStore.tool !== 'move') return
zoneEditorStore.setSelectedZoneObject(zoneObject) zoneEditorStore.setSelectedZoneObject(zoneObject)
} }
onBeforeMount(async () => {
await gameStore.fetchAllZoneAssets()
await loadAssets(scene)
});
</script> </script>

View File

@ -42,7 +42,6 @@ gameStore.connection!.on('zone:teleport', async (data: zoneLoadData) => {
// Fetch assets for new zone // Fetch assets for new zone
await gameStore.fetchZoneAssets(data.zone.id) await gameStore.fetchZoneAssets(data.zone.id)
// wait 1.5 sec
await loadAssets(scene) await loadAssets(scene)
/** /**

View File

@ -68,8 +68,8 @@ export const useGameStore = defineStore('game', {
return false return false
}) })
}, },
async fetchAllAssets() { async fetchAllZoneAssets() {
return fetch(config.server_endpoint + '/assets') return fetch(config.server_endpoint + '/assets/zone')
.then((response) => response.json()) .then((response) => response.json())
.then((assets) => { .then((assets) => {
// Only add the zones that are not already in the store // Only add the zones that are not already in the store