Don't use ienumerable stuff in body system (#7316)
This commit is contained in:
@@ -47,18 +47,22 @@ namespace Content.Server.Body.Systems
|
||||
/// <param name="uid">The entity to check for the component on.</param>
|
||||
/// <param name="body">The body to check for mechanisms on.</param>
|
||||
/// <typeparam name="T">The component to check for.</typeparam>
|
||||
public IEnumerable<(T Comp, MechanismComponent Mech)> GetComponentsOnMechanisms<T>(EntityUid uid,
|
||||
public List<(T Comp, MechanismComponent Mech)> GetComponentsOnMechanisms<T>(EntityUid uid,
|
||||
SharedBodyComponent? body=null) where T : Component
|
||||
{
|
||||
if (!Resolve(uid, ref body))
|
||||
yield break;
|
||||
return new();
|
||||
|
||||
var query = EntityManager.GetEntityQuery<T>();
|
||||
var list = new List<(T Comp, MechanismComponent Mech)>(3);
|
||||
foreach (var (part, _) in body.Parts)
|
||||
foreach (var mechanism in part.Mechanisms)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<T>((mechanism).Owner, out var comp))
|
||||
yield return (comp, mechanism);
|
||||
if (query.TryGetComponent(mechanism.Owner, out var comp))
|
||||
list.Add((comp, mechanism));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +75,7 @@ namespace Content.Server.Body.Systems
|
||||
/// <typeparam name="T">The component to check for.</typeparam>
|
||||
/// <returns>Whether any were found.</returns>
|
||||
public bool TryGetComponentsOnMechanisms<T>(EntityUid uid,
|
||||
[NotNullWhen(true)] out IEnumerable<(T Comp, MechanismComponent Mech)>? comps,
|
||||
[NotNullWhen(true)] out List<(T Comp, MechanismComponent Mech)>? comps,
|
||||
SharedBodyComponent? body=null) where T: Component
|
||||
{
|
||||
if (!Resolve(uid, ref body))
|
||||
@@ -80,9 +84,9 @@ namespace Content.Server.Body.Systems
|
||||
return false;
|
||||
}
|
||||
|
||||
comps = GetComponentsOnMechanisms<T>(uid, body).ToArray();
|
||||
comps = GetComponentsOnMechanisms<T>(uid, body);
|
||||
|
||||
if (!comps.Any())
|
||||
if (comps.Count == 0)
|
||||
{
|
||||
comps = null;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user