Fix removehand command when you have no hands (#2685)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -42,14 +42,14 @@ namespace Content.Server.Commands.Body
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hand = body.Parts.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
|
var (_, hand) = body.Parts.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
|
||||||
if (hand.Value.Equals(default))
|
if (hand == null)
|
||||||
{
|
{
|
||||||
shell.SendText(player, "You have no hands.");
|
shell.SendText(player, "You have no hands.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body.RemovePart(hand.Value);
|
body.RemovePart(hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,17 +196,15 @@ namespace Content.Shared.GameObjects.Components.Body
|
|||||||
{
|
{
|
||||||
DebugTools.AssertNotNull(part);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RemovePart(pair.Key))
|
if (RemovePart(slotName))
|
||||||
{
|
{
|
||||||
slotName = pair.Key;
|
|
||||||
return true;
|
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,
|
// 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.
|
// so we can iterate through the dictionary values to get the key from there.
|
||||||
var pair = Parts.FirstOrDefault(x => x.Value == part);
|
(slot, _) = Parts.FirstOrDefault(x => x.Value == part);
|
||||||
slot = pair.Key;
|
|
||||||
|
|
||||||
return !pair.Equals(default);
|
return slot != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetSlotType(string slot, out BodyPartType result)
|
public bool TryGetSlotType(string slot, out BodyPartType result)
|
||||||
|
|||||||
Reference in New Issue
Block a user