From 98a9196dd48c758b7d058010e08e4b033ab5c4dd Mon Sep 17 00:00:00 2001 From: Flipp Syder <76629141+vulppine@users.noreply.github.com> Date: Tue, 2 Aug 2022 06:42:05 -0700 Subject: [PATCH] Fixes issues with wire layouts, enables wire layout composition (#10246) --- Content.Server/Wires/WiresSystem.cs | 41 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs index 3d452582fd..b277f76a2c 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -71,22 +71,41 @@ public sealed class WiresSystem : EntitySystem TryGetLayout(wires.LayoutId, out layout); } + List wireActions = new(); + var dummyWires = 0; + + if (!_protoMan.TryIndex(wires.LayoutId, out WireLayoutPrototype? layoutPrototype)) + { + return; + } + + dummyWires += layoutPrototype.DummyWires; + + if (layoutPrototype.Wires != null) + { + wireActions.AddRange(layoutPrototype.Wires); + } + // does the prototype have a parent (and are the wires empty?) if so, we just create // a new layout based on that - // - // TODO: Merge wire layouts... - foreach (var layoutPrototype in _protoMan.EnumerateParents(wires.LayoutId)) + foreach (var parentLayout in _protoMan.EnumerateParents(wires.LayoutId)) { - if (layoutPrototype.Wires != null) + if (parentLayout.Wires != null) { - foreach (var wire in layoutPrototype.Wires) - { - wire.Initialize(); - } - - wireSet = CreateWireSet(uid, layout, layoutPrototype.Wires, layoutPrototype.DummyWires); - break; + wireActions.AddRange(parentLayout.Wires); } + + dummyWires += parentLayout.DummyWires; + } + + if (wireActions.Count > 0) + { + foreach (var wire in wireActions) + { + wire.Initialize(); + } + + wireSet = CreateWireSet(uid, layout, wireActions, dummyWires); } if (wireSet == null || wireSet.Count == 0)