-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6436 from mozilla/bit-sfx-update
Bit SFX update
- Loading branch information
Showing
5 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { defineQuery, enterQuery } from "bitecs"; | ||
import { HubsWorld } from "../app"; | ||
import { | ||
HeldHandLeft, | ||
HeldHandRight, | ||
HeldRemoteLeft, | ||
HeldRemoteRight, | ||
HoldableButton, | ||
HoverButton, | ||
HoveredHandLeft, | ||
HoveredHandRight, | ||
HoveredRemoteLeft, | ||
HoveredRemoteRight | ||
} from "../bit-components"; | ||
import { SOUND_HOVER_OR_GRAB } from "../systems/sound-effects-system"; | ||
|
||
const hoveredRemoteRightQuery = defineQuery([HoverButton, HoveredRemoteRight]); | ||
const hoveredRemoteRightEnterQuery = enterQuery(hoveredRemoteRightQuery); | ||
const hoveredRemoteLeftQuery = defineQuery([HoverButton, HoveredRemoteLeft]); | ||
const hoveredRemoteLeftEnterQuery = enterQuery(hoveredRemoteLeftQuery); | ||
const hoveredHandRightQuery = defineQuery([HoverButton, HoveredHandRight]); | ||
const hoveredHandRightEnterQuery = enterQuery(hoveredHandRightQuery); | ||
const hoveredHandLeftQuery = defineQuery([HoverButton, HoveredHandLeft]); | ||
const hoveredHandLeftEnterQuery = enterQuery(hoveredHandLeftQuery); | ||
const heldRemoteRightQuery = defineQuery([HoldableButton, HeldRemoteRight]); | ||
const heldRemoteRightEnterQuery = enterQuery(heldRemoteRightQuery); | ||
const heldRemoteLeftQuery = defineQuery([HoldableButton, HeldRemoteLeft]); | ||
const heldRemoteLeftEnterQuery = enterQuery(heldRemoteLeftQuery); | ||
const heldHandRightQuery = defineQuery([HoldableButton, HeldHandRight]); | ||
const heldHandRightEnterQuery = enterQuery(heldHandRightQuery); | ||
const heldHandLeftQuery = defineQuery([HoldableButton, HeldHandLeft]); | ||
const heldHandLeftEnterQuery = enterQuery(heldHandLeftQuery); | ||
export function sfxButtonSystem(world: HubsWorld, sfxSystem: any) { | ||
hoveredRemoteRightEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
hoveredRemoteLeftEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
hoveredHandRightEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
hoveredHandLeftEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
heldRemoteRightEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
heldRemoteLeftEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
heldHandRightEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
heldHandLeftEnterQuery(world).forEach(() => sfxSystem.playSoundOneShot(SOUND_HOVER_OR_GRAB)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Not, defineQuery, enterQuery, exitQuery } from "bitecs"; | ||
import { HubsWorld } from "../app"; | ||
import { Deleting, MediaLoaded, MediaLoader, MediaLoading, Networked } from "../bit-components"; | ||
import { SOUND_MEDIA_LOADED, SOUND_MEDIA_LOADING } from "../systems/sound-effects-system"; | ||
|
||
const loadingSounds = new Map(); | ||
const mediaLoadingQuery = defineQuery([Networked, MediaLoader, MediaLoading, Not(Deleting)]); | ||
const mediaLoadingEnterQuery = enterQuery(mediaLoadingQuery); | ||
const mediaLoadingExitQuery = exitQuery(mediaLoadingQuery); | ||
const mediaLoadedQuery = defineQuery([MediaLoaded]); | ||
const mediaLoadedEnterQuery = enterQuery(mediaLoadedQuery); | ||
const mediaLoadedExitQuery = exitQuery(mediaLoadedQuery); | ||
export function sfxMediaSystem(world: HubsWorld, sfxSystem: any) { | ||
mediaLoadingExitQuery(world).forEach(eid => { | ||
if (loadingSounds.has(eid)) { | ||
sfxSystem.stopPositionalAudio(loadingSounds.get(eid)); | ||
loadingSounds.delete(eid); | ||
} | ||
}); | ||
mediaLoadingEnterQuery(world).forEach(eid => { | ||
if (loadingSounds.has(eid)) { | ||
sfxSystem.stopPositionalAudio(loadingSounds.get(eid)); | ||
loadingSounds.delete(eid); | ||
} | ||
if (Networked.owner[eid] === APP.getSid(NAF.clientId)) { | ||
const obj = world.eid2obj.get(eid); | ||
const audio = sfxSystem.playPositionalSoundFollowing(SOUND_MEDIA_LOADING, obj, true); | ||
loadingSounds.set(eid, audio); | ||
} | ||
}); | ||
mediaLoadedExitQuery(world).forEach(eid => { | ||
if (loadingSounds.has(eid)) { | ||
sfxSystem.stopPositionalAudio(loadingSounds.get(eid)); | ||
loadingSounds.delete(eid); | ||
} | ||
}); | ||
mediaLoadedEnterQuery(world).forEach(eid => { | ||
if (loadingSounds.has(eid)) { | ||
sfxSystem.stopPositionalAudio(loadingSounds.get(eid)); | ||
loadingSounds.delete(eid); | ||
} | ||
const obj = world.eid2obj.get(eid); | ||
const audio = sfxSystem.playPositionalSoundFollowing(SOUND_MEDIA_LOADED, obj, false); | ||
loadingSounds.set(eid, audio); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters