Effects/WorldSound.cs
namespace PlanetMeat;
[Group( "Planet Meat - Effects" ), Title( "SFX Bundle" ), Icon( "speaker_group" )]
public sealed class SoundEffectsBundle : Component
{
private static GameObject Prefab => GameObject.GetPrefab( "effects/point_sound.prefab" );
public static SoundEffectsBundle Create( Vector3 position, IEnumerable<SoundEvent> sounds )
{
if ( Prefab.Clone( position ).Components.Get<SoundEffectsBundle>() is SoundEffectsBundle sfb )
{
foreach ( var s in sounds )
sfb.AddSound( s );
return sfb;
}
return null;
}
public void AddSound( SoundEvent sound )
{
var soundComp = Components.Create<SoundPointComponent>();
soundComp.TargetMixer = "Game";
soundComp.SoundEvent = sound;
soundComp.StartSound();
}
}