public virtual void PlaySound(string name) { if (string.IsNullOrEmpty(name)) { return; } var mode = Transform3D != null ? SoundModes.Mode3D : 0; Sound sound = SoundWorld.SoundCreate(name, mode); if (sound == null) { return; } //!!!!attachedToScene var channel = SoundWorld.SoundPlay(null, sound, EngineApp.DefaultSoundChannelGroup, 0.5, true); if (channel != null) { if (Transform3D != null) { channel.Position = Transform3D.Position; //channel.Velocity = xxx; } channel.Pause = false; } }
//public Sound Sound //{ // get { return sound; } //} //Sound GetSoundByMode( SoundModes mode ) //{ // soundByMode.TryGetValue( mode, out var sound ); // return sound; //} public Sound LoadSoundByMode(SoundModes mode) { if (!soundByMode.TryGetValue(mode, out var sound)) { //!!!!threading var v = owner.LoadFile.Value; var resourceName = v != null ? v.ResourceName : ""; if (VirtualFile.Exists(resourceName)) { sound = SoundWorld.SoundCreate(resourceName, mode); } soundByMode.Add(mode, sound); } return(sound); }