Files
tbd-station-14/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs
py01 01b10cb687 Node serialization change (#1497)
* NodeContainerComponent serializes a set of Nodes with ExposeData

* Fixes Nodes to work when being created by serializer

* ConduitNode

* ConduitPlacer to replace WirePlacer

* ConduitNode ConduitLayer setter

* Map update

* Comments

* Map update again

* Method ordering by privacy

* Removes conduits

* ignored component

* reorg

* map update

* readd wireplacer

Co-authored-by: py01 <pyronetics01@gmail.com>
2020-08-07 02:47:54 +02:00

24 lines
919 B
C#

using Robust.Shared.GameObjects.Components.Transform;
using System.Collections.Generic;
using System.Linq;
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);
}
}
}