quantum-space-buddies/QSB/WorldSync/WorldRegistry.cs

27 lines
638 B
C#
Raw Normal View History

2020-08-13 17:25:12 +00:00
using System.Collections.Generic;
using System.Linq;
namespace QSB.WorldSync
{
public static class WorldRegistry
{
private static readonly List<WorldObject> _worldObjects = new List<WorldObject>();
public static void AddObject(WorldObject worldObject)
{
_worldObjects.Add(worldObject);
}
public static List<T> GetObjects<T>()
{
return _worldObjects.OfType<T>().ToList();
}
2020-08-13 17:25:12 +00:00
2020-08-13 18:43:47 +00:00
public static T GetObject<T>(int id) where T : WorldObject
2020-08-13 17:25:12 +00:00
{
return GetObjects<T>().FirstOrDefault(x => x.ObjectId == id);
2020-08-13 17:25:12 +00:00
}
2020-08-13 17:25:12 +00:00
}
}