Removes some linq from power (#2875)

* PowerProviderComponent Linq removal

* AdjacentNode Linq removal

* PipeNode Linq removal

* Replaces HasFlag usage in PipeNode

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2021-01-01 19:04:10 -06:00
committed by GitHub
parent 836e2d185a
commit a87dda47e9
4 changed files with 62 additions and 27 deletions

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using Robust.Shared.GameObjects.Components.Transform;
namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
@@ -11,13 +10,25 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
{
protected override IEnumerable<Node> GetReachableNodes()
{
return Owner.GetComponent<SnapGridComponent>()
.GetCardinalNeighborCells()
.SelectMany(sgc => sgc.GetLocal())
.Select(entity => entity.TryGetComponent<NodeContainerComponent>(out var container) ? container : null)
.Where(container => container != null)
.SelectMany(container => container.Nodes)
.Where(node => node != null && node != this);
var cells = Owner.GetComponent<SnapGridComponent>()
.GetCardinalNeighborCells();
foreach (var cell in cells)
{
foreach (var entity in cell.GetLocal())
{
if (entity.TryGetComponent<NodeContainerComponent>(out var container))
{
foreach (var node in container.Nodes)
{
if (node != null && node != this)
{
yield return node;
}
}
}
}
}
}
}
}