Partial hand ECS (#5634)

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
Co-authored-by: Paul <ritter.paul1@googlemail.com>
This commit is contained in:
Leon Friedrich
2022-01-05 17:53:08 +13:00
committed by GitHub
parent 03ad20758e
commit adbc4ee5b0
34 changed files with 781 additions and 963 deletions

View File

@@ -1,5 +1,5 @@
using Content.Shared.Hands.Components;
using Robust.Shared.Containers;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -7,48 +7,9 @@ namespace Content.Client.Hands
{
[RegisterComponent]
[ComponentReference(typeof(SharedHandsComponent))]
[Friend(typeof(HandsSystem))]
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 (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(Owner, out var containerMan))
return;
foreach (var hand in Hands)
{
if (hand.Container == null)
{
containerMan.TryGetContainer(hand.Name, out var container);
hand.Container = container;
}
}
}
}
}