2020-08-13 17:25:12 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace QSB.WorldSync
|
|
|
|
|
{
|
|
|
|
|
public static class WorldRegistry
|
|
|
|
|
{
|
2020-08-16 15:15:36 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
2020-08-16 15:15:36 +00:00
|
|
|
|
_worldObjects.Add(worldObject);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-16 20:39:21 +00:00
|
|
|
|
public static IEnumerable<T> GetObjects<T>()
|
2020-08-16 15:15:36 +00:00
|
|
|
|
{
|
2020-08-16 20:39:21 +00:00
|
|
|
|
return _worldObjects.OfType<T>();
|
2020-08-16 15:15:36 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
2020-08-16 15:15:36 +00:00
|
|
|
|
return GetObjects<T>().FirstOrDefault(x => x.ObjectId == id);
|
2020-08-13 17:25:12 +00:00
|
|
|
|
}
|
2020-08-16 15:15:36 +00:00
|
|
|
|
|
2020-08-13 17:25:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|