* 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
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using Content.Shared.Hands.Components;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.Client.Hands
|
|
{
|
|
[RegisterComponent]
|
|
[ComponentReference(typeof(SharedHandsComponent))]
|
|
public class HandsComponent : SharedHandsComponent
|
|
{
|
|
public HandsGui? Gui { get; set; }
|
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
{
|
|
if (curState is not HandsComponentState state)
|
|
return;
|
|
|
|
Hands.Clear();
|
|
|
|
foreach (var handState in state.Hands)
|
|
{
|
|
var newHand = new Hand(handState.Name, handState.Location);
|
|
Hands.Add(newHand);
|
|
}
|
|
|
|
ActiveHand = state.ActiveHand;
|
|
|
|
HandsModified();
|
|
}
|
|
|
|
public override void HandsModified()
|
|
{
|
|
UpdateHandContainers();
|
|
|
|
base.HandsModified();
|
|
}
|
|
|
|
public void UpdateHandContainers()
|
|
{
|
|
if (!Owner.TryGetComponent<ContainerManagerComponent>(out var containerMan))
|
|
return;
|
|
|
|
foreach (var hand in Hands)
|
|
{
|
|
if (hand.Container == null)
|
|
{
|
|
containerMan.TryGetContainer(hand.Name, out var container);
|
|
hand.Container = container;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|