Improve stripping UI (#9768)

This commit is contained in:
Leon Friedrich
2022-10-16 06:00:04 +13:00
committed by GitHub
parent be90d63d15
commit efac113469
32 changed files with 518 additions and 461 deletions

View File

@@ -2,6 +2,7 @@ using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using JetBrains.Annotations;
using System.Diagnostics.CodeAnalysis;
namespace Content.Server.Hands.Systems
{
@@ -10,16 +11,21 @@ namespace Content.Server.Hands.Systems
{
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
public bool TrySpawnVirtualItemInHand(EntityUid blockingEnt, EntityUid user)
public bool TrySpawnVirtualItemInHand(EntityUid blockingEnt, EntityUid user) => TrySpawnVirtualItemInHand(blockingEnt, user, out _);
public bool TrySpawnVirtualItemInHand(EntityUid blockingEnt, EntityUid user, [NotNullWhen(true)] out EntityUid? virtualItem)
{
if (!_handsSystem.TryGetEmptyHand(user, out var hand))
{
virtualItem = null;
return false;
}
var pos = EntityManager.GetComponent<TransformComponent>(user).Coordinates;
var virtualItem = EntityManager.SpawnEntity("HandVirtualItem", pos);
var virtualItemComp = EntityManager.GetComponent<HandVirtualItemComponent>(virtualItem);
virtualItem = EntityManager.SpawnEntity("HandVirtualItem", pos);
var virtualItemComp = EntityManager.GetComponent<HandVirtualItemComponent>(virtualItem.Value);
virtualItemComp.BlockingEntity = blockingEnt;
_handsSystem.DoPickup(user, hand, virtualItem);
_handsSystem.DoPickup(user, hand, virtualItem.Value);
return true;
}

View File

@@ -106,23 +106,6 @@ namespace Content.Server.Hands.Systems
}
#region EntityInsertRemove
public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, SharedHandsComponent? hands = null)
{
base.DoDrop(uid, hand,doDropInteraction, hands);
// update gui of anyone stripping this entity.
_strippableSystem.SendUpdate(uid);
}
public override void DoPickup(EntityUid uid, Hand hand, EntityUid entity, SharedHandsComponent? hands = null)
{
base.DoPickup(uid, hand, entity, hands);
// update gui of anyone stripping this entity.
_strippableSystem.SendUpdate(uid);
}
public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition,
EntityUid? exclude)
{