Remove hands component reference (#15197)
This commit is contained in:
@@ -12,23 +12,23 @@ public static class HandHelpers
|
||||
/// 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 SharedHandsComponent component) => component.Hands.Values.Any(hand => hand.IsEmpty);
|
||||
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 SharedHandsComponent component) => component.Hands.Values.Count(hand => hand.IsEmpty);
|
||||
public static int CountFreeHands(this HandsComponent component) => component.Hands.Values.Count(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<Hand> GetFreeHands(this SharedHandsComponent component) => component.Hands.Values.Where(hand => !hand.IsEmpty);
|
||||
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 SharedHandsComponent component) => GetFreeHands(component).Select(hand => hand.Name);
|
||||
public static IEnumerable<string> GetFreeHandNames(this HandsComponent component) => GetFreeHands(component).Select(hand => hand.Name);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Hands.Components;
|
||||
|
||||
[NetworkedComponent]
|
||||
public abstract class SharedHandsComponent : Component
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(SharedHandsSystem))]
|
||||
public sealed class HandsComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The currently active hand.
|
||||
@@ -42,6 +44,19 @@ public abstract class SharedHandsComponent : Component
|
||||
[DataField("throwRange")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ThrowRange { get; set; } = 8f;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to add in-hand sprites for held items. Some entities (e.g., drones) don't want these.
|
||||
/// Used by the client.
|
||||
/// </summary>
|
||||
[DataField("showInHands")]
|
||||
public bool ShowInHands = true;
|
||||
|
||||
/// <summary>
|
||||
/// Data about the current sprite layers that the hand is contributing to the owner entity. Used for sprite in-hands.
|
||||
/// Used by the client.
|
||||
/// </summary>
|
||||
public readonly Dictionary<HandLocation, HashSet<string>> RevealedLayers = new();
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
@@ -80,7 +95,7 @@ public sealed class HandsComponentState : ComponentState
|
||||
public readonly List<string> HandNames;
|
||||
public readonly string? ActiveHand;
|
||||
|
||||
public HandsComponentState(SharedHandsComponent handComp)
|
||||
public HandsComponentState(HandsComponent handComp)
|
||||
{
|
||||
Hands = new(handComp.Hands.Values);
|
||||
HandNames = handComp.SortedHands;
|
||||
Reference in New Issue
Block a user