Removed broken logic @TODO. replace with working logic :(

This commit is contained in:
2024-09-20 14:15:47 +02:00
parent b6b0ccb22d
commit b9bb55cf49
5 changed files with 27 additions and 43 deletions

View File

@ -37,9 +37,10 @@
<script setup lang="ts">
import config from '@/config'
import 'phaser'
import { watch, ref, onBeforeUnmount } from 'vue'
import { watch, ref, onBeforeUnmount, onBeforeMount } from 'vue'
import { Game, Scene } from 'phavuer'
import { useGameStore } from '@/stores/game'
import { useZoneStore } from '@/stores/zone'
import { useZoneEditorStore } from '@/stores/zoneEditor'
import { useAssetStore } from '@/stores/assets'
import Hud from '@/components/gui/Hud.vue'
@ -50,8 +51,10 @@ import GmTools from '@/components/gameMaster/GmTools.vue'
import ZoneEditor from '@/components/gameMaster/zoneEditor/ZoneEditor.vue'
import GmPanel from '@/components/gameMaster/GmPanel.vue'
import Inventory from '@/components/gui/UserPanel.vue'
import { loadAssets } from '@/services/zone'
const gameStore = useGameStore()
const zoneStore = useZoneStore()
const zoneEditorStore = useZoneEditorStore()
const assetStore = useAssetStore()
const isLoaded = ref(false)
@ -145,31 +148,6 @@ const createScene = (scene: Phaser.Scene) => {
repeat: -1
})
})
/**
* Watch for changes in assets and reload them
*/
watch(
() => assetStore.assets,
async () => {
loadAssets(scene)
}
)
}
const loadAssets = (scene: Phaser.Scene) => {
assetStore.assets.forEach((asset) => {
console.log('asset', asset)
if (asset.group === 'sprite_animations') {
scene.load.spritesheet(asset.key, config.server_endpoint + asset.url, { frameWidth: asset.frameWidth ?? 0, frameHeight: asset.frameHeight ?? 0 })
} else {
scene.load.image(asset.key, config.server_endpoint + asset.url)
}
})
// scene.load.once(Phaser.Loader.Events.COMPLETE, () => {})
scene.load.start()
}
onBeforeUnmount(() => {