hands ECS (#7081)
This commit is contained in:
@@ -8,6 +8,7 @@ using Content.Server.Hands.Components;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Item;
|
||||
@@ -46,6 +47,7 @@ namespace Content.Server.Storage.Components
|
||||
public sealed class ServerStorageComponent : SharedStorageComponent, IInteractUsing, IActivate, IStorageComponent, IDestroyAct, IExAct, IAfterInteract
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
||||
|
||||
private const string LoggerName = "Storage";
|
||||
|
||||
@@ -243,22 +245,24 @@ namespace Content.Server.Storage.Components
|
||||
EnsureInitialCalculated();
|
||||
|
||||
if (!_entityManager.TryGetComponent(player, out HandsComponent? hands) ||
|
||||
hands.GetActiveHandItem == null)
|
||||
hands.ActiveHandEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var toInsert = hands.GetActiveHandItem;
|
||||
var toInsert = hands.ActiveHandEntity;
|
||||
|
||||
if (!hands.Drop(toInsert.Owner))
|
||||
var handSys = _sysMan.GetEntitySystem<SharedHandsSystem>();
|
||||
|
||||
if (!handSys.TryDrop(player, toInsert.Value, handsComp: hands))
|
||||
{
|
||||
Owner.PopupMessage(player, "Can't insert.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Insert(toInsert.Owner))
|
||||
if (!Insert(toInsert.Value))
|
||||
{
|
||||
hands.PutInHand(toInsert);
|
||||
handSys.PickupOrDrop(player, toInsert.Value, handsComp: hands);
|
||||
Owner.PopupMessage(player, "Can't insert.");
|
||||
return false;
|
||||
}
|
||||
@@ -475,18 +479,7 @@ namespace Content.Server.Storage.Components
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_entityManager.TryGetComponent(remove.EntityUid, out SharedItemComponent? item) || !_entityManager.TryGetComponent(player, out HandsComponent? hands))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hands.CanPutInHand(item))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
hands.PutInHand(item);
|
||||
|
||||
_sysMan.GetEntitySystem<SharedHandsSystem>().TryPickupAnyHand(player, remove.EntityUid);
|
||||
break;
|
||||
}
|
||||
case InsertEntityMessage _:
|
||||
|
||||
Reference in New Issue
Block a user