Remove LungBehavior and replace with LungComponent/System (#5630)

This commit is contained in:
mirrorcult
2021-11-30 18:25:02 -07:00
committed by GitHub
parent e3af2b5727
commit ccf01d7431
11 changed files with 311 additions and 242 deletions

View File

@@ -40,8 +40,15 @@ namespace Content.Server.Body.Systems
}
}
public IEnumerable<T> GetComponentsOnMechanisms<T>(EntityUid uid,
SharedBodyComponent? body) where T : Component
/// <summary>
/// Returns a list of ValueTuples of <see cref="T"/> and SharedMechanismComponent on each mechanism
/// in the given body.
/// </summary>
/// <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, SharedMechanismComponent Mech)> GetComponentsOnMechanisms<T>(EntityUid uid,
SharedBodyComponent? body=null) where T : Component
{
if (!Resolve(uid, ref body))
yield break;
@@ -50,13 +57,22 @@ namespace Content.Server.Body.Systems
foreach (var mechanism in part.Mechanisms)
{
if (EntityManager.TryGetComponent<T>(mechanism.OwnerUid, out var comp))
yield return comp;
yield return (comp, mechanism);
}
}
/// <summary>
/// Tries to get a list of ValueTuples of <see cref="T"/> and SharedMechanismComponent on each mechanism
/// in the given body.
/// </summary>
/// <param name="uid">The entity to check for the component on.</param>
/// <param name="comps">The list of components.</param>
/// <param name="body">The body to check for mechanisms on.</param>
/// <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>? comps,
SharedBodyComponent? body) where T: Component
[NotNullWhen(true)] out IEnumerable<(T Comp, SharedMechanismComponent Mech)>? comps,
SharedBodyComponent? body=null) where T: Component
{
if (!Resolve(uid, ref body))
{