2022-02-07 01:10:33 +13:00
|
|
|
using Content.Server.NodeContainer;
|
2023-08-25 20:40:42 +02:00
|
|
|
using Content.Server.NodeContainer.EntitySystems;
|
2021-07-04 18:11:52 +02:00
|
|
|
using Content.Server.NodeContainer.Nodes;
|
2022-11-22 13:12:04 +11:00
|
|
|
using Robust.Shared.Map.Components;
|
2021-07-04 18:11:52 +02:00
|
|
|
|
|
|
|
|
namespace Content.Server.Power.Nodes
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Type of node that connects to a <see cref="CableNode"/> below it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataDefinition]
|
2022-02-16 00:23:23 -07:00
|
|
|
[Virtual]
|
2023-08-22 18:14:33 -07:00
|
|
|
public partial class CableDeviceNode : Node
|
2021-07-04 18:11:52 +02:00
|
|
|
{
|
2023-08-25 20:40:42 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// If disabled, this cable device will never connect.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// If you change this,
|
|
|
|
|
/// you must manually call <see cref="NodeGroupSystem.QueueReflood"/> to update the node connections.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
[DataField("enabled")]
|
|
|
|
|
public bool Enabled { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public override bool Connectable(IEntityManager entMan, TransformComponent? xform = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Enabled)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return base.Connectable(entMan, xform);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
2021-07-04 18:11:52 +02:00
|
|
|
{
|
2022-02-07 01:10:33 +13:00
|
|
|
if (!xform.Anchored || grid == null)
|
2021-12-13 00:45:54 -05:00
|
|
|
yield break;
|
|
|
|
|
|
2022-02-07 01:10:33 +13:00
|
|
|
var gridIndex = grid.TileIndicesFor(xform.Coordinates);
|
2021-10-05 09:50:28 +02:00
|
|
|
|
2022-02-07 01:10:33 +13:00
|
|
|
foreach (var node in NodeHelpers.GetNodesInTile(nodeQuery, grid, gridIndex))
|
2021-07-04 18:11:52 +02:00
|
|
|
{
|
|
|
|
|
if (node is CableNode)
|
|
|
|
|
yield return node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|