Make more uids nullable (#5794)

This commit is contained in:
Leon Friedrich
2021-12-26 15:32:45 +13:00
committed by GitHub
parent 83114de0e4
commit afc3ae6335
42 changed files with 161 additions and 204 deletions

View File

@@ -64,15 +64,17 @@ namespace Content.Shared.Verbs
// call ActionBlocker checks, just cache it for the verb request.
var canInteract = force || _actionBlockerSystem.CanInteract(user);
EntityUid @using = default;
if (EntityManager.TryGetComponent(user, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user)))
EntityUid? @using = null;
if (TryComp(user, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user)))
{
hands.TryGetActiveHeldEntity(out @using);
// TODO Hands remove nullable (#5634)
hands.TryGetActiveHeldEntity(out var nonNullableUsing);
@using = nonNullableUsing;
// Check whether the "Held" entity is a virtual pull entity. If yes, set that as the entity being "Used".
// This allows you to do things like buckle a dragged person onto a surgery table, without click-dragging
// their sprite.
if (@using != default && EntityManager.TryGetComponent<HandVirtualItemComponent?>(@using, out var pull))
if (@using != null && TryComp(@using, out HandVirtualItemComponent? pull))
{
@using = pull.BlockingEntity;
}