Make power node not die on map load.
This commit is contained in:
@@ -51,6 +51,10 @@ namespace Content.Server.GameObjects.Components.Power
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void TryCreatePowernetConnection()
|
public void TryCreatePowernetConnection()
|
||||||
{
|
{
|
||||||
|
if (Parent != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
var _emanager = IoCManager.Resolve<IServerEntityManager>();
|
var _emanager = IoCManager.Resolve<IServerEntityManager>();
|
||||||
var position = Owner.GetComponent<TransformComponent>().WorldPosition;
|
var position = Owner.GetComponent<TransformComponent>().WorldPosition;
|
||||||
var wires = _emanager.GetEntitiesIntersecting(Owner)
|
var wires = _emanager.GetEntitiesIntersecting(Owner)
|
||||||
@@ -58,7 +62,13 @@ namespace Content.Server.GameObjects.Components.Power
|
|||||||
.OrderByDescending(x => (x.GetComponent<TransformComponent>().WorldPosition - position).Length);
|
.OrderByDescending(x => (x.GetComponent<TransformComponent>().WorldPosition - position).Length);
|
||||||
var choose = wires.FirstOrDefault();
|
var choose = wires.FirstOrDefault();
|
||||||
if (choose != null)
|
if (choose != null)
|
||||||
ConnectToPowernet(choose.GetComponent<PowerTransferComponent>().Parent);
|
{
|
||||||
|
var transfer = choose.GetComponent<PowerTransferComponent>();
|
||||||
|
if (transfer.Parent != null)
|
||||||
|
{
|
||||||
|
ConnectToPowernet(transfer.Parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user