34 lines
1004 B
C#
34 lines
1004 B
C#
using Unity.Mathematics;
|
|
using UnityEngine.Audio;
|
|
|
|
namespace DanieleMarotta.RiversongCodeShowcase
|
|
{
|
|
public interface ISoundPlayer
|
|
{
|
|
void Play(AudioResource resource);
|
|
|
|
void PlayAt(AudioResource resource, float3 position);
|
|
|
|
void PlayAt(AudioResource resource, int2 tile);
|
|
|
|
AudioResource GetSystemSound(SystemSoundId soundId);
|
|
}
|
|
|
|
public static class SoundPlayerExtensions
|
|
{
|
|
public static void Play(this ISoundPlayer soundPlayer, SystemSoundId soundId)
|
|
{
|
|
soundPlayer.Play(soundPlayer.GetSystemSound(soundId));
|
|
}
|
|
|
|
public static void PlayAt(this ISoundPlayer soundPlayer, SystemSoundId soundId, float3 position)
|
|
{
|
|
soundPlayer.PlayAt(soundPlayer.GetSystemSound(soundId), position);
|
|
}
|
|
|
|
public static void PlayAt(this ISoundPlayer soundPlayer, SystemSoundId soundId, int2 tile)
|
|
{
|
|
soundPlayer.PlayAt(soundPlayer.GetSystemSound(soundId), tile);
|
|
}
|
|
}
|
|
} |