Fix removehand command when you have no hands (#2685)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
DrSmugleaf
2020-12-04 13:17:40 +01:00
committed by GitHub
parent af28de36ee
commit 1eaad7e5d7
2 changed files with 8 additions and 11 deletions

View File

@@ -42,14 +42,14 @@ namespace Content.Server.Commands.Body
return;
}
var hand = body.Parts.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
if (hand.Value.Equals(default))
var (_, hand) = body.Parts.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
if (hand == null)
{
shell.SendText(player, "You have no hands.");
}
else
{
body.RemovePart(hand.Value);
body.RemovePart(hand);
}
}
}

View File

@@ -196,17 +196,15 @@ namespace Content.Shared.GameObjects.Components.Body
{
DebugTools.AssertNotNull(part);
var pair = _parts.FirstOrDefault(kvPair => kvPair.Value == part);
(slotName, _) = _parts.FirstOrDefault(kvPair => kvPair.Value == part);
if (pair.Equals(default))
if (slotName == null)
{
slotName = null;
return false;
}
if (RemovePart(pair.Key))
if (RemovePart(slotName))
{
slotName = pair.Key;
return true;
}
@@ -310,10 +308,9 @@ namespace Content.Shared.GameObjects.Components.Body
{
// We enforce that there is only one of each value in the dictionary,
// so we can iterate through the dictionary values to get the key from there.
var pair = Parts.FirstOrDefault(x => x.Value == part);
slot = pair.Key;
(slot, _) = Parts.FirstOrDefault(x => x.Value == part);
return !pair.Equals(default);
return slot != null;
}
public bool TryGetSlotType(string slot, out BodyPartType result)