2021-04-28 10:49:37 -07:00
|
|
|
using Robust.Shared.Map;
|
2022-11-22 13:12:04 +11:00
|
|
|
using Robust.Shared.Map.Components;
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.NodeContainer.Nodes
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A <see cref="Node"/> that can reach other <see cref="AdjacentNode"/>s that are directly adjacent to it.
|
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class AdjacentNode : Node
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
2022-02-07 01:10:33 +13:00
|
|
|
public override IEnumerable<Node> GetReachableNodes(TransformComponent xform,
|
|
|
|
|
EntityQuery<NodeContainerComponent> nodeQuery,
|
|
|
|
|
EntityQuery<TransformComponent> xformQuery,
|
2022-11-22 13:12:04 +11:00
|
|
|
MapGridComponent? grid,
|
2022-02-07 01:10:33 +13:00
|
|
|
IEntityManager entMan)
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
2022-02-07 01:10:33 +13:00
|
|
|
if (!xform.Anchored || grid == null)
|
2021-03-02 11:58:19 -07:00
|
|
|
yield break;
|
|
|
|
|
|
2022-02-07 01:10:33 +13:00
|
|
|
var gridIndex = grid.TileIndicesFor(xform.Coordinates);
|
2021-04-09 20:47:31 +02:00
|
|
|
|
2022-02-07 01:10:33 +13:00
|
|
|
foreach (var (_, node) in NodeHelpers.GetCardinalNeighborNodes(nodeQuery, grid, gridIndex))
|
2021-07-04 18:11:52 +02:00
|
|
|
{
|
|
|
|
|
if (node != this)
|
|
|
|
|
yield return node;
|
2021-01-01 19:04:10 -06:00
|
|
|
}
|
2020-06-28 09:23:26 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|