Fix exceptions on round restarts due to accessing deleted entities' components
This commit is contained in:
@@ -91,7 +91,8 @@ namespace Content.Server.GameObjects.Components.Markers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.GridPosition);
|
if(!Owner.Deleted)
|
||||||
|
_entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.GridPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MapInit()
|
public void MapInit()
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ namespace Content.Server.GameObjects.Components.Power
|
|||||||
private void ConnectToBestProvider()
|
private void ConnectToBestProvider()
|
||||||
{
|
{
|
||||||
//Any values we can connect to or are we already connected to a node, cancel!
|
//Any values we can connect to or are we already connected to a node, cancel!
|
||||||
if (!AvailableProviders.Any() || Connected == DrawTypes.Node || Deleted)
|
if (!AvailableProviders.Any() || Connected == DrawTypes.Node || Deleted || Owner.Deleted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Get the starting value for our loop
|
//Get the starting value for our loop
|
||||||
@@ -300,6 +300,9 @@ namespace Content.Server.GameObjects.Components.Power
|
|||||||
|
|
||||||
foreach (var availprovider in AvailableProviders)
|
foreach (var availprovider in AvailableProviders)
|
||||||
{
|
{
|
||||||
|
if (availprovider.Owner.Deleted)
|
||||||
|
continue;
|
||||||
|
|
||||||
//Find distance to new provider
|
//Find distance to new provider
|
||||||
var distance = (availprovider.Owner.GetComponent<ITransformComponent>().WorldPosition - position).LengthSquared;
|
var distance = (availprovider.Owner.GetComponent<ITransformComponent>().WorldPosition - position).LengthSquared;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user