Make held entity nullable (#5923)

This commit is contained in:
wrexbe
2021-12-30 18:27:15 -08:00
committed by GitHub
parent 761dfb48af
commit abba1e1c2c
11 changed files with 68 additions and 86 deletions

View File

@@ -77,10 +77,10 @@ namespace Content.Client.Hands
return new HandsGuiState(states, hands.ActiveHand);
}
public EntityUid GetActiveHandEntity()
public EntityUid? GetActiveHandEntity()
{
if (GetPlayerHandsComponent() is not { ActiveHand: { } active } hands)
return default;
return null;
return hands.GetHand(active).HeldEntity;
}
@@ -106,7 +106,7 @@ namespace Content.Client.Hands
var pressedEntity = pressedHand.HeldEntity;
var activeEntity = activeHand.HeldEntity;
if (pressedHand == activeHand && activeEntity != default)
if (pressedHand == activeHand && activeEntity != null)
{
// use item in hand
// it will always be attack_self() in my heart.
@@ -114,14 +114,14 @@ namespace Content.Client.Hands
return;
}
if (pressedHand != activeHand && pressedEntity == default)
if (pressedHand != activeHand && pressedEntity == null)
{
// change active hand
RaiseNetworkEvent(new RequestSetHandEvent(handName));
return;
}
if (pressedHand != activeHand && pressedEntity != default && activeEntity != default)
if (pressedHand != activeHand && pressedEntity != null && activeEntity != null)
{
// use active item on held item
RaiseNetworkEvent(new ClientInteractUsingInHandMsg(pressedHand.Name));