Fix removehand throwing exception when no hand exists (#1570)

* Fix removehand throwing exception when no hand exists

* Message when you have no hands
This commit is contained in:
Exp
2020-08-02 17:31:43 +02:00
committed by GitHub
parent c61e6d541b
commit a73c5ba323

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.BodySystem;
@@ -388,8 +388,16 @@ namespace Content.Server.GameTicking
}
var manager = player.AttachedEntity.GetComponent<BodyManagerComponent>();
var hand = manager.PartDictionary.First(x => x.Value.PartType == BodyPartType.Hand);
manager.DisconnectBodyPart(hand.Value, true);
var hand = manager.PartDictionary.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
if (hand.Value == null)
{
shell.SendText(player, "You have no hands.");
return;
}
else
{
manager.DisconnectBodyPart(hand.Value, true);
}
}
}
}