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,10 +1,12 @@
using System;
using Content.Shared.ActionBlocker;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Inventory;
using Content.Shared.Sound;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
@@ -123,7 +125,7 @@ namespace Content.Shared.Item
if (!CanPickup(user))
return false;
if (!_entMan.TryGetComponent(user, out SharedHandsComponent? hands))
if (!_entMan.TryGetComponent(user, out SharedHandsComponent hands))
return false;
var activeHand = hands.ActiveHand;
@@ -131,15 +133,27 @@ namespace Content.Shared.Item
if (activeHand == null)
return false;
hands.TryPickupEntityToActiveHand(Owner);
hands.TryPickupEntityToActiveHand(Owner, animateUser: true);
return true;
}
protected virtual void OnEquippedPrefixChange() { }
private void OnEquippedPrefixChange()
{
if (Owner.TryGetContainer(out var container))
EntitySystem.Get<SharedHandsSystem>().UpdateHandVisualizer(container.Owner);
}
public virtual void RemovedFromSlot() { }
public void RemovedFromSlot()
{
if (_entMan.TryGetComponent(Owner, out SharedSpriteComponent component))
component.Visible = true;
}
public virtual void EquippedToSlot() { }
public virtual void EquippedToSlot()
{
if (_entMan.TryGetComponent(Owner, out SharedSpriteComponent component))
component.Visible = false;
}
}
[Serializable, NetSerializable]