Little NodeContainer ECS (#17702)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
@@ -18,10 +19,12 @@ namespace Content.Server.Electrocution
|
||||
MapGridComponent? grid,
|
||||
IEntityManager entMan)
|
||||
{
|
||||
var _nodeContainer = entMan.System<NodeContainerSystem>();
|
||||
|
||||
if (!nodeQuery.TryGetComponent(CableEntity, out var nodeContainer))
|
||||
yield break;
|
||||
|
||||
if (nodeContainer.TryGetNode(NodeName, out Node? node))
|
||||
if (_nodeContainer.TryGetNode(nodeContainer, NodeName, out Node? node))
|
||||
yield return node;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
[Dependency] private readonly TagSystem _tag = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
|
||||
|
||||
private const string StatusEffectKey = "Electrocution";
|
||||
private const string DamageType = "Shock";
|
||||
@@ -265,7 +266,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
Node? TryNode(string? id)
|
||||
{
|
||||
if (id != null &&
|
||||
nodeContainer.TryGetNode<Node>(id, out var tryNode) &&
|
||||
_nodeContainer.TryGetNode<Node>(nodeContainer, id, out var tryNode) &&
|
||||
tryNode.NodeGroup is IBasePowerNet { NetworkNode: { LastCombinedSupply: > 0 } })
|
||||
{
|
||||
return tryNode;
|
||||
@@ -320,7 +321,12 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
return true;
|
||||
|
||||
var electrocutionEntity = Spawn($"VirtualElectrocutionLoad{node.NodeGroupID}", sourceTransform.Coordinates);
|
||||
var electrocutionNode = Comp<NodeContainerComponent>(electrocutionEntity).GetNode<ElectrocutionNode>("electrocution");
|
||||
|
||||
var nodeContainer = Comp<NodeContainerComponent>(electrocutionEntity);
|
||||
|
||||
if (!_nodeContainer.TryGetNode<ElectrocutionNode>(nodeContainer, "electrocution", out var electrocutionNode))
|
||||
return false;
|
||||
|
||||
var electrocutionComponent = Comp<ElectrocutionComponent>(electrocutionEntity);
|
||||
|
||||
// This shows up in the power monitor.
|
||||
|
||||
Reference in New Issue
Block a user