Remove IHandsComponent and ISharedHandsComponent (#5218)

* Remove IHandsComponent and ISharedHandsComponent

* Copy the documentation from the interfaces

* Revert "Copy the documentation from the interfaces"

This reverts commit 7638a2d4817743d487c7b255ba3e56add77dca86.

* Perform a minute amount of cleanup
This commit is contained in:
Javier Guardia Fernández
2021-11-08 15:08:24 +01:00
committed by GitHub
parent 162cde1b32
commit ec9e65951c
25 changed files with 42 additions and 266 deletions

View File

@@ -1,13 +1,10 @@
using System.Collections.Generic;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Item;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Client.Hands namespace Content.Client.Hands
{ {
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(ISharedHandsComponent))]
[ComponentReference(typeof(SharedHandsComponent))] [ComponentReference(typeof(SharedHandsComponent))]
public class HandsComponent : SharedHandsComponent public class HandsComponent : SharedHandsComponent
{ {

View File

@@ -10,7 +10,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using HandsComponent = Content.Client.Hands.HandsComponent;
namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
{ {
@@ -48,7 +47,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
IEntity cuffs; IEntity cuffs;
IEntity secondCuffs; IEntity secondCuffs;
CuffableComponent cuffed; CuffableComponent cuffed;
IHandsComponent hands; HandsComponent hands;
server.Assert(() => server.Assert(() =>
{ {

View File

@@ -1,11 +1,11 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.Access.Components; using Content.Server.Access.Components;
using Content.Shared.Containers.ItemSlots;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Inventory.Components; using Content.Server.Inventory.Components;
using Content.Server.Items; using Content.Server.Items;
using Content.Server.PDA; using Content.Server.PDA;
using Content.Shared.Containers.ItemSlots;
using NUnit.Framework; using NUnit.Framework;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -72,7 +72,7 @@ namespace Content.IntegrationTests.Tests.PDA
// Put PDA in hand // Put PDA in hand
var dummyPda = sEntityManager.SpawnEntity(PdaDummy, player.Transform.MapPosition); var dummyPda = sEntityManager.SpawnEntity(PdaDummy, player.Transform.MapPosition);
var pdaItemComponent = dummyPda.GetComponent<ItemComponent>(); var pdaItemComponent = dummyPda.GetComponent<ItemComponent>();
player.GetComponent<IHandsComponent>().PutInHand(pdaItemComponent); player.GetComponent<HandsComponent>().PutInHand(pdaItemComponent);
var pdaComponent = dummyPda.GetComponent<PDAComponent>(); var pdaComponent = dummyPda.GetComponent<PDAComponent>();
var pdaIdCard = sEntityManager.SpawnEntity(IdCardDummy, player.Transform.MapPosition); var pdaIdCard = sEntityManager.SpawnEntity(IdCardDummy, player.Transform.MapPosition);
@@ -92,7 +92,7 @@ namespace Content.IntegrationTests.Tests.PDA
// Put ID card in hand // Put ID card in hand
var idDummy = sEntityManager.SpawnEntity(IdCardDummy, player.Transform.MapPosition); var idDummy = sEntityManager.SpawnEntity(IdCardDummy, player.Transform.MapPosition);
var idItemComponent = idDummy.GetComponent<ItemComponent>(); var idItemComponent = idDummy.GetComponent<ItemComponent>();
player.GetComponent<IHandsComponent>().PutInHand(idItemComponent); player.GetComponent<HandsComponent>().PutInHand(idItemComponent);
var idCardComponent = idDummy.GetComponent<IdCardComponent>(); var idCardComponent = idDummy.GetComponent<IdCardComponent>();
@@ -120,7 +120,7 @@ namespace Content.IntegrationTests.Tests.PDA
} }
} }
var hands = player.GetComponent<IHandsComponent>(); var hands = player.GetComponent<HandsComponent>();
hands.Drop(dummyPda, false); hands.Drop(dummyPda, false);
hands.Drop(idDummy, false); hands.Drop(idDummy, false);

View File

@@ -124,7 +124,7 @@ namespace Content.Server.AME.Components
return; return;
} }
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("ame-controller-component-interact-no-hands-text")); Owner.PopupMessage(args.User, Loc.GetString("ame-controller-component-interact-no-hands-text"));
return; return;
@@ -335,7 +335,7 @@ namespace Content.Server.AME.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
{ {
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("ame-controller-component-interact-using-no-hands-text")); Owner.PopupMessage(args.User, Loc.GetString("ame-controller-component-interact-using-no-hands-text"));
return true; return true;

View File

@@ -5,7 +5,6 @@ using Content.Server.Tools;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Sound; using Content.Shared.Sound;
using Content.Shared.Tools.Components;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -36,7 +35,7 @@ namespace Content.Server.AME.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
{ {
if (!args.User.TryGetComponent<IHandsComponent>(out var hands)) if (!args.User.HasComponent<HandsComponent>())
{ {
Owner.PopupMessage(args.User, Loc.GetString("ame-part-component-interact-using-no-hands")); Owner.PopupMessage(args.User, Loc.GetString("ame-part-component-interact-using-no-hands"));
return false; return false;

View File

@@ -5,7 +5,6 @@ using Content.Server.Hands.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.Components; using Content.Shared.Atmos.Components;
using Content.Shared.DragDrop;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Popups; using Content.Shared.Popups;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -161,7 +160,7 @@ namespace Content.Server.Atmos.Components
if (session.AttachedEntity == null) if (session.AttachedEntity == null)
return; return;
if (!session.AttachedEntity.TryGetComponent(out IHandsComponent? handsComponent)) if (!session.AttachedEntity.TryGetComponent(out HandsComponent? handsComponent))
return; return;
var activeHandEntity = handsComponent?.GetActiveHand?.Owner; var activeHandEntity = handsComponent?.GetActiveHand?.Owner;
@@ -226,7 +225,7 @@ namespace Content.Server.Atmos.Components
return; return;
} }
if (!player.TryGetComponent(out IHandsComponent? handsComponent)) if (!player.TryGetComponent(out HandsComponent? handsComponent))
{ {
Owner.PopupMessage(player, Loc.GetString("gas-analyzer-component-player-has-no-hands-message")); Owner.PopupMessage(player, Loc.GetString("gas-analyzer-component-player-has-no-hands-message"));
return; return;

View File

@@ -9,7 +9,6 @@ using Content.Server.Power.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Popups; using Content.Shared.Popups;
@@ -378,7 +377,7 @@ namespace Content.Server.Chemistry.Components
return; return;
} }
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("chem-master-component-activate-no-hands")); Owner.PopupMessage(args.User, Loc.GetString("chem-master-component-activate-no-hands"));
return; return;
@@ -400,7 +399,7 @@ namespace Content.Server.Chemistry.Components
/// <returns></returns> /// <returns></returns>
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
{ {
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("chem-master-component-interact-using-no-hands")); Owner.PopupMessage(args.User, Loc.GetString("chem-master-component-interact-using-no-hands"));
return true; return true;

View File

@@ -11,7 +11,6 @@ using Content.Server.UserInterface;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Dispenser; using Content.Shared.Chemistry.Dispenser;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Popups; using Content.Shared.Popups;
@@ -321,7 +320,7 @@ namespace Content.Server.Chemistry.Components
return; return;
} }
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("reagent-dispenser-component-activate-no-hands")); Owner.PopupMessage(args.User, Loc.GetString("reagent-dispenser-component-activate-no-hands"));
return; return;
@@ -343,7 +342,7 @@ namespace Content.Server.Chemistry.Components
/// <returns></returns> /// <returns></returns>
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
{ {
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("reagent-dispenser-component-interact-using-no-hands")); Owner.PopupMessage(args.User, Loc.GetString("reagent-dispenser-component-interact-using-no-hands"));
return true; return true;

View File

@@ -8,7 +8,6 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Sound; using Content.Shared.Sound;
using Content.Shared.Verbs;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
@@ -166,7 +165,7 @@ namespace Content.Server.Disposal.Tube.Components
return; return;
} }
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("disposal-router-window-tag-input-activate-no-hands")); Owner.PopupMessage(args.User, Loc.GetString("disposal-router-window-tag-input-activate-no-hands"));
return; return;

View File

@@ -5,7 +5,6 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Sound; using Content.Shared.Sound;
using Content.Shared.Verbs;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
@@ -132,7 +131,7 @@ namespace Content.Server.Disposal.Tube.Components
return; return;
} }
if (!args.User.TryGetComponent(out IHandsComponent? hands)) if (!args.User.TryGetComponent(out HandsComponent? hands))
{ {
Owner.PopupMessage(args.User, Loc.GetString("disposal-tagger-window-activate-no-hands")); Owner.PopupMessage(args.User, Loc.GetString("disposal-tagger-window-activate-no-hands"));
return; return;

View File

@@ -392,7 +392,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
} }
// This popup message doesn't appear on clicks, even when code was seperate. Unsure why. // This popup message doesn't appear on clicks, even when code was seperate. Unsure why.
if (!eventArgs.User.HasComponent<IHandsComponent>()) if (!eventArgs.User.HasComponent<HandsComponent>())
{ {
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("ui-disposal-unit-is-valid-interaction-no-hands")); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("ui-disposal-unit-is-valid-interaction-no-hands"));
return false; return false;

View File

@@ -25,11 +25,9 @@ using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Hands.Components namespace Content.Server.Hands.Components
{ {
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(IHandsComponent))]
[ComponentReference(typeof(ISharedHandsComponent))]
[ComponentReference(typeof(SharedHandsComponent))] [ComponentReference(typeof(SharedHandsComponent))]
#pragma warning disable 618 #pragma warning disable 618
public class HandsComponent : SharedHandsComponent, IHandsComponent, IBodyPartAdded, IBodyPartRemoved, IDisarmedAct public class HandsComponent : SharedHandsComponent, IBodyPartAdded, IBodyPartRemoved, IDisarmedAct
#pragma warning restore 618 #pragma warning restore 618
{ {
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;

View File

@@ -1,194 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Items;
using Content.Shared.ActionBlocker;
using Content.Shared.Hands.Components;
using Content.Shared.Item;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.Server.Hands.Components
{
public interface IHandsComponent : ISharedHandsComponent
{
/// <summary>
/// Invoked when the hand contents changes or when a hand is added/removed.
/// </summary>
event Action? OnItemChanged;
/// <summary>
/// The hands in this component.
/// </summary>
IEnumerable<string> HandNames { get; }
/// <summary>
/// The hand name of the currently active hand.
/// </summary>
string? ActiveHand { get; set; }
/// <summary>
/// Enumerates over every held item.
/// </summary>
IEnumerable<ItemComponent> GetAllHeldItems();
/// <summary>
/// Gets the item held by a hand.
/// </summary>
/// <param name="handName">The name of the hand to get.</param>
/// <returns>The item in the held, null if no item is held</returns>
ItemComponent? GetItem(string handName);
/// <summary>
/// Attempts to get an item in a hand.
/// </summary>
/// <param name="handName">The name of the hand to get.</param>
/// <param name="item">The item in the held, null if no item is held</param>
/// <returns>Whether it was holding an item</returns>
bool TryGetItem(string handName, [NotNullWhen(true)] out ItemComponent? item);
/// <summary>
/// Gets item held by the current active hand
/// </summary>
ItemComponent? GetActiveHand { get; }
/// <summary>
/// Puts an item into any empty hand, preferring the active hand.
/// </summary>
/// <param name="item">The item to put in a hand.</param>
/// <param name="mobCheck">Whether to perform an ActionBlocker check to the entity.</param>
/// <returns>True if the item was inserted, false otherwise.</returns>
bool PutInHand(SharedItemComponent item, bool mobCheck = true);
/// <summary>
/// Checks to see if an item can be put in any hand.
/// </summary>
/// <param name="item">The item to check for.</param>
/// <param name="mobCheck">Whether to perform an ActionBlocker check to the entity.</param>
/// <returns>True if the item can be inserted, false otherwise.</returns>
bool CanPutInHand(ItemComponent item, bool mobCheck = true);
/// <summary>
/// Drops the item contained in the slot to the same position as our entity.
/// </summary>
/// <param name="slot">The slot of which to drop to drop the item.</param>
/// <param name="mobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param
/// <returns>True on success, false if something blocked the drop.</returns>
bool Drop(string slot, bool mobChecks = true, bool intentional = true);
/// <summary>
/// Drops an item held by one of our hand slots to the same position as our owning entity.
/// </summary>
/// <param name="entity">The item to drop.</param>
/// <param name="mobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
/// <returns>True on success, false if something blocked the drop.</returns>
/// <exception cref="ArgumentNullException">
/// Thrown if <see cref="entity"/> is null.
/// </exception>
/// <exception cref="ArgumentException">
/// Thrown if <see cref="entity"/> is not actually held in any hand.
/// </exception>
bool Drop(IEntity entity, bool mobChecks = true, bool intentional = true);
/// <summary>
/// Drops the item in a slot.
/// </summary>
/// <param name="slot">The slot to drop the item from.</param>
/// <param name="coords"></param>
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
/// <returns>True if an item was dropped, false otherwise.</returns>
bool TryDropHand(string slot, EntityCoordinates coords, bool doMobChecks = true, bool intentional = true);
/// <summary>
/// Drop the specified entity in our hands to a certain position.
/// </summary>
/// <remarks>
/// There are no checks whether or not the user is within interaction range of the drop location
/// or whether the drop location is occupied.
/// </remarks>
/// <param name="entity">The entity to drop, must be held in one of the hands.</param>
/// <param name="coords">The coordinates to drop the entity at.</param>
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
/// <returns>
/// True if the drop succeeded,
/// false if it failed (due to failing to eject from our hand slot, etc...)
/// </returns>
/// <exception cref="ArgumentNullException">
/// Thrown if <see cref="entity"/> is null.
/// </exception>
/// <exception cref="ArgumentException">
/// Thrown if <see cref="entity"/> is not actually held in any hand.
/// </exception>
bool TryDropEntity(IEntity entity, EntityCoordinates coords, bool doMobChecks = true, bool intentional = true);
/// <summary>
/// Drop the item contained in a slot into another container.
/// </summary>
/// <param name="slot">The slot of which to drop the entity.</param>
/// <param name="targetContainer">The container to drop into.</param>
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop(IEntity)"/> for the mob or not.</param>
/// <returns>True on success, false if something was blocked (insertion or removal).</returns>
/// <exception cref="InvalidOperationException">
/// Thrown if dry-run checks reported OK to remove and insert,
/// but practical remove or insert returned false anyways.
/// This is an edge-case that is currently unhandled.
/// </exception>
bool TryPutHandIntoContainer(string slot, BaseContainer targetContainer, bool doMobChecks = true);
/// <summary>
/// Drops an item in one of the hands into a container.
/// </summary>
/// <param name="entity">The item to drop.</param>
/// <param name="targetContainer">The container to drop into.</param>
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
/// <returns>True on success, false if something was blocked (insertion or removal).</returns>
/// <exception cref="InvalidOperationException">
/// Thrown if dry-run checks reported OK to remove and insert,
/// but practical remove or insert returned false anyways.
/// This is an edge-case that is currently unhandled.
/// </exception>
/// <exception cref="ArgumentNullException">
/// Thrown if <see cref="entity"/> is null.
/// </exception>
/// <exception cref="ArgumentException">
/// Thrown if <see cref="entity"/> is not actually held in any hand.
/// </exception>
bool Drop(IEntity entity, BaseContainer targetContainer, bool doMobChecks = true);
/// <summary>
/// Checks whether the item in the specified hand can be dropped.
/// </summary>
/// <param name="name">The hand to check for.</param>
/// <param name="mobCheck">Whether to perform an ActionBlocker check to the entity.</param>
/// <returns>
/// True if the item can be dropped, false if the hand is empty or the item in the hand cannot be dropped.
/// </returns>
bool CanDrop(string name, bool mobCheck = true);
/// <summary>
/// Adds a new hand to this hands component.
/// </summary>
/// <param name="name">The name of the hand to add.</param>
/// <exception cref="InvalidOperationException">
/// Thrown if a hand with specified name already exists.
/// </exception>
void AddHand(string name, HandLocation handLocation);
/// <summary>
/// Removes a hand from this hands component.
/// </summary>
/// <remarks>
/// If the hand contains an item, the item is dropped.
/// </remarks>
/// <param name="name">The name of the hand to remove.</param>
void RemoveHand(string name);
/// <summary>
/// Checks whether a hand with the specified name exists.
/// </summary>
/// <param name="name">The hand name to check.</param>
/// <returns>True if the hand exists, false otherwise.</returns>
bool HasHand(string name);
}
}

View File

@@ -170,11 +170,11 @@ namespace Content.Server.Hands.Systems
{ {
base.DropAllItemsInHands(entity, doMobChecks); base.DropAllItemsInHands(entity, doMobChecks);
if (!entity.TryGetComponent(out IHandsComponent? hands)) return; if (!entity.TryGetComponent(out HandsComponent? hands)) return;
foreach (var heldItem in hands.GetAllHeldItems()) foreach (var heldItem in hands.GetAllHeldItems())
{ {
hands.Drop(heldItem.Owner, doMobChecks, intentional:false); hands.Drop(heldItem.Owner, doMobChecks, false);
} }
} }

View File

@@ -2,12 +2,10 @@ using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.Buckle.Components;
using Content.Server.CombatMode; using Content.Server.CombatMode;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Items; using Content.Server.Items;
using Content.Server.Pulling; using Content.Server.Pulling;
using Content.Server.Verbs;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.DragDrop; using Content.Shared.DragDrop;
using Content.Shared.Input; using Content.Shared.Input;
@@ -15,8 +13,6 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Content.Shared.Rotatable;
using Content.Shared.Timing;
using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -29,9 +25,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Players; using Robust.Shared.Players;
using Robust.Shared.Random;
namespace Content.Server.Interaction namespace Content.Server.Interaction
{ {
@@ -314,7 +308,7 @@ namespace Content.Server.Interaction
} }
// Verify user has a hand, and find what object they are currently holding in their active hand // Verify user has a hand, and find what object they are currently holding in their active hand
if (!user.TryGetComponent<IHandsComponent>(out var hands)) if (!user.TryGetComponent<HandsComponent>(out var hands))
return; return;
var item = hands.GetActiveHand?.Owner; var item = hands.GetActiveHand?.Owner;
@@ -460,7 +454,7 @@ namespace Content.Server.Interaction
} }
// Verify user has a hand, and find what object they are currently holding in their active hand // Verify user has a hand, and find what object they are currently holding in their active hand
if (user.TryGetComponent<IHandsComponent>(out var hands)) if (user.TryGetComponent<HandsComponent>(out var hands))
{ {
var item = hands.GetActiveHand?.Owner; var item = hands.GetActiveHand?.Owner;

View File

@@ -54,7 +54,7 @@ namespace Content.Server.Kitchen.EntitySystems
{ {
if (args.Handled) return; if (args.Handled) return;
if (!args.User.HasComponent<IHandsComponent>()) if (!args.User.HasComponent<HandsComponent>())
{ {
component.Owner.PopupMessage(args.User, component.Owner.PopupMessage(args.User,
Loc.GetString("reagent-grinder-component-interact-using-no-hands")); Loc.GetString("reagent-grinder-component-interact-using-no-hands"));
@@ -229,7 +229,7 @@ namespace Content.Server.Kitchen.EntitySystems
if (canJuice || !entity.TryGetComponent(out ExtractableComponent? component)) continue; if (canJuice || !entity.TryGetComponent(out ExtractableComponent? component)) continue;
canJuice = component.JuiceSolution != null; canJuice = component.JuiceSolution != null;
canGrind = component.GrindableSolution != null canGrind = component.GrindableSolution != null
&& _solutionsSystem.TryGetSolution(entity.Uid, component.GrindableSolution, out _); && _solutionsSystem.TryGetSolution(entity.Uid, component.GrindableSolution, out _);
} }
} }

View File

@@ -67,7 +67,7 @@ namespace Content.Server.Morgue.Components
return false; return false;
} }
var handsComponent = eventArgs.User.GetComponent<IHandsComponent>(); var handsComponent = eventArgs.User.GetComponent<HandsComponent>();
if (!handsComponent.Drop(eventArgs.Using, LabelContainer)) if (!handsComponent.Drop(eventArgs.Using, LabelContainer))
{ {
return false; return false;

View File

@@ -18,7 +18,7 @@ namespace Content.Server.PDA
{ {
IdCardComponent? firstIdInPda = null; IdCardComponent? firstIdInPda = null;
if (player.TryGetComponent(out IHandsComponent? hands)) if (player.TryGetComponent(out HandsComponent? hands))
{ {
foreach (var item in hands.GetAllHeldItems()) foreach (var item in hands.GetAllHeldItems())
{ {

View File

@@ -59,7 +59,7 @@ namespace Content.Server.Storage.Components
return false; return false;
} }
if (!user.TryGetComponent(out IHandsComponent? hands)) if (!user.TryGetComponent(out HandsComponent? hands))
return false; return false;
if (!hands.Drop(itemToHide, _itemContainer)) if (!hands.Drop(itemToHide, _itemContainer))

View File

@@ -219,7 +219,7 @@ namespace Content.Server.Storage.Components
{ {
EnsureInitialCalculated(); EnsureInitialCalculated();
if (!player.TryGetComponent(out IHandsComponent? hands) || if (!player.TryGetComponent(out HandsComponent? hands) ||
hands.GetActiveHand == null) hands.GetActiveHand == null)
{ {
return false; return false;

View File

@@ -1,11 +1,12 @@
using System.Linq;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Inventory.Components; using Content.Server.Inventory.Components;
using Content.Server.Items; using Content.Server.Items;
using Content.Server.Mind.Components;
using Content.Server.PDA; using Content.Server.PDA;
using Content.Server.Traitor.Uplink.Account; using Content.Server.Traitor.Uplink.Account;
using Content.Server.Traitor.Uplink.Components; using Content.Server.Traitor.Uplink.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.ActionBlocker;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Traitor.Uplink; using Content.Shared.Traitor.Uplink;
@@ -16,9 +17,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Player; using Robust.Shared.Player;
using System;
using System.Linq;
using Content.Shared.ActionBlocker;
namespace Content.Server.Traitor.Uplink namespace Content.Server.Traitor.Uplink
{ {
@@ -218,7 +216,7 @@ namespace Content.Server.Traitor.Uplink
} }
// Also check hands // Also check hands
if (user.TryGetComponent(out IHandsComponent? hands)) if (user.TryGetComponent(out HandsComponent? hands))
{ {
var heldItems = hands.GetAllHeldItems(); var heldItems = hands.GetAllHeldItems();
foreach (var item in heldItems) foreach (var item in heldItems)

View File

@@ -13,7 +13,6 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Sound; using Content.Shared.Sound;
using Content.Shared.Tools; using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Content.Shared.Wires; using Content.Shared.Wires;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -417,7 +416,7 @@ namespace Content.Server.WireHacking
return; return;
} }
if (!player.TryGetComponent(out IHandsComponent? handsComponent)) if (!player.TryGetComponent(out HandsComponent? handsComponent))
{ {
Owner.PopupMessage(player, Loc.GetString("wires-component-ui-on-receive-message-no-hands")); Owner.PopupMessage(player, Loc.GetString("wires-component-ui-on-receive-message-no-hands"));
return; return;

View File

@@ -1,8 +0,0 @@
using Robust.Shared.GameObjects;
namespace Content.Shared.Hands.Components
{
public interface ISharedHandsComponent : IComponent
{
}
}

View File

@@ -19,8 +19,8 @@ using Robust.Shared.ViewVariables;
namespace Content.Shared.Hands.Components namespace Content.Shared.Hands.Components
{ {
[NetworkedComponent()] [NetworkedComponent]
public abstract class SharedHandsComponent : Component, ISharedHandsComponent public abstract class SharedHandsComponent : Component
{ {
public sealed override string Name => "Hands"; public sealed override string Name => "Hands";
@@ -124,13 +124,12 @@ namespace Content.Shared.Hands.Components
if (HasHand(handName)) if (HasHand(handName))
return; return;
var container = ContainerHelpers.CreateContainer<ContainerSlot>(Owner, handName); var container = Owner.CreateContainer<ContainerSlot>(handName);
container.OccludesLight = false; container.OccludesLight = false;
Hands.Add(new Hand(handName, handLocation, container)); Hands.Add(new Hand(handName, handLocation, container));
if (ActiveHand == null) ActiveHand ??= handName;
ActiveHand = handName;
HandCountChanged(); HandCountChanged();
@@ -353,7 +352,7 @@ namespace Content.Shared.Hands.Components
} }
/// <summary> /// <summary>
/// Attempts to move a held item from a hand into a container that is not another hand, without dropping it on the floor inbetween. /// 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> /// </summary>
public bool Drop(IEntity entity, BaseContainer targetContainer, bool checkActionBlocker = true) public bool Drop(IEntity entity, BaseContainer targetContainer, bool checkActionBlocker = true)
{ {
@@ -391,8 +390,9 @@ namespace Content.Shared.Hands.Components
/// <summary> /// <summary>
/// Tries to remove the item in the active hand, without dropping it. /// Tries to remove the item in the active hand, without dropping it.
/// For transfering the held item to anothe rlocation, like an inventory slot, /// For transferring the held item to another location, like an inventory slot,
/// which souldn't trigger the drop interaction /// which shouldn't trigger the drop interaction
/// </summary>
public bool TryDropNoInteraction() public bool TryDropNoInteraction()
{ {
if (!TryGetActiveHand(out var hand)) if (!TryGetActiveHand(out var hand))

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.DragDrop; using Content.Shared.DragDrop;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Interaction.Events;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using static Content.Shared.Inventory.EquipmentSlotDefines; using static Content.Shared.Inventory.EquipmentSlotDefines;
@@ -17,7 +16,7 @@ namespace Content.Shared.Strip.Components
public bool CanBeStripped(IEntity by) public bool CanBeStripped(IEntity by)
{ {
return by != Owner return by != Owner
&& by.HasComponent<ISharedHandsComponent>() && by.HasComponent<SharedHandsComponent>()
&& EntitySystem.Get<ActionBlockerSystem>().CanInteract(by); && EntitySystem.Get<ActionBlockerSystem>().CanInteract(by);
} }