Remove hands component reference (#15197)

This commit is contained in:
DrSmugleaf
2023-04-07 11:21:12 -07:00
committed by GitHub
parent c54ee5290b
commit b947856431
73 changed files with 277 additions and 328 deletions

View File

@@ -3,7 +3,6 @@ using Content.Shared.Access.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Inventory;
using Content.Shared.PDA;
using Robust.Shared.GameStates;
namespace Content.Shared.Access.Systems;
@@ -18,7 +17,7 @@ public abstract class SharedIdCardSystem : EntitySystem
public bool TryFindIdCard(EntityUid uid, [NotNullWhen(true)] out IdCardComponent? idCard)
{
// check held item?
if (EntityManager.TryGetComponent(uid, out SharedHandsComponent? hands) &&
if (EntityManager.TryGetComponent(uid, out HandsComponent? hands) &&
hands.ActiveHandEntity is EntityUid heldItem &&
TryGetIdCard(heldItem, out idCard))
{

View File

@@ -14,7 +14,6 @@ using Content.Shared.Popups;
using Content.Shared.Toggleable;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
@@ -85,7 +84,7 @@ public sealed partial class BlockingSystem : EntitySystem
return;
var blockQuery = GetEntityQuery<BlockingComponent>();
var handQuery = GetEntityQuery<SharedHandsComponent>();
var handQuery = GetEntityQuery<HandsComponent>();
if (!handQuery.TryGetComponent(args.Performer, out var hands))
return;
@@ -265,7 +264,7 @@ public sealed partial class BlockingSystem : EntitySystem
StopBlocking(uid, component, user);
var userQuery = GetEntityQuery<BlockingUserComponent>();
var handQuery = GetEntityQuery<SharedHandsComponent>();
var handQuery = GetEntityQuery<HandsComponent>();
if (!handQuery.TryGetComponent(user, out var hands))
return;

View File

@@ -1,4 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.ActionBlocker;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Destructible;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
@@ -8,13 +11,9 @@ using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Player;
using Robust.Shared.Utility;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Robust.Shared.Network;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Shared.Containers.ItemSlots
{
@@ -193,7 +192,7 @@ namespace Content.Shared.Containers.ItemSlots
if (args.Handled)
return;
if (!EntityManager.TryGetComponent(args.User, out SharedHandsComponent? hands))
if (!EntityManager.TryGetComponent(args.User, out HandsComponent? hands))
return;
foreach (var slot in itemSlots.Slots.Values)
@@ -296,7 +295,7 @@ namespace Content.Shared.Containers.ItemSlots
/// Does not check action blockers.
/// </summary>
/// <returns>False if failed to insert item</returns>
public bool TryInsertFromHand(EntityUid uid, ItemSlot slot, EntityUid user, SharedHandsComponent? hands = null)
public bool TryInsertFromHand(EntityUid uid, ItemSlot slot, EntityUid user, HandsComponent? hands = null)
{
if (!Resolve(user, ref hands, false))
return false;

View File

@@ -151,7 +151,7 @@ namespace Content.Shared.Cuffs
public void UpdateCuffState(EntityUid uid, CuffableComponent component)
{
var canInteract = TryComp(uid, out SharedHandsComponent? hands) && hands.Hands.Count > component.CuffedHandCount;
var canInteract = TryComp(uid, out HandsComponent? hands) && hands.Hands.Count > component.CuffedHandCount;
if (canInteract == component.CanStillInteract)
return;
@@ -344,7 +344,7 @@ namespace Content.Shared.Cuffs
}
var dirty = false;
var handCount = CompOrNull<SharedHandsComponent>(owner)?.Count ?? 0;
var handCount = CompOrNull<HandsComponent>(owner)?.Count ?? 0;
while (cuffable.CuffedHandCount > handCount && cuffable.CuffedHandCount > 0)
{
@@ -374,7 +374,7 @@ namespace Content.Shared.Cuffs
// TODO we probably don't just want to use the generic virtual-item entity, and instead
// want to add our own item, so that use-in-hand triggers an uncuff attempt and the like.
if (!TryComp<SharedHandsComponent>(uid, out var handsComponent))
if (!TryComp<HandsComponent>(uid, out var handsComponent))
return;
var freeHands = 0;
@@ -427,7 +427,7 @@ namespace Content.Shared.Cuffs
if (!Resolve(handcuff, ref handcuffComponent) || !Resolve(target, ref cuffable, false))
return;
if (!TryComp<SharedHandsComponent?>(target, out var hands))
if (!TryComp<HandsComponent?>(target, out var hands))
{
if (_net.IsServer)
{

View File

@@ -13,7 +13,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
var time = GameTiming.CurTime;
var xformQuery = GetEntityQuery<TransformComponent>();
var handsQuery = GetEntityQuery<SharedHandsComponent>();
var handsQuery = GetEntityQuery<HandsComponent>();
var enumerator = EntityQueryEnumerator<ActiveDoAfterComponent, DoAfterComponent>();
while (enumerator.MoveNext(out var uid, out var active, out var comp))
@@ -28,7 +28,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
DoAfterComponent comp,
TimeSpan time,
EntityQuery<TransformComponent> xformQuery,
EntityQuery<SharedHandsComponent> handsQuery)
EntityQuery<HandsComponent> handsQuery)
{
var dirty = false;
@@ -122,7 +122,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
private bool ShouldCancel(DoAfter doAfter,
EntityQuery<TransformComponent> xformQuery,
EntityQuery<SharedHandsComponent> handsQuery)
EntityQuery<HandsComponent> handsQuery)
{
var args = doAfter.Args;

View File

@@ -203,7 +203,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
// (or if there is no item there we need to keep it free).
if (args.NeedHand && args.BreakOnHandChange)
{
if (!TryComp(args.User, out SharedHandsComponent? handsComponent))
if (!TryComp(args.User, out HandsComponent? handsComponent))
return false;
doAfter.InitialHand = handsComponent.ActiveHand?.Name;
@@ -211,7 +211,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
}
// Inital checks
if (ShouldCancel(doAfter, GetEntityQuery<TransformComponent>(), GetEntityQuery<SharedHandsComponent>()))
if (ShouldCancel(doAfter, GetEntityQuery<TransformComponent>(), GetEntityQuery<HandsComponent>()))
return false;
if (args.AttemptFrequency == AttemptFrequency.StartAndEnd && !TryAttemptEvent(doAfter))

View File

@@ -1,23 +1,20 @@
using System.Linq;
using Content.Shared.Access.Components;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.Doors.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Stunnable;
using Content.Shared.Tag;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Timing;
using System.Linq;
using Content.Shared.DoAfter;
using Content.Shared.Tag;
using Content.Shared.Tools.Components;
using Content.Shared.Verbs;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
namespace Content.Shared.Doors.Systems;
@@ -285,7 +282,7 @@ public abstract class SharedDoorSystem : EntitySystem
// component, but no actual hands!? What!? Is this the sound of them head-butting the door to get it to open??
// I'm 99% sure something is wrong here, but I kind of want to keep it this way.
if (user != null && TryComp(user.Value, out SharedHandsComponent? hands) && hands.Hands.Count == 0)
if (user != null && TryComp(user.Value, out HandsComponent? hands) && hands.Hands.Count == 0)
PlaySound(uid, door.TryOpenDoorSound, AudioParams.Default.WithVolume(-2), user, predicted);
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -1,5 +1,5 @@
using Content.Shared.Hands.Components;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Hands.Components;
namespace Content.Shared.Hands.EntitySystems;
@@ -8,7 +8,7 @@ namespace Content.Shared.Hands.EntitySystems;
public abstract partial class SharedHandsSystem : EntitySystem
{
public bool TrySelect(EntityUid uid, EntityUid? entity, SharedHandsComponent? handsComp = null)
public bool TrySelect(EntityUid uid, EntityUid? entity, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
return false;
@@ -20,7 +20,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
return true;
}
public bool TrySelect<TComponent>(EntityUid uid, [NotNullWhen(true)] out TComponent? component, SharedHandsComponent? handsComp = null) where TComponent : Component
public bool TrySelect<TComponent>(EntityUid uid, [NotNullWhen(true)] out TComponent? component, HandsComponent? handsComp = null) where TComponent : Component
{
component = null;
if (!Resolve(uid, ref handsComp, false))
@@ -35,5 +35,5 @@ public abstract partial class SharedHandsSystem : EntitySystem
return false;
}
public bool TrySelectEmptyHand(EntityUid uid, SharedHandsComponent? handsComp = null) => TrySelect(uid, null, handsComp);
public bool TrySelectEmptyHand(EntityUid uid, HandsComponent? handsComp = null) => TrySelect(uid, null, handsComp);
}

View File

@@ -27,7 +27,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Attempts to drop the item in the currently active hand.
/// </summary>
public bool TryDrop(EntityUid uid, EntityCoordinates? targetDropLocation = null, bool checkActionBlocker = true, bool doDropInteraction = true, SharedHandsComponent? handsComp = null)
public bool TryDrop(EntityUid uid, EntityCoordinates? targetDropLocation = null, bool checkActionBlocker = true, bool doDropInteraction = true, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp))
return false;
@@ -41,7 +41,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Drops an item at the target location.
/// </summary>
public bool TryDrop(EntityUid uid, EntityUid entity, EntityCoordinates? targetDropLocation = null, bool checkActionBlocker = true, bool doDropInteraction = true, SharedHandsComponent? handsComp = null)
public bool TryDrop(EntityUid uid, EntityUid entity, EntityCoordinates? targetDropLocation = null, bool checkActionBlocker = true, bool doDropInteraction = true, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp))
return false;
@@ -55,7 +55,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Drops a hands contents at the target location.
/// </summary>
public bool TryDrop(EntityUid uid, Hand hand, EntityCoordinates? targetDropLocation = null, bool checkActionBlocker = true, bool doDropInteraction = true, SharedHandsComponent? handsComp = null)
public bool TryDrop(EntityUid uid, Hand hand, EntityCoordinates? targetDropLocation = null, bool checkActionBlocker = true, bool doDropInteraction = true, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp))
return false;
@@ -90,7 +90,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Attempts to move a held item from a hand into a container that is not another hand, without dropping it on the floor in-between.
/// </summary>
public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, IContainer targetContainer, bool checkActionBlocker = true, SharedHandsComponent? handsComp = null)
public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, IContainer targetContainer, bool checkActionBlocker = true, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp))
return false;
@@ -133,7 +133,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Removes the contents of a hand from its container. Assumes that the removal is allowed. In general, you should not be calling this directly.
/// </summary>
public virtual void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, SharedHandsComponent? handsComp = null)
public virtual void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp))
return;

View File

@@ -19,7 +19,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
SubscribeAllEvent<RequestMoveHandItemEvent>(HandleMoveItemFromHand);
SubscribeAllEvent<RequestHandAltInteractEvent>(HandleHandAltInteract);
SubscribeLocalEvent<SharedHandsComponent, ExaminedEvent>(HandleExamined);
SubscribeLocalEvent<HandsComponent, ExaminedEvent>(HandleExamined);
CommandBinds.Builder
.Bind(ContentKeyFunctions.UseItemInHand, InputCmdHandler.FromDelegate(HandleUseItem, handle: false, outsidePrediction: false))
@@ -74,7 +74,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
private void SwapHandsPressed(ICommonSession? session)
{
if (!TryComp(session?.AttachedEntity, out SharedHandsComponent? component))
if (!TryComp(session?.AttachedEntity, out HandsComponent? component))
return;
if (!_actionBlocker.CanInteract(session.AttachedEntity.Value, null))
@@ -91,7 +91,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
private bool DropPressed(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{
if (TryComp(session?.AttachedEntity, out SharedHandsComponent? hands) && hands.ActiveHand != null)
if (TryComp(session?.AttachedEntity, out HandsComponent? hands) && hands.ActiveHand != null)
TryDrop(session.AttachedEntity!.Value, hands.ActiveHand, coords, handsComp: hands);
// always send to server.
@@ -99,7 +99,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
}
#endregion
public bool TryActivateItemInHand(EntityUid uid, SharedHandsComponent? handsComp = null, string? handName = null)
public bool TryActivateItemInHand(EntityUid uid, HandsComponent? handsComp = null, string? handName = null)
{
if (!Resolve(uid, ref handsComp, false))
return false;
@@ -114,7 +114,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
return _interactionSystem.InteractionActivate(uid, held);
}
public bool TryInteractHandWithActiveHand(EntityUid uid, string handName, SharedHandsComponent? handsComp = null)
public bool TryInteractHandWithActiveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
return false;
@@ -132,7 +132,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
return true;
}
public bool TryUseItemInHand(EntityUid uid, bool altInteract = false, SharedHandsComponent? handsComp = null, string? handName = null)
public bool TryUseItemInHand(EntityUid uid, bool altInteract = false, HandsComponent? handsComp = null, string? handName = null)
{
if (!Resolve(uid, ref handsComp, false))
return false;
@@ -153,7 +153,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Moves an entity from one hand to the active hand.
/// </summary>
public bool TryMoveHeldEntityToActiveHand(EntityUid uid, string handName, bool checkActionBlocker = true, SharedHandsComponent? handsComp = null)
public bool TryMoveHeldEntityToActiveHand(EntityUid uid, string handName, bool checkActionBlocker = true, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp))
return false;
@@ -178,7 +178,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
}
//TODO: Actually shows all items/clothing/etc.
private void HandleExamined(EntityUid uid, SharedHandsComponent handsComp, ExaminedEvent args)
private void HandleExamined(EntityUid uid, HandsComponent handsComp, ExaminedEvent args)
{
foreach (var inhand in EnumerateHeld(uid, handsComp))
{

View File

@@ -25,7 +25,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
bool checkActionBlocker = true,
bool animateUser = false,
bool animate = true,
SharedHandsComponent? handsComp = null,
HandsComponent? handsComp = null,
ItemComponent? item = null)
{
if (!Resolve(uid, ref handsComp, false))
@@ -54,7 +54,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
bool checkActionBlocker = true,
bool animateUser = false,
bool animate = true,
SharedHandsComponent? handsComp = null,
HandsComponent? handsComp = null,
ItemComponent? item = null)
{
if (!Resolve(uid, ref handsComp, false))
@@ -73,7 +73,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
bool checkActionBlocker = true,
bool animateUser = false,
bool animate = true,
SharedHandsComponent? handsComp = null,
HandsComponent? handsComp = null,
ItemComponent? item = null)
{
if (!Resolve(uid, ref handsComp, false))
@@ -104,7 +104,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
return true;
}
public bool CanPickupAnyHand(EntityUid uid, EntityUid entity, bool checkActionBlocker = true, SharedHandsComponent? handsComp = null, ItemComponent? item = null)
public bool CanPickupAnyHand(EntityUid uid, EntityUid entity, bool checkActionBlocker = true, HandsComponent? handsComp = null, ItemComponent? item = null)
{
if (!Resolve(uid, ref handsComp, false))
return false;
@@ -118,7 +118,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Checks whether a given item will fit into a specific user's hand. Unless otherwise specified, this will also check the general CanPickup action blocker.
/// </summary>
public bool CanPickupToHand(EntityUid uid, EntityUid entity, Hand hand, bool checkActionBlocker = true, SharedHandsComponent? handsComp = null, ItemComponent? item = null)
public bool CanPickupToHand(EntityUid uid, EntityUid entity, Hand hand, bool checkActionBlocker = true, HandsComponent? handsComp = null, ItemComponent? item = null)
{
if (!Resolve(uid, ref handsComp, false))
return false;
@@ -149,7 +149,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
bool checkActionBlocker = true,
bool animateUser = false,
bool animate = true,
SharedHandsComponent? handsComp = null,
HandsComponent? handsComp = null,
ItemComponent? item = null)
{
if (uid == null
@@ -166,7 +166,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Puts an entity into the player's hand, assumes that the insertion is allowed. In general, you should not be calling this function directly.
/// </summary>
public virtual void DoPickup(EntityUid uid, Hand hand, EntityUid entity, SharedHandsComponent? hands = null)
public virtual void DoPickup(EntityUid uid, Hand hand, EntityUid entity, HandsComponent? hands = null)
{
if (!Resolve(uid, ref hands))
return;

View File

@@ -16,7 +16,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
protected event Action<SharedHandsComponent?>? OnHandSetActive;
protected event Action<HandsComponent?>? OnHandSetActive;
public override void Initialize()
{
@@ -31,7 +31,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
CommandBinds.Unregister<SharedHandsSystem>();
}
public virtual void AddHand(EntityUid uid, string handName, HandLocation handLocation, SharedHandsComponent? handsComp = null)
public virtual void AddHand(EntityUid uid, string handName, HandLocation handLocation, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
return;
@@ -53,7 +53,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
Dirty(handsComp);
}
public virtual void RemoveHand(EntityUid uid, string handName, SharedHandsComponent? handsComp = null)
public virtual void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
return;
@@ -83,7 +83,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Get any empty hand. Prioritizes the currently active hand.
/// </summary>
public bool TryGetEmptyHand(EntityUid uid, [NotNullWhen(true)] out Hand? emptyHand, SharedHandsComponent? handComp = null)
public bool TryGetEmptyHand(EntityUid uid, [NotNullWhen(true)] out Hand? emptyHand, HandsComponent? handComp = null)
{
emptyHand = null;
if (!Resolve(uid, ref handComp, false))
@@ -104,7 +104,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Enumerate over hands, starting with the currently active hand.
/// </summary>
public IEnumerable<Hand> EnumerateHands(EntityUid uid, SharedHandsComponent? handsComp = null)
public IEnumerable<Hand> EnumerateHands(EntityUid uid, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
yield break;
@@ -122,7 +122,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary>
/// Enumerate over held items, starting with the item in the currently active hand (if there is one).
/// </summary>
public IEnumerable<EntityUid> EnumerateHeld(EntityUid uid, SharedHandsComponent? handsComp = null)
public IEnumerable<EntityUid> EnumerateHeld(EntityUid uid, HandsComponent? handsComp = null)
{
if (!Resolve(uid, ref handsComp, false))
yield break;
@@ -145,7 +145,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// </summary>
/// <returns>True if the active hand was set to a NEW value. Setting it to the same value returns false and does
/// not trigger interactions.</returns>
public virtual bool TrySetActiveHand(EntityUid uid, string? name, SharedHandsComponent? handComp = null)
public virtual bool TrySetActiveHand(EntityUid uid, string? name, HandsComponent? handComp = null)
{
if (!Resolve(uid, ref handComp))
return false;
@@ -164,7 +164,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// </summary>
/// <returns>True if the active hand was set to a NEW value. Setting it to the same value returns false and does
/// not trigger interactions.</returns>
public bool SetActiveHand(EntityUid uid, Hand? hand, SharedHandsComponent? handComp = null)
public bool SetActiveHand(EntityUid uid, Hand? hand, HandsComponent? handComp = null)
{
if (!Resolve(uid, ref handComp))
return false;
@@ -190,7 +190,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
return true;
}
public bool IsHolding(EntityUid uid, EntityUid? entity, [NotNullWhen(true)] out Hand? inHand, SharedHandsComponent? handsComp = null)
public bool IsHolding(EntityUid uid, EntityUid? entity, [NotNullWhen(true)] out Hand? inHand, HandsComponent? handsComp = null)
{
inHand = null;
if (!Resolve(uid, ref handsComp, false))
@@ -207,4 +207,15 @@ public abstract partial class SharedHandsSystem : EntitySystem
return false;
}
public bool TryGetHand(EntityUid handsUid, string handId, [NotNullWhen(true)] out Hand? hand,
HandsComponent? hands = null)
{
hand = null;
if (!Resolve(handsUid, ref hands))
return false;
return hands.Hands.TryGetValue(handId, out hand);
}
}

View File

@@ -30,7 +30,6 @@ using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
@@ -284,7 +283,7 @@ namespace Content.Shared.Interaction
: !checkAccess || InRangeUnobstructed(user, target.Value); // permits interactions with wall mounted entities
// Does the user have hands?
if (!TryComp(user, out SharedHandsComponent? hands) || hands.ActiveHand == null)
if (!TryComp(user, out HandsComponent? hands) || hands.ActiveHand == null)
{
var ev = new InteractNoHandEvent(user, target, coordinates);
RaiseLocalEvent(user, ev);
@@ -877,7 +876,7 @@ namespace Content.Shared.Interaction
return false;
// Does the user have hands?
if (!HasComp<SharedHandsComponent>(user))
if (!HasComp<HandsComponent>(user))
return false;
var activateMsg = new ActivateInWorldEvent(user, used);

View File

@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.ActionBlocker;
using Content.Shared.Clothing.Components;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
@@ -41,7 +40,7 @@ public abstract partial class InventorySystem
protected void QuickEquip(EntityUid uid, ClothingComponent component, UseInHandEvent args)
{
if (!TryComp(args.User, out InventoryComponent? inv)
|| !TryComp(args.User, out SharedHandsComponent? hands)
|| !TryComp(args.User, out HandsComponent? hands)
|| !_prototypeManager.TryIndex<InventoryTemplatePrototype>(inv.TemplateId, out var prototype))
return;
@@ -108,7 +107,7 @@ public abstract partial class InventorySystem
if (eventArgs.SenderSession.AttachedEntity is not { Valid: true } actor)
return;
if (!TryComp(actor, out InventoryComponent? inventory) || !TryComp<SharedHandsComponent>(actor, out var hands))
if (!TryComp(actor, out InventoryComponent? inventory) || !TryComp<HandsComponent>(actor, out var hands))
return;
var held = hands.ActiveHandEntity;
@@ -245,7 +244,7 @@ public abstract partial class InventorySystem
return actor != target &&
HasComp<StrippableComponent>(target) &&
HasComp<StrippingComponent>(actor) &&
HasComp<SharedHandsComponent>(actor);
HasComp<HandsComponent>(actor);
}
public bool CanEquip(EntityUid uid, EntityUid itemUid, string slot, [NotNullWhen(false)] out string? reason,

View File

@@ -2,7 +2,6 @@ using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Popups;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Shared.Item;
@@ -27,7 +26,7 @@ public abstract class SharedMultiHandedItemSystem : EntitySystem
private void OnAttemptPickup(EntityUid uid, MultiHandedItemComponent component, GettingPickedUpAttemptEvent args)
{
if (TryComp<SharedHandsComponent>(args.User, out var hands) && hands.CountFreeHands() >= component.HandsNeeded)
if (TryComp<HandsComponent>(args.User, out var hands) && hands.CountFreeHands() >= component.HandsNeeded)
return;
args.Cancel();

View File

@@ -1,6 +1,6 @@
using Content.Shared.Emag.Systems;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Emag.Systems;
using Content.Shared.Examine;
using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
@@ -192,7 +192,7 @@ public sealed class LockSystem : EntitySystem
/// </summary>
public bool CanToggleLock(EntityUid uid, EntityUid user, bool quiet = true)
{
if (!HasComp<SharedHandsComponent>(user))
if (!HasComp<HandsComponent>(user))
return false;
var ev = new LockToggleAttemptEvent(user, quiet);

View File

@@ -387,7 +387,7 @@ public abstract class SharedMechSystem : EntitySystem
if (!Resolve(uid, ref component))
return false;
return IsEmpty(component) && _actionBlocker.CanMove(toInsert) && HasComp<SharedHandsComponent>(toInsert);
return IsEmpty(component) && _actionBlocker.CanMove(toInsert) && HasComp<HandsComponent>(toInsert);
}
/// <summary>

View File

@@ -125,7 +125,7 @@ namespace Content.Shared.Stacks
EntityUid item,
EntityUid user,
StackComponent? itemStack = null,
SharedHandsComponent? hands = null)
HandsComponent? hands = null)
{
if (!Resolve(user, ref hands, false))
return;

View File

@@ -1,15 +1,11 @@
using Content.Shared.Audio;
using Content.Shared.Hands.Components;
using Content.Shared.Physics;
using Content.Shared.Rotation;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Physics;
using Content.Shared.Physics;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Serialization;
namespace Content.Shared.Standing
{
@@ -53,7 +49,7 @@ namespace Content.Shared.Standing
public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true,
StandingStateComponent? standingState = null,
AppearanceComponent? appearance = null,
SharedHandsComponent? hands = null)
HandsComponent? hands = null)
{
// TODO: This should actually log missing comps...
if (!Resolve(uid, ref standingState, false))

View File

@@ -121,7 +121,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
private void OnRelayMovement(EntityUid uid, SharedEntityStorageComponent component, ref ContainerRelayMovementEntityEvent args)
{
if (!HasComp<SharedHandsComponent>(args.Entity))
if (!HasComp<HandsComponent>(args.Entity))
return;
if (_timing.CurTime < component.LastInternalOpenAttempt + SharedEntityStorageComponent.InternalOpenAttemptDelay)
@@ -311,7 +311,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
if (!Resolve(target, ref component))
return false;
if (!HasComp<SharedHandsComponent>(user))
if (!HasComp<HandsComponent>(user))
return false;
if (component.IsWeldedShut)

View File

@@ -43,14 +43,14 @@ public abstract class SharedStrippableSystem : EntitySystem
args.Handled = true;
args.CanDrop |= uid == args.User &&
HasComp<StrippableComponent>(args.Dragged) &&
HasComp<SharedHandsComponent>(args.User);
HasComp<HandsComponent>(args.User);
}
private void OnCanDrop(EntityUid uid, StrippableComponent component, ref CanDropDraggedEvent args)
{
args.CanDrop |= args.Target == args.User &&
HasComp<StrippingComponent>(args.User) &&
HasComp<SharedHandsComponent>(args.User);
HasComp<HandsComponent>(args.User);
if (args.CanDrop)
args.Handled = true;

View File

@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.ActionBlocker;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
@@ -6,9 +7,7 @@ using Content.Shared.Tabletop.Events;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using System.Diagnostics.CodeAnalysis;
namespace Content.Shared.Tabletop
{
@@ -114,7 +113,7 @@ namespace Content.Shared.Tabletop
// CanSeeTable checks interaction action blockers. So no need to check them here.
// If this ever changes, so that ghosts can spectate games, then the check needs to be moved here.
return TryComp(playerEntity, out SharedHandsComponent? hands) && hands.Hands.Count > 0;
return TryComp(playerEntity, out HandsComponent? hands) && hands.Hands.Count > 0;
}
#endregion
}

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
@@ -6,9 +7,6 @@ using Content.Shared.Physics.Pull;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
using System.Linq;
using Content.Shared.Sound.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
@@ -129,7 +127,7 @@ namespace Content.Shared.Throwing
// Unfortunately we can't check for hands containers as they have specific names.
if (uid.TryGetContainerMan(out var containerManager) &&
EntityManager.HasComponent<SharedHandsComponent>(containerManager.Owner))
EntityManager.HasComponent<HandsComponent>(containerManager.Owner))
{
EntityManager.RemoveComponent(landing, thrownItem);
return;

View File

@@ -79,7 +79,7 @@ namespace Content.Shared.Verbs
var canInteract = force || _actionBlockerSystem.CanInteract(user, target);
EntityUid? @using = null;
if (TryComp(user, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUseHeldEntity(user)))
if (TryComp(user, out HandsComponent? hands) && (force || _actionBlockerSystem.CanUseHeldEntity(user)))
{
@using = hands.ActiveHandEntity;

View File

@@ -112,7 +112,7 @@ namespace Content.Shared.Verbs
/// <remarks>
/// This may be null if the user has no hands.
/// </remarks>
public readonly SharedHandsComponent? Hands;
public readonly HandsComponent? Hands;
/// <summary>
/// The entity currently being held by the active hand.
@@ -123,7 +123,7 @@ namespace Content.Shared.Verbs
/// </remarks>
public readonly EntityUid? Using;
public GetVerbsEvent(EntityUid user, EntityUid target, EntityUid? @using, SharedHandsComponent? hands, bool canInteract, bool canAccess)
public GetVerbsEvent(EntityUid user, EntityUid target, EntityUid? @using, HandsComponent? hands, bool canInteract, bool canAccess)
{
User = user;
Target = target;

View File

@@ -262,7 +262,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
}
// Use inhands entity if we got one.
if (EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands) &&
if (EntityManager.TryGetComponent(entity, out HandsComponent? hands) &&
hands.ActiveHandEntity is { } held)
{
if (EntityManager.TryGetComponent(held, out melee))

View File

@@ -10,18 +10,18 @@ using Content.Shared.Hands.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Projectiles;
using Content.Shared.Tag;
using Content.Shared.Throwing;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Tag;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
@@ -191,7 +191,7 @@ public abstract partial class SharedGunSystem : EntitySystem
if (!_combatMode.IsInCombatMode(entity))
return false;
if (EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands) &&
if (EntityManager.TryGetComponent(entity, out HandsComponent? hands) &&
hands.ActiveHandEntity is { } held &&
TryComp(held, out GunComponent? gun))
{

View File

@@ -1,12 +1,12 @@
using Content.Shared.Audio;
using Content.Shared.Popups;
using Robust.Shared.Random;
using Robust.Shared.Physics.Systems;
using Content.Shared.Hands.Components;
using Robust.Shared.GameStates;
using Content.Shared.Weapons.Ranged.Events;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Audio;
using Content.Shared.Hands.Components;
using Content.Shared.Popups;
using Content.Shared.Projectiles;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.GameStates;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Random;
namespace Content.Shared.Weapons.Reflect;
@@ -24,8 +24,8 @@ public abstract class SharedReflectSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SharedHandsComponent, ProjectileReflectAttemptEvent>(OnHandReflectProjectile);
SubscribeLocalEvent<SharedHandsComponent, HitScanReflectAttemptEvent>(OnHandsReflectHitscan);
SubscribeLocalEvent<HandsComponent, ProjectileReflectAttemptEvent>(OnHandReflectProjectile);
SubscribeLocalEvent<HandsComponent, HitScanReflectAttemptEvent>(OnHandsReflectHitscan);
SubscribeLocalEvent<ReflectComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<ReflectComponent, ComponentGetState>(OnGetState);
@@ -45,7 +45,7 @@ public abstract class SharedReflectSystem : EntitySystem
args.State = new ReflectComponentState(component.Enabled, component.EnergeticChance, component.KineticChance, component.Spread);
}
private void OnHandReflectProjectile(EntityUid uid, SharedHandsComponent hands, ref ProjectileReflectAttemptEvent args)
private void OnHandReflectProjectile(EntityUid uid, HandsComponent hands, ref ProjectileReflectAttemptEvent args)
{
if (args.Cancelled)
return;
@@ -78,7 +78,7 @@ public abstract class SharedReflectSystem : EntitySystem
return false;
}
private void OnHandsReflectHitscan(EntityUid uid, SharedHandsComponent hands, ref HitScanReflectAttemptEvent args)
private void OnHandsReflectHitscan(EntityUid uid, HandsComponent hands, ref HitScanReflectAttemptEvent args)
{
if (args.Reflected)
return;