private void SoundEngine_OnBackgroundSongChanged(object sender, Engine.Sound.Sound e) { if (_activeSound != null && !_active.HasEnded) { var asnd = _activeSound; _activeSound = null; asnd.CompletionCallback(_activeSound); } if (_active != null) { _active.End(); } _activeSound = e; _active = _player.Cache.GetSound(e.AssetName).Play(SoundPlayer.ChannelGroup.Background); _active.Ended = (o) => { if (_activeSound?.CompletionCallback != null) { _activeSound.CompletionCallback(_activeSound); } }; _active.LoopCount = e.LoopCount; _active.Pitch = e.Pitch; _active.Playing = e.Playing; _active.Position = _player.PlayerPosition; _active.Velocity = _player.PlayerVelocity; _active.Time = e.Time; _active.Timescale = (float)_game.Timescale.Fractional * _activeSound.Timescale; _active.Volume = e.Volume; }
public ActiveGameEffect(Engine.Sound.Sound sound, SoundPlayer player) { SoundObject = sound; Instance = player.Cache.GetSound(sound.AssetName).Play(SoundPlayer.ChannelGroup.Effects); Instance.Ended = EndedHook; }