Files
wwdpublic/Content.Shared/Hands/Components/HandHelpers.cs
RedFoxIV 6d4215b08d dollar store spookston (#258)
* initial sidestream port

* ru locale

* blyatison

* упс

* jannie qol (#6)

* initial sidestream port

* blyadison

* cs1.4 (#4)

* initial sidestream port
* blyatison

* antitryaska (#7)

* initial sidestream port (still fucked though)

* blyatison

* o fugg (#8) speedmerge

* o fugg

* fugg :-DDD

* attempt numero uno (#9)

* fix desword sound (#10)

* раз уж я тут сижу

* whoops

* shit

---------

Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com>
2025-03-03 14:29:21 +02:00

46 lines
2.1 KiB
C#

using System.Linq;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
namespace Content.Shared._White.Hands.Components;
/// <summary>
/// These helpers exist to make getting basic information out of the hands component more convenient, without
/// needing to resolve hands system or something like that.
/// </summary>
public static class HandHelpers
{
/// <summary>
/// Returns true if any hand is free. This is a LinQ method, not a property, so
/// cache it instead of accessing this multiple times.
/// </summary>
public static bool IsAnyHandFree(this HandsComponent component) => component.Hands.Values.Any(hand => hand.IsEmpty);
/// <summary>
/// Get the number of hands that are not currently holding anything. This is a LinQ method, not a property, so
/// cache it instead of accessing this multiple times.
/// </summary>
public static int CountFreeHands(this HandsComponent component) => component.Hands.Values.Count(hand => hand.IsEmpty);
/// <summary>
/// Get the number of hands that are not currently holding anything. This is a LinQ method, not a property, so
/// cache it instead of accessing this multiple times.
/// </summary>
public static int CountFreeableHands(this Entity<HandsComponent> component, SharedHandsSystem system)
{
return system.CountFreeableHands(component);
}
/// <summary>
/// Get a list of hands that are currently holding nothing. This is a LinQ method, not a property, so cache
/// it instead of accessing this multiple times.
/// </summary>
public static IEnumerable<Hand> GetFreeHands(this HandsComponent component) => component.Hands.Values.Where(hand => !hand.IsEmpty);
/// <summary>
/// Get a list of hands that are currently holding nothing. This is a LinQ method, not a property, so cache
/// it instead of accessing this multiple times.
/// </summary>
public static IEnumerable<string> GetFreeHandNames(this HandsComponent component) => component.GetFreeHands().Select(hand => hand.Name);
}