Check if hair is set before executing logic
This commit is contained in:
parent
489c6c3ba0
commit
65b011982a
@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<Image v-bind="imageProps" v-if="gameStore.isTextureLoaded(texture)" />
|
<Image v-bind="imageProps" v-if="hairSpriteId && gameStore.isTextureLoaded(texture)" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { MapCharacter, Sprite as SpriteT } from '@/application/types'
|
import type { MapCharacter, Sprite as SpriteT } from '@/application/types'
|
||||||
import { loadSpriteTextures } from '@/services/textureService'
|
import { loadSpriteTextures } from '@/services/textureService'
|
||||||
import { CharacterHairStorage, CharacterTypeStorage, SpriteStorage } from '@/storage/storages'
|
import { CharacterHairStorage, SpriteStorage } from '@/storage/storages'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
import { useGameStore } from '@/stores/gameStore'
|
||||||
import { Image, useScene } from 'phavuer'
|
import { Image, useScene } from 'phavuer'
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
@ -42,13 +42,16 @@ const imageProps = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
if (!props.mapCharacter.character.characterHair) return
|
||||||
|
|
||||||
const characterHairStorage = new CharacterHairStorage()
|
const characterHairStorage = new CharacterHairStorage()
|
||||||
const spriteId = await characterHairStorage.getSpriteId(props.mapCharacter.character.characterHair!)
|
const spriteId = await characterHairStorage.getSpriteId(props.mapCharacter.character.characterHair)
|
||||||
if (!spriteId) return
|
if (!spriteId) return
|
||||||
|
|
||||||
hairSpriteId.value = spriteId
|
hairSpriteId.value = spriteId
|
||||||
const spriteStorage = new SpriteStorage()
|
const spriteStorage = new SpriteStorage()
|
||||||
sprite.value = await spriteStorage.getById(spriteId)
|
sprite.value = await spriteStorage.getById(spriteId)
|
||||||
|
|
||||||
await loadSpriteTextures(scene, spriteId)
|
await loadSpriteTextures(scene, spriteId)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user