Replace all T : Component constraints with T : IComponent (#4494)

This commit is contained in:
DrSmugleaf
2023-10-17 19:37:46 -07:00
committed by GitHub
parent f24d18f470
commit 6b6ec844e8
22 changed files with 362 additions and 373 deletions

View File

@@ -36,15 +36,15 @@ namespace Robust.Shared.GameObjects
private static readonly ComponentState DefaultComponentState = new();
private readonly Dictionary<Type, Dictionary<EntityUid, Component>> _entTraitDict
private readonly Dictionary<Type, Dictionary<EntityUid, IComponent>> _entTraitDict
= new();
private Dictionary<EntityUid, Component>[] _entTraitArray
= Array.Empty<Dictionary<EntityUid, Component>>();
private Dictionary<EntityUid, IComponent>[] _entTraitArray
= Array.Empty<Dictionary<EntityUid, IComponent>>();
private readonly HashSet<Component> _deleteSet = new(TypeCapacity);
private readonly HashSet<IComponent> _deleteSet = new(TypeCapacity);
private UniqueIndexHkm<EntityUid, Component> _entCompIndex =
private UniqueIndexHkm<EntityUid, IComponent> _entCompIndex =
new(ComponentCollectionCapacity);
/// <inheritdoc />
@@ -78,7 +78,7 @@ namespace Robust.Shared.GameObjects
private void AddComponentRefType(CompIdx type)
{
var dict = new Dictionary<EntityUid, Component>();
var dict = new Dictionary<EntityUid, IComponent>();
_entTraitDict.Add(_componentFactory.IdxToType(type), dict);
CompIdx.AssignArray(ref _entTraitArray, type, dict);
}
@@ -91,7 +91,7 @@ namespace Robust.Shared.GameObjects
#region Component Management
/// <inheritdoc />
public int Count<T>() where T : Component
public int Count<T>() where T : IComponent
{
var dict = _entTraitDict[typeof(T)];
return dict.Count;
@@ -114,7 +114,7 @@ namespace Robust.Shared.GameObjects
metadata.EntityLifeStage = EntityLifeStage.Initializing;
// Initialize() can modify the collection of components. Copy them.
FixedArray32<Component?> compsFixed = default;
FixedArray32<IComponent?> compsFixed = default;
var comps = compsFixed.AsSpan;
CopyComponentsInto(ref comps, uid);
@@ -145,7 +145,7 @@ namespace Robust.Shared.GameObjects
{
// Startup() can modify _components
// This code can only handle additions to the list. Is there a better way? Probably not.
FixedArray32<Component?> compsFixed = default;
FixedArray32<IComponent?> compsFixed = default;
var comps = compsFixed.AsSpan;
CopyComponentsInto(ref comps, uid);
@@ -182,7 +182,7 @@ namespace Robust.Shared.GameObjects
return newComponent;
}
public T AddComponent<T>(EntityUid uid) where T : Component, new()
public T AddComponent<T>(EntityUid uid) where T : IComponent, new()
{
var newComponent = _componentFactory.GetComponent<T>();
#pragma warning disable CS0618 // Type or member is obsolete
@@ -193,7 +193,7 @@ namespace Robust.Shared.GameObjects
}
public readonly struct CompInitializeHandle<T> : IDisposable
where T : Component
where T : IComponent
{
private readonly IEntityManager _entMan;
private readonly EntityUid _owner;
@@ -230,7 +230,7 @@ namespace Robust.Shared.GameObjects
/// <inheritdoc />
[Obsolete]
public CompInitializeHandle<T> AddComponentUninitialized<T>(EntityUid uid) where T : Component, new()
public CompInitializeHandle<T> AddComponentUninitialized<T>(EntityUid uid) where T : IComponent, new()
{
var reg = _componentFactory.GetRegistration<T>();
var newComponent = (T)_componentFactory.GetComponent(reg);
@@ -247,7 +247,7 @@ namespace Robust.Shared.GameObjects
}
/// <inheritdoc />
public void AddComponent<T>(EntityUid uid, T component, bool overwrite = false, MetaDataComponent? metadata = null) where T : Component
public void AddComponent<T>(EntityUid uid, T component, bool overwrite = false, MetaDataComponent? metadata = null) where T : IComponent
{
if (!uid.IsValid() || !EntityExists(uid))
throw new ArgumentException($"Entity {uid} is not valid.", nameof(uid));
@@ -268,14 +268,14 @@ namespace Robust.Shared.GameObjects
AddComponentInternal(uid, component, overwrite, false, metadata);
}
private void AddComponentInternal<T>(EntityUid uid, T component, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : Component
private void AddComponentInternal<T>(EntityUid uid, T component, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : IComponent
{
// get interface aliases for mapping
var reg = _componentFactory.GetRegistration(component);
AddComponentInternal(uid, component, reg, overwrite, skipInit, metadata);
}
private void AddComponentInternal<T>(EntityUid uid, T component, ComponentRegistration reg, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : Component
private void AddComponentInternal<T>(EntityUid uid, T component, ComponentRegistration reg, bool overwrite, bool skipInit, MetaDataComponent? metadata = null) where T : IComponent
{
// We can't use typeof(T) here in case T is just Component
DebugTools.Assert(component is MetaDataComponent ||
@@ -440,7 +440,7 @@ namespace Robust.Shared.GameObjects
RemoveComponentDeferred(component, owner, false);
}
private static IEnumerable<Component> InSafeOrder(IEnumerable<Component> comps, bool forCreation = false)
private static IEnumerable<IComponent> InSafeOrder(IEnumerable<IComponent> comps, bool forCreation = false)
{
static int Sequence(IComponent x)
=> x switch
@@ -527,7 +527,7 @@ namespace Robust.Shared.GameObjects
#endif
}
private void RemoveComponentImmediate(Component component, EntityUid uid, bool terminating,
private void RemoveComponentImmediate(IComponent component, EntityUid uid, bool terminating,
MetaDataComponent? meta)
{
if (component.Deleted)
@@ -602,7 +602,7 @@ namespace Robust.Shared.GameObjects
_deleteSet.Clear();
}
private void DeleteComponent(EntityUid entityUid, Component component, bool terminating, MetaDataComponent? metadata = null)
private void DeleteComponent(EntityUid entityUid, IComponent component, bool terminating, MetaDataComponent? metadata = null)
{
if (!MetaQuery.ResolveInternal(entityUid, ref metadata))
return;
@@ -643,7 +643,7 @@ namespace Robust.Shared.GameObjects
{
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
return dict!.TryGetValue(uid, out var comp) && !comp.Deleted;
return dict.TryGetValue(uid, out var comp) && !comp.Deleted;
}
/// <inheritdoc />
@@ -699,15 +699,14 @@ namespace Robust.Shared.GameObjects
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T EnsureComponent<T>(EntityUid uid) where T : Component, new()
public T EnsureComponent<T>(EntityUid uid) where T : IComponent, new()
{
if (TryGetComponent<T>(uid, out var component))
{
// Check for deferred component removal.
if (component.LifeStage <= ComponentLifeStage.Running)
return component;
else
RemoveComponent(uid, component);
RemoveComponent(uid, component);
}
return AddComponent<T>(uid);
@@ -715,7 +714,7 @@ namespace Robust.Shared.GameObjects
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool EnsureComponent<T>(EntityUid entity, out T component) where T : Component, new()
public bool EnsureComponent<T>(EntityUid entity, out T component) where T : IComponent, new()
{
if (TryGetComponent<T>(entity, out var comp))
{
@@ -725,8 +724,8 @@ namespace Robust.Shared.GameObjects
component = comp;
return true;
}
else
RemoveComponent(entity, comp);
RemoveComponent(entity, comp);
}
component = AddComponent<T>(entity);
@@ -739,11 +738,11 @@ namespace Robust.Shared.GameObjects
{
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
if (dict!.TryGetValue(uid, out var comp))
if (dict.TryGetValue(uid, out var comp))
{
if (!comp!.Deleted)
if (!comp.Deleted)
{
return (T)(IComponent) comp;
return (T)comp;
}
}
@@ -802,11 +801,11 @@ namespace Robust.Shared.GameObjects
{
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
if (dict!.TryGetValue(uid, out var comp))
if (dict.TryGetValue(uid, out var comp))
{
if (!comp.Deleted)
{
component = (T)(IComponent)comp;
component = (T)comp;
return true;
}
}
@@ -922,25 +921,25 @@ namespace Robust.Shared.GameObjects
return TryGetComponent(uid.Value, netId, out component, meta);
}
public EntityQuery<TComp1> GetEntityQuery<TComp1>() where TComp1 : Component
public EntityQuery<TComp1> GetEntityQuery<TComp1>() where TComp1 : IComponent
{
var comps = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
DebugTools.Assert(comps != null, $"Unknown component: {typeof(TComp1).Name}");
return new EntityQuery<TComp1>(comps!, _resolveSawmill);
return new EntityQuery<TComp1>(comps, _resolveSawmill);
}
public EntityQuery<Component> GetEntityQuery(Type type)
public EntityQuery<IComponent> GetEntityQuery(Type type)
{
var comps = _entTraitArray[CompIdx.ArrayIndex(type)];
DebugTools.Assert(comps != null, $"Unknown component: {type.Name}");
return new EntityQuery<Component>(comps!, _resolveSawmill);
return new EntityQuery<IComponent>(comps, _resolveSawmill);
}
/// <inheritdoc />
public IEnumerable<IComponent> GetComponents(EntityUid uid)
{
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (Component comp in _entCompIndex[uid].ToArray())
foreach (var comp in _entCompIndex[uid].ToArray())
{
if (comp.Deleted) continue;
@@ -957,14 +956,14 @@ namespace Robust.Shared.GameObjects
/// <summary>
/// Copy the components for an entity into the given span,
/// or re-allocate the span as an array if there's not enough space.
/// or re-allocate the span as an array if there's not enough space.º
/// </summary>
private void CopyComponentsInto(ref Span<Component?> comps, EntityUid uid)
private void CopyComponentsInto(ref Span<IComponent?> comps, EntityUid uid)
{
var set = _entCompIndex[uid];
if (set.Count > comps.Length)
{
comps = new Component[set.Count];
comps = new IComponent[set.Count];
}
var i = 0;
@@ -1003,7 +1002,7 @@ namespace Robust.Shared.GameObjects
#region Join Functions
public (EntityUid Uid, T Component)[] AllComponents<T>() where T : Component
public (EntityUid Uid, T Component)[] AllComponents<T>() where T : IComponent
{
var query = AllEntityQueryEnumerator<T>();
var comps = new (EntityUid Uid, T Component)[Count<T>()];
@@ -1018,7 +1017,7 @@ namespace Robust.Shared.GameObjects
return comps;
}
public List<(EntityUid Uid, T Component)> AllComponentsList<T>() where T : Component
public List<(EntityUid Uid, T Component)> AllComponentsList<T>() where T : IComponent
{
var query = AllEntityQueryEnumerator<T>();
var comps = new List<(EntityUid Uid, T Component)>(Count<T>());
@@ -1032,15 +1031,15 @@ namespace Robust.Shared.GameObjects
}
public AllEntityQueryEnumerator<TComp1> AllEntityQueryEnumerator<TComp1>()
where TComp1 : Component
where TComp1 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
return new AllEntityQueryEnumerator<TComp1>(trait1);
}
public AllEntityQueryEnumerator<TComp1, TComp2> AllEntityQueryEnumerator<TComp1, TComp2>()
where TComp1 : Component
where TComp2 : Component
where TComp1 : IComponent
where TComp2 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
@@ -1048,9 +1047,9 @@ namespace Robust.Shared.GameObjects
}
public AllEntityQueryEnumerator<TComp1, TComp2, TComp3> AllEntityQueryEnumerator<TComp1, TComp2, TComp3>()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
@@ -1059,10 +1058,10 @@ namespace Robust.Shared.GameObjects
}
public AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp4 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
where TComp4 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
@@ -1072,15 +1071,15 @@ namespace Robust.Shared.GameObjects
}
public EntityQueryEnumerator<TComp1> EntityQueryEnumerator<TComp1>()
where TComp1 : Component
where TComp1 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
return new EntityQueryEnumerator<TComp1>(trait1, MetaQuery);
}
public EntityQueryEnumerator<TComp1, TComp2> EntityQueryEnumerator<TComp1, TComp2>()
where TComp1 : Component
where TComp2 : Component
where TComp1 : IComponent
where TComp2 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
@@ -1088,9 +1087,9 @@ namespace Robust.Shared.GameObjects
}
public EntityQueryEnumerator<TComp1, TComp2, TComp3> EntityQueryEnumerator<TComp1, TComp2, TComp3>()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
@@ -1099,10 +1098,10 @@ namespace Robust.Shared.GameObjects
}
public EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4>()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp4 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
where TComp4 : IComponent
{
var trait1 = _entTraitArray[CompIdx.ArrayIndex<TComp1>()];
var trait2 = _entTraitArray[CompIdx.ArrayIndex<TComp2>()];
@@ -1120,11 +1119,11 @@ namespace Robust.Shared.GameObjects
if (includePaused)
{
foreach (var t1Comp in comps!.Values)
foreach (var t1Comp in comps.Values)
{
if (t1Comp.Deleted) continue;
yield return (T)(object)t1Comp;
yield return (T)t1Comp;
}
}
else
@@ -1135,7 +1134,7 @@ namespace Robust.Shared.GameObjects
if (metaComp.EntityPaused) continue;
yield return (T)(object)t1Comp;
yield return (T)t1Comp;
}
}
}
@@ -1158,8 +1157,8 @@ namespace Robust.Shared.GameObjects
continue;
yield return (
(TComp1)(object)t1Comp,
(TComp2)(object)t2Comp);
(TComp1) t1Comp,
(TComp2) t2Comp);
}
}
else
@@ -1179,8 +1178,8 @@ namespace Robust.Shared.GameObjects
if (meta.EntityPaused) continue;
yield return (
(TComp1)(object)t1Comp,
(TComp2)(object)t2Comp);
(TComp1) t1Comp,
(TComp2) t2Comp);
}
}
}
@@ -1206,9 +1205,9 @@ namespace Robust.Shared.GameObjects
continue;
yield return (
(TComp1)(object)t1Comp,
(TComp2)(object)t2Comp,
(TComp3)(object)t3Comp);
(TComp1) t1Comp,
(TComp2) t2Comp,
(TComp3) t3Comp);
}
}
else
@@ -1231,9 +1230,9 @@ namespace Robust.Shared.GameObjects
if (meta.EntityPaused) continue;
yield return (
(TComp1)(object)t1Comp,
(TComp2)(object)t2Comp,
(TComp3)(object)t3Comp);
(TComp1) t1Comp,
(TComp2) t2Comp,
(TComp3) t3Comp);
}
}
}
@@ -1265,10 +1264,10 @@ namespace Robust.Shared.GameObjects
continue;
yield return (
(TComp1)(object)t1Comp,
(TComp2)(object)t2Comp,
(TComp3)(object)t3Comp,
(TComp4)(object)t4Comp);
(TComp1) t1Comp,
(TComp2) t2Comp,
(TComp3) t3Comp,
(TComp4) t4Comp);
}
}
else
@@ -1294,10 +1293,10 @@ namespace Robust.Shared.GameObjects
if (meta.EntityPaused) continue;
yield return (
(TComp1)(object)t1Comp,
(TComp2)(object)t2Comp,
(TComp3)(object)t3Comp,
(TComp4)(object)t4Comp);
(TComp1) t1Comp,
(TComp2) t2Comp,
(TComp3) t3Comp,
(TComp4) t4Comp);
}
}
}
@@ -1305,7 +1304,7 @@ namespace Robust.Shared.GameObjects
#endregion
/// <inheritdoc />
public IEnumerable<(EntityUid Uid, Component Component)> GetAllComponents(Type type, bool includePaused = false)
public IEnumerable<(EntityUid Uid, IComponent Component)> GetAllComponents(Type type, bool includePaused = false)
{
var comps = _entTraitDict[type];
@@ -1363,23 +1362,23 @@ namespace Robust.Shared.GameObjects
public readonly struct NetComponentEnumerable
{
private readonly Dictionary<ushort, Component> _dictionary;
private readonly Dictionary<ushort, IComponent> _dictionary;
public NetComponentEnumerable(Dictionary<ushort, Component> dictionary) => _dictionary = dictionary;
public NetComponentEnumerable(Dictionary<ushort, IComponent> dictionary) => _dictionary = dictionary;
public NetComponentEnumerator GetEnumerator() => new(_dictionary);
}
public struct NetComponentEnumerator
{
// DO NOT MAKE THIS READONLY
private Dictionary<ushort, Component>.Enumerator _dictEnum;
private Dictionary<ushort, IComponent>.Enumerator _dictEnum;
public NetComponentEnumerator(Dictionary<ushort, Component> dictionary) =>
public NetComponentEnumerator(Dictionary<ushort, IComponent> dictionary) =>
_dictEnum = dictionary.GetEnumerator();
public bool MoveNext() => _dictEnum.MoveNext();
public (ushort netId, Component component) Current
public (ushort netId, IComponent component) Current
{
get
{
@@ -1389,12 +1388,12 @@ namespace Robust.Shared.GameObjects
}
}
public readonly struct EntityQuery<TComp1> where TComp1 : Component
public readonly struct EntityQuery<TComp1> where TComp1 : IComponent
{
private readonly Dictionary<EntityUid, Component> _traitDict;
private readonly Dictionary<EntityUid, IComponent> _traitDict;
private readonly ISawmill _sawmill;
public EntityQuery(Dictionary<EntityUid, Component> traitDict, ISawmill sawmill)
public EntityQuery(Dictionary<EntityUid, IComponent> traitDict, ISawmill sawmill)
{
_traitDict = traitDict;
_sawmill = sawmill;
@@ -1482,7 +1481,7 @@ namespace Robust.Shared.GameObjects
if (TryGetComponent(uid, out var comp))
return comp;
return null;
return default;
}
#region Internal
@@ -1534,7 +1533,7 @@ namespace Robust.Shared.GameObjects
}
/// <summary>
/// Elides the component.Deleted check of <see cref="HasComponent"/>
/// Elides the component.Deleted check of <see cref="HasComponent(EntityUid)"/>
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Pure]
@@ -1579,7 +1578,7 @@ namespace Robust.Shared.GameObjects
if (TryGetComponent(uid, out var comp))
return comp;
return null;
return default;
}
#endregion
@@ -1591,13 +1590,13 @@ namespace Robust.Shared.GameObjects
/// Returns all matching unpaused components.
/// </summary>
public struct EntityQueryEnumerator<TComp1> : IDisposable
where TComp1 : Component
where TComp1 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
private readonly EntityQuery<MetaDataComponent> _metaQuery;
public EntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict,
Dictionary<EntityUid, IComponent> traitDict,
EntityQuery<MetaDataComponent> metaQuery)
{
_traitDict = traitDict.GetEnumerator();
@@ -1611,7 +1610,7 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp1 = default;
return false;
}
@@ -1649,16 +1648,16 @@ namespace Robust.Shared.GameObjects
/// Returns all matching unpaused components.
/// </summary>
public struct EntityQueryEnumerator<TComp1, TComp2> : IDisposable
where TComp1 : Component
where TComp2 : Component
where TComp1 : IComponent
where TComp2 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, Component> _traitDict2;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
private readonly EntityQuery<MetaDataComponent> _metaQuery;
public EntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict,
Dictionary<EntityUid, Component> traitDict2,
Dictionary<EntityUid, IComponent> traitDict,
Dictionary<EntityUid, IComponent> traitDict2,
EntityQuery<MetaDataComponent> metaQuery)
{
_traitDict = traitDict.GetEnumerator();
@@ -1673,8 +1672,8 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp2 = null;
comp1 = default;
comp2 = default;
return false;
}
@@ -1718,19 +1717,19 @@ namespace Robust.Shared.GameObjects
/// Returns all matching unpaused components.
/// </summary>
public struct EntityQueryEnumerator<TComp1, TComp2, TComp3> : IDisposable
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, Component> _traitDict2;
private readonly Dictionary<EntityUid, Component> _traitDict3;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
private readonly EntityQuery<MetaDataComponent> _metaQuery;
public EntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict,
Dictionary<EntityUid, Component> traitDict2,
Dictionary<EntityUid, Component> traitDict3,
Dictionary<EntityUid, IComponent> traitDict,
Dictionary<EntityUid, IComponent> traitDict2,
Dictionary<EntityUid, IComponent> traitDict3,
EntityQuery<MetaDataComponent> metaQuery)
{
_traitDict = traitDict.GetEnumerator();
@@ -1746,9 +1745,9 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp2 = null;
comp3 = null;
comp1 = default;
comp2 = default;
comp3 = default;
return false;
}
@@ -1801,22 +1800,22 @@ namespace Robust.Shared.GameObjects
/// Returns all matching unpaused components.
/// </summary>
public struct EntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> : IDisposable
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp4 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
where TComp4 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, Component> _traitDict2;
private readonly Dictionary<EntityUid, Component> _traitDict3;
private readonly Dictionary<EntityUid, Component> _traitDict4;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
private readonly Dictionary<EntityUid, IComponent> _traitDict4;
private readonly EntityQuery<MetaDataComponent> _metaQuery;
public EntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict,
Dictionary<EntityUid, Component> traitDict2,
Dictionary<EntityUid, Component> traitDict3,
Dictionary<EntityUid, Component> traitDict4,
Dictionary<EntityUid, IComponent> traitDict,
Dictionary<EntityUid, IComponent> traitDict2,
Dictionary<EntityUid, IComponent> traitDict3,
Dictionary<EntityUid, IComponent> traitDict4,
EntityQuery<MetaDataComponent> metaQuery)
{
_traitDict = traitDict.GetEnumerator();
@@ -1833,10 +1832,10 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp2 = null;
comp3 = null;
comp4 = null;
comp1 = default;
comp2 = default;
comp3 = default;
comp4 = default;
return false;
}
@@ -1900,12 +1899,12 @@ namespace Robust.Shared.GameObjects
/// Returns all matching components, paused or not.
/// </summary>
public struct AllEntityQueryEnumerator<TComp1> : IDisposable
where TComp1 : Component
where TComp1 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
public AllEntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict)
Dictionary<EntityUid, IComponent> traitDict)
{
_traitDict = traitDict.GetEnumerator();
}
@@ -1917,7 +1916,7 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp1 = default;
return false;
}
@@ -1950,15 +1949,15 @@ namespace Robust.Shared.GameObjects
/// Returns all matching components, paused or not.
/// </summary>
public struct AllEntityQueryEnumerator<TComp1, TComp2> : IDisposable
where TComp1 : Component
where TComp2 : Component
where TComp1 : IComponent
where TComp2 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, Component> _traitDict2;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
public AllEntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict,
Dictionary<EntityUid, Component> traitDict2)
Dictionary<EntityUid, IComponent> traitDict,
Dictionary<EntityUid, IComponent> traitDict2)
{
_traitDict = traitDict.GetEnumerator();
_traitDict2 = traitDict2;
@@ -1971,8 +1970,8 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp2 = null;
comp1 = default;
comp2 = default;
return false;
}
@@ -2011,18 +2010,18 @@ namespace Robust.Shared.GameObjects
/// Returns all matching components, paused or not.
/// </summary>
public struct AllEntityQueryEnumerator<TComp1, TComp2, TComp3> : IDisposable
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, Component> _traitDict2;
private readonly Dictionary<EntityUid, Component> _traitDict3;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
public AllEntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict,
Dictionary<EntityUid, Component> traitDict2,
Dictionary<EntityUid, Component> traitDict3)
Dictionary<EntityUid, IComponent> traitDict,
Dictionary<EntityUid, IComponent> traitDict2,
Dictionary<EntityUid, IComponent> traitDict3)
{
_traitDict = traitDict.GetEnumerator();
_traitDict2 = traitDict2;
@@ -2036,9 +2035,9 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp2 = null;
comp3 = null;
comp1 = default;
comp2 = default;
comp3 = default;
return false;
}
@@ -2086,21 +2085,21 @@ namespace Robust.Shared.GameObjects
/// Returns all matching components, paused or not.
/// </summary>
public struct AllEntityQueryEnumerator<TComp1, TComp2, TComp3, TComp4> : IDisposable
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp4 : Component
where TComp1 : IComponent
where TComp2 : IComponent
where TComp3 : IComponent
where TComp4 : IComponent
{
private Dictionary<EntityUid, Component>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, Component> _traitDict2;
private readonly Dictionary<EntityUid, Component> _traitDict3;
private readonly Dictionary<EntityUid, Component> _traitDict4;
private Dictionary<EntityUid, IComponent>.Enumerator _traitDict;
private readonly Dictionary<EntityUid, IComponent> _traitDict2;
private readonly Dictionary<EntityUid, IComponent> _traitDict3;
private readonly Dictionary<EntityUid, IComponent> _traitDict4;
public AllEntityQueryEnumerator(
Dictionary<EntityUid, Component> traitDict,
Dictionary<EntityUid, Component> traitDict2,
Dictionary<EntityUid, Component> traitDict3,
Dictionary<EntityUid, Component> traitDict4)
Dictionary<EntityUid, IComponent> traitDict,
Dictionary<EntityUid, IComponent> traitDict2,
Dictionary<EntityUid, IComponent> traitDict3,
Dictionary<EntityUid, IComponent> traitDict4)
{
_traitDict = traitDict.GetEnumerator();
_traitDict2 = traitDict2;
@@ -2115,10 +2114,10 @@ namespace Robust.Shared.GameObjects
if (!_traitDict.MoveNext())
{
uid = default;
comp1 = null;
comp2 = null;
comp3 = null;
comp4 = null;
comp1 = default;
comp2 = default;
comp3 = default;
comp4 = default;
return false;
}