From 1eaad7e5d7b01420ded62087055783381801d7e3 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Fri, 4 Dec 2020 13:17:40 +0100 Subject: [PATCH] Fix removehand command when you have no hands (#2685) Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- Content.Server/Commands/Body/RemoveHandCommand.cs | 6 +++--- .../Components/Body/SharedBodyComponent.cs | 13 +++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Content.Server/Commands/Body/RemoveHandCommand.cs b/Content.Server/Commands/Body/RemoveHandCommand.cs index 090927903a..6491c5525e 100644 --- a/Content.Server/Commands/Body/RemoveHandCommand.cs +++ b/Content.Server/Commands/Body/RemoveHandCommand.cs @@ -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); } } } diff --git a/Content.Shared/GameObjects/Components/Body/SharedBodyComponent.cs b/Content.Shared/GameObjects/Components/Body/SharedBodyComponent.cs index dcb2e26ad8..b343c4e66a 100644 --- a/Content.Shared/GameObjects/Components/Body/SharedBodyComponent.cs +++ b/Content.Shared/GameObjects/Components/Body/SharedBodyComponent.cs @@ -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)