mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 16:47:26 +00:00
* Add overloads for NodeHelpers methods, obsolete old ones * Pass in SharedMapSystem instead of IEntityManager * Change GetReachableNodes signature, deal with aftermath * Allow non-grid nodes * Change GetReachableNodes to also take Entity<TransformComponent> * Remove vestigial ReSharper hint Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Formatting --------- Co-authored-by: TemporalOroboros <TemporalOroboros@gmail.com>
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using Content.Shared.NodeContainer;
|
|
using Robust.Shared.Map.Components;
|
|
|
|
namespace Content.Server.NodeContainer.Nodes
|
|
{
|
|
/// <summary>
|
|
/// A <see cref="Node"/> that can reach other <see cref="AdjacentNode"/>s that are directly adjacent to it.
|
|
/// </summary>
|
|
[DataDefinition]
|
|
public sealed partial class AdjacentNode : Node
|
|
{
|
|
public override IEnumerable<Node> GetReachableNodes(
|
|
Entity<TransformComponent> xform,
|
|
EntityQuery<NodeContainerComponent> nodeQuery,
|
|
EntityQuery<TransformComponent> xformQuery,
|
|
Entity<MapGridComponent>? grid,
|
|
IEntityManager entMan)
|
|
{
|
|
if (!xform.Comp.Anchored || grid is not { } gridEnt)
|
|
yield break;
|
|
|
|
var mapSystem = entMan.System<SharedMapSystem>();
|
|
var gridIndex = mapSystem.TileIndicesFor(gridEnt, xform.Comp.Coordinates);
|
|
|
|
foreach (var (_, node) in NodeHelpers.GetCardinalNeighborNodes(nodeQuery, gridEnt, gridIndex, mapSystem))
|
|
{
|
|
if (node != this)
|
|
yield return node;
|
|
}
|
|
}
|
|
}
|
|
}
|