axiosengine/axios/Engine/GameServices.cs

40 lines
956 B
C#
Raw Normal View History

using Microsoft.Xna.Framework;
namespace Axios.Engine
{
public static class GameServices
{
private static GameServiceContainer container;
private static object lockobj = new object();
public static GameServiceContainer Instance
{
get
{
lock (GameServices.lockobj)
{
if (container == null)
{
container = new GameServiceContainer();
}
}
return container;
}
}
public static T GetService<T>()
{
return (T)Instance.GetService(typeof(T));
}
public static void AddService<T>(T service)
{
Instance.AddService(typeof(T), service);
}
public static void RemoveService<T>()
{
Instance.RemoveService(typeof(T));
}
}
}