Fix suicide exception when entity has no hands.
Can be the case with ghost roles, etc.
This commit is contained in:
@@ -88,9 +88,8 @@ namespace Content.Server.Chat.Commands
|
||||
$"{_entities.ToPrettyString(player.AttachedEntity.Value):player} is committing suicide");
|
||||
|
||||
// Held item suicide
|
||||
var handsComponent = _entities.GetComponent<HandsComponent>(owner);
|
||||
var itemComponent = handsComponent.GetActiveHandItem;
|
||||
if (itemComponent != null)
|
||||
if (_entities.TryGetComponent(owner, out HandsComponent handsComponent)
|
||||
&& handsComponent.GetActiveHandItem is {} itemComponent)
|
||||
{
|
||||
var suicide = _entities.GetComponents<ISuicideAct>(itemComponent.Owner).FirstOrDefault();
|
||||
|
||||
@@ -100,6 +99,7 @@ namespace Content.Server.Chat.Commands
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Get all entities in range of the suicider
|
||||
var entities = EntitySystem.Get<EntityLookupSystem>().GetEntitiesInRange(owner, 1, LookupFlags.Approximate | LookupFlags.IncludeAnchored).ToArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user