Adds hands examine text (#4160)

* Adds hands examine text.

* Cleans the code

* Fixes?

* Update Resources/Locale/en-US/components/hands-component.ftl

Thankies ❤

Co-authored-by: mirrorcult <notzombiedude@gmail.com>

* Put it under handcontainer and shutdown

Co-authored-by: mirrorcult <notzombiedude@gmail.com>
This commit is contained in:
T-Stalker
2021-06-09 05:39:31 -03:00
committed by GitHub
parent 3b3a11a905
commit 1c582ac2ec
2 changed files with 19 additions and 9 deletions

View File

@@ -1,6 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items;
using Content.Server.GameObjects.Components.Items.Storage;
@@ -20,6 +17,9 @@ using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
namespace Content.Server.GameObjects.EntitySystems
@@ -27,7 +27,6 @@ namespace Content.Server.GameObjects.EntitySystems
[UsedImplicitly]
internal sealed class HandsSystem : EntitySystem
{
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons
/// <inheritdoc />
@@ -37,6 +36,7 @@ namespace Content.Server.GameObjects.EntitySystems
SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleContainerModified);
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleContainerModified);
SubscribeLocalEvent<HandsComponent, ExaminedEvent>(HandleExamined);
CommandBinds.Builder
.Bind(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(HandleSwapHands))
@@ -53,9 +53,6 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Shutdown();
UnsubscribeLocalEvent<EntRemovedFromContainerMessage>();
UnsubscribeLocalEvent<EntInsertedIntoContainerMessage>();
CommandBinds.Unregister<HandsSystem>();
}
@@ -67,6 +64,15 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
//TODO: Actually shows all items/clothing/etc.
private void HandleExamined(EntityUid uid, HandsComponent component, ExaminedEvent args)
{
foreach (var inhand in component.GetAllHeldItems())
{
args.Message.AddText($"\n{Loc.GetString("comp-hands-examine", ("user", component.Owner), ("item", inhand.Owner))}");
}
}
private static bool TryGetAttachedComponent<T>(IPlayerSession? session, [NotNullWhen(true)] out T? component)
where T : Component
{
@@ -154,7 +160,7 @@ namespace Content.Server.GameObjects.EntitySystems
private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{
var playerEnt = ((IPlayerSession?)session)?.AttachedEntity;
var playerEnt = ((IPlayerSession?) session)?.AttachedEntity;
if (playerEnt == null || !playerEnt.IsValid())
return false;
@@ -180,7 +186,7 @@ namespace Content.Server.GameObjects.EntitySystems
}
else
{
var splitStack = new StackSplitEvent() {Amount = 1, SpawnPosition = playerEnt.Transform.Coordinates};
var splitStack = new StackSplitEvent() { Amount = 1, SpawnPosition = playerEnt.Transform.Coordinates };
RaiseLocalEvent(throwEnt.Uid, splitStack);
if (splitStack.Result == null)