Files
tbd-station-14/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs
DrSmugleaf 4a8ed41e3a Fix namespaces and optimize imports (#1651)
* Fix namespaces and optimize imports

* Cleanup fixes

* Merge conflict fixes

* Merge conflict fixes

* Merge conflict fixes
2020-08-13 14:40:27 +02:00

24 lines
919 B
C#

using System.Collections.Generic;
using System.Linq;
using Robust.Shared.GameObjects.Components.Transform;
namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
{
/// <summary>
/// A <see cref="Node"/> that can reach other <see cref="AdjacentNode"/>s that are directly adjacent to it.
/// </summary>
public class AdjacentNode : Node
{
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);
}
}
}