Skip to content

Commit

Permalink
fix: danger hint
Browse files Browse the repository at this point in the history
  • Loading branch information
noyyyy committed Sep 23, 2024
1 parent 4f2b492 commit fccf616
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/client/src/ui/hooks/usePlayBackGroundMusic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useComponentValue } from "@dojoengine/react";
import { useDojo } from "./useDojo";
import { useEffect } from "react";
import { SoundFile, SoundType } from "./usePlaySoundSegment";
import {
SoundFile,
SoundType,
usePlaySoundSegment,
} from "./usePlaySoundSegment";
import useAudioStore from "./useAudioStore";
import { usePersistUIStore } from "../../store";

Expand All @@ -23,7 +27,8 @@ export function usePlayBackGroundMusic() {
const playerValue = useComponentValue(Player, playerEntity);
const soundVolumes = usePersistUIStore((state) => state.soundVolumes);

const { play, playSprite, fadeIn, fadeOut, isLoaded } = useAudioStore();
const { play, fadeIn, fadeOut, isLoaded } = useAudioStore();
const { play: playDangerHint } = usePlaySoundSegment(SoundType.DangerHint);

useEffect(() => {
if (!isLoaded) return;
Expand Down Expand Up @@ -56,13 +61,9 @@ export function usePlayBackGroundMusic() {

useEffect(() => {
if ((playerValue?.danger ?? 0) >= 100) {
playSprite(
SoundFile.Main,
SoundType.DangerHint,
soundVolumes.music / 100
);
playDangerHint();
}
}, [playerValue?.danger, playSprite, soundVolumes.music]);
}, [playerValue?.danger, playDangerHint]);

useEffect(() => {
if (!playerValue?.inMatch) {
Expand Down

0 comments on commit fccf616

Please sign in to comment.