Skip to content
Permalink
Browse files

Remove cast to Game in AudioSystem (#472)

  • Loading branch information
Hyperpred authored and xen2 committed Jul 2, 2019
1 parent e8f0272 commit 0a8d7bad749d2d4b08afe34a4cbea0a5aaf49b5a
@@ -2,10 +2,10 @@
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using System;
using System.Collections.Generic;
using Xenko.Core;
using Xenko.Core.Collections;
using Xenko.Engine;
using Xenko.Engine.Design;
using Xenko.Games;

namespace Xenko.Audio
@@ -54,7 +54,7 @@ public override void Initialize()
{
if (audioEngineSingleton == null)
{
var settings = ((Game)Game)?.Settings?.Configurations?.Get<AudioEngineSettings>();
var settings = Services.GetService<IGameSettingsService>()?.Settings?.Configurations?.Get<AudioEngineSettings>();
audioEngineSingleton = AudioEngineFactory.NewAudioEngine(RequestedAudioDevice, settings != null && settings.HrtfSupport ? AudioLayer.DeviceFlags.Hrtf : AudioLayer.DeviceFlags.None);
}
else
@@ -0,0 +1,13 @@
// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

namespace Xenko.Engine.Design
{
public interface IGameSettingsService
{
/// <summary>
/// Gets the GameSettings
/// </summary>
GameSettings Settings { get; }
}
}
@@ -30,7 +30,7 @@ namespace Xenko.Engine
/// <summary>
/// Main Game class system.
/// </summary>
public class Game : GameBase, ISceneRendererContext
public class Game : GameBase, ISceneRendererContext, IGameSettingsService
{
/// <summary>
/// Static event that will be fired when a game is initialized
@@ -272,6 +272,8 @@ protected override void PrepareContext()
if (!deviceManager.ShaderProfile.HasValue)
deviceManager.ShaderProfile = renderingSettings.DefaultGraphicsProfile;
}

Services.AddService<IGameSettingsService>(this);
}

// Load several default settings

0 comments on commit 0a8d7ba

Please sign in to comment.
You can’t perform that action at this time.