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

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Act;
using Content.Server.Interaction;
using Content.Server.Popups;
using Content.Server.Pulling;
using Content.Shared.Audio;
@@ -13,12 +12,10 @@ using Content.Shared.Item;
using Content.Shared.Popups;
using Content.Shared.Pulling.Components;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -37,32 +34,6 @@ namespace Content.Server.Hands.Components
int IDisarmedAct.Priority => int.MaxValue; // We want this to be the last disarm act to run.
protected override void OnHeldEntityRemovedFromHand(EntityUid heldEntity, HandState handState)
{
if (_entities.TryGetComponent(heldEntity, out SharedItemComponent? item))
{
item.RemovedFromSlot();
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedHandInteraction(Owner, heldEntity, handState);
}
if (_entities.TryGetComponent(heldEntity, out SpriteComponent? sprite))
{
sprite.RenderOrder = _entities.CurrentTick.Value;
}
}
protected override void HandlePickupAnimation(EntityUid entity)
{
var initialPosition = EntityCoordinates.FromMap(_entities.GetComponent<TransformComponent>(Owner).Parent?.Owner ?? Owner, _entities.GetComponent<TransformComponent>(entity).MapPosition);
var finalPosition = _entities.GetComponent<TransformComponent>(Owner).LocalPosition;
if (finalPosition.EqualsApprox(initialPosition.Position))
return;
_entities.EntityNetManager!.SendSystemNetworkMessage(
new PickupAnimationMessage(entity, finalPosition, initialPosition));
}
#region Pull/Disarm
void IBodyPartAdded.BodyPartAdded(BodyPartAddedEventArgs args)
@@ -198,24 +169,6 @@ namespace Content.Server.Hands.Components
yield return item;
}
}
/// <summary>
/// Checks if any hand can pick up an item.
/// </summary>
public bool CanPutInHand(SharedItemComponent item, bool mobCheck = true)
{
var entity = item.Owner;
if (mobCheck && !PlayerCanPickup())
return false;
foreach (var hand in Hands)
{
if (CanInsertEntityIntoHand(hand, entity))
return true;
}
return false;
}
#endregion
}
}