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

40 lines
1.3 KiB
C#
Raw Normal View History

2020-08-28 10:08:40 +00:00
using QSB.TransformSync;
using System.Collections.Generic;
2020-08-13 17:25:12 +00:00
using System.Linq;
namespace QSB.WorldSync
{
public static class WorldRegistry
{
private static readonly List<WorldObject> _worldObjects = new List<WorldObject>();
2020-08-28 10:08:40 +00:00
public static uint OrbStartNetId { get; set; }
public static List<NomaiOrbTransformSync> OrbList = new List<NomaiOrbTransformSync>();
public static List<NomaiInterfaceOrb> OldOrbList = new List<NomaiInterfaceOrb>();
public static Dictionary<NomaiInterfaceOrb, uint> OrbUserList = new Dictionary<NomaiInterfaceOrb, uint>();
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-28 10:08:40 +00:00
public static bool IsOrbControlledLocally(NomaiInterfaceOrb orb)
{
return OrbUserList[orb] == PlayerRegistry.LocalPlayerId;
}
2020-08-13 17:25:12 +00:00
}
}