Little NodeContainer ECS (#17702)

This commit is contained in:
faint
2023-06-28 14:28:38 +03:00
committed by GitHub
parent c25f3f08ed
commit 2f85b5ea3c
27 changed files with 143 additions and 88 deletions

View File

@@ -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.