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

31 lines
741 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)
{
2020-08-23 19:52:22 +00:00
if (_worldObjects.Contains(worldObject))
{
return;
}
_worldObjects.Add(worldObject);
}
2020-08-16 20:39:21 +00:00
public static IEnumerable<T> GetObjects<T>()
{
2020-08-16 20:39:21 +00:00
return _worldObjects.OfType<T>();
}
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
}
}