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:
@@ -1,6 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.GameObjects.Components.Items;
|
using Content.Server.GameObjects.Components.Items;
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
@@ -20,6 +17,9 @@ using Robust.Shared.Localization;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
@@ -27,7 +27,6 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal sealed class HandsSystem : EntitySystem
|
internal sealed class HandsSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
|
||||||
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons
|
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -37,6 +36,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleContainerModified);
|
SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleContainerModified);
|
||||||
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleContainerModified);
|
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleContainerModified);
|
||||||
|
SubscribeLocalEvent<HandsComponent, ExaminedEvent>(HandleExamined);
|
||||||
|
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(HandleSwapHands))
|
.Bind(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(HandleSwapHands))
|
||||||
@@ -53,9 +53,6 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
|
|
||||||
UnsubscribeLocalEvent<EntRemovedFromContainerMessage>();
|
|
||||||
UnsubscribeLocalEvent<EntInsertedIntoContainerMessage>();
|
|
||||||
|
|
||||||
CommandBinds.Unregister<HandsSystem>();
|
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)
|
private static bool TryGetAttachedComponent<T>(IPlayerSession? session, [NotNullWhen(true)] out T? component)
|
||||||
where T : Component
|
where T : Component
|
||||||
{
|
{
|
||||||
@@ -154,7 +160,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||||
{
|
{
|
||||||
var playerEnt = ((IPlayerSession?)session)?.AttachedEntity;
|
var playerEnt = ((IPlayerSession?) session)?.AttachedEntity;
|
||||||
|
|
||||||
if (playerEnt == null || !playerEnt.IsValid())
|
if (playerEnt == null || !playerEnt.IsValid())
|
||||||
return false;
|
return false;
|
||||||
@@ -180,7 +186,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
}
|
}
|
||||||
else
|
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);
|
RaiseLocalEvent(throwEnt.Uid, splitStack);
|
||||||
|
|
||||||
if (splitStack.Result == null)
|
if (splitStack.Result == null)
|
||||||
|
|||||||
4
Resources/Locale/en-US/components/hands-component.ftl
Normal file
4
Resources/Locale/en-US/components/hands-component.ftl
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
### HandComponent stuff
|
||||||
|
|
||||||
|
# Examine text after when they're holding something (in-hand)
|
||||||
|
comp-hands-examine = { CAPITALIZE(SUBJECT($user)) } { CONJUGATE-BE($user) } holding a { $item }.
|
||||||
Reference in New Issue
Block a user