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

@@ -47,18 +47,14 @@ namespace Content.Server.Strip
_strippableSystem = EntitySystem.Get<StrippableSystem>();
Owner.EnsureComponentWarn<ServerInventoryComponent>();
var hands = Owner.EnsureComponentWarn<HandsComponent>();
var cuffed = Owner.EnsureComponentWarn<CuffableComponent>();
cuffed.OnCuffedStateChanged += UpdateState;
hands.OnItemChanged += UpdateState;
}
protected override void Shutdown()
{
base.Shutdown();
if(_entities.TryGetComponent<HandsComponent>(Owner, out var hands))
hands.OnItemChanged -= UpdateState;
if(_entities.TryGetComponent<CuffableComponent>(Owner, out var cuffed))
cuffed.OnCuffedStateChanged -= UpdateState;
}
@@ -208,8 +204,8 @@ namespace Content.Server.Strip
if (result != DoAfterStatus.Finished) return;
userHands.Drop(hand);
hands.TryPickupEntity(hand, item!.Owner, checkActionBlocker: false);
UpdateState();
hands.TryPickupEntity(hand, item!.Owner, checkActionBlocker: false, animateUser: true);
// hand update will trigger strippable update
}
/// <summary>
@@ -314,10 +310,12 @@ namespace Content.Server.Strip
var result = await doAfterSystem.WaitDoAfter(doAfterArgs);
if (result != DoAfterStatus.Finished) return;
var item = hands.GetItem(hand);
if (!hands.TryGetHeldEntity(hand, out var entity))
return;
hands.Drop(hand, false);
userHands.PutInHandOrDrop(item!);
UpdateState();
userHands.PutInHandOrDrop(entity.Value);
// hand update will trigger strippable update
}
private void HandleUserInterfaceMessage(ServerBoundUserInterfaceMessage obj)

View File

@@ -43,7 +43,7 @@ namespace Content.Server.Strip
public void SendUpdate(EntityUid uid, StrippableComponent? strippableComponent = null)
{
if (!Resolve(uid, ref strippableComponent) || strippableComponent.UserInterface == null)
if (!Resolve(uid, ref strippableComponent, false) || strippableComponent.UserInterface == null)
{
return;
}