Files
tbd-station-14/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

36 lines
1.1 KiB
C#

#nullable enable
using System.Collections.Generic;
using Robust.Shared.GameObjects;
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()
{
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;
}
}
}
}
}
}
}
}