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");
|
$"{_entities.ToPrettyString(player.AttachedEntity.Value):player} is committing suicide");
|
||||||
|
|
||||||
// Held item suicide
|
// Held item suicide
|
||||||
var handsComponent = _entities.GetComponent<HandsComponent>(owner);
|
if (_entities.TryGetComponent(owner, out HandsComponent handsComponent)
|
||||||
var itemComponent = handsComponent.GetActiveHandItem;
|
&& handsComponent.GetActiveHandItem is {} itemComponent)
|
||||||
if (itemComponent != null)
|
|
||||||
{
|
{
|
||||||
var suicide = _entities.GetComponents<ISuicideAct>(itemComponent.Owner).FirstOrDefault();
|
var suicide = _entities.GetComponents<ISuicideAct>(itemComponent.Owner).FirstOrDefault();
|
||||||
|
|
||||||
@@ -100,6 +99,7 @@ namespace Content.Server.Chat.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all entities in range of the suicider
|
// Get all entities in range of the suicider
|
||||||
var entities = EntitySystem.Get<EntityLookupSystem>().GetEntitiesInRange(owner, 1, LookupFlags.Approximate | LookupFlags.IncludeAnchored).ToArray();
|
var entities = EntitySystem.Get<EntityLookupSystem>().GetEntitiesInRange(owner, 1, LookupFlags.Approximate | LookupFlags.IncludeAnchored).ToArray();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user