Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Declared in class:
- ```csharp
- private MyEntity3DSoundEmitter m_soundEmitter;
- public MyEntity3DSoundEmitter SoundEmitter { get { return m_soundEmitter; } }
- ```
- In Init():
- ```csharp
- m_soundEmitter = new MyEntity3DSoundEmitter(Container.Entity as VRage.Game.Entity.MyEntity);
- ```
- Using:
- ```csharp
- public static void PlaySound(this IMyFunctionalBlock ftl, string soundname, bool stopPrevious = false)
- {
- MyEntity3DSoundEmitter emitter = null;
- if( ftl.IsFTL() )
- emitter = ftl.GameLogic.GetAs<FTL>().SoundEmitter;
- if( emitter != null )
- {
- if (string.IsNullOrEmpty(soundname))
- {
- emitter.StopSound((emitter.Loop ? true : false), true);
- }
- else
- {
- MySoundPair sound = new MySoundPair(soundname);
- emitter.CustomMaxDistance = (float)ftl.GetTopMostParent().PositionComp.WorldVolume.Radius * 2.0f;
- Logger.Instance.LogDebug("Distance: " + emitter.CustomMaxDistance);
- emitter.CustomVolume = 1.0f;
- emitter.PlaySound(sound, stopPrevious);
- }
- }
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment