Fixes issues with wire layouts, enables wire layout composition (#10246)
This commit is contained in:
@@ -71,22 +71,41 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
TryGetLayout(wires.LayoutId, out layout);
|
TryGetLayout(wires.LayoutId, out layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// does the prototype have a parent (and are the wires empty?) if so, we just create
|
List<IWireAction> wireActions = new();
|
||||||
// a new layout based on that
|
var dummyWires = 0;
|
||||||
//
|
|
||||||
// TODO: Merge wire layouts...
|
if (!_protoMan.TryIndex(wires.LayoutId, out WireLayoutPrototype? layoutPrototype))
|
||||||
foreach (var layoutPrototype in _protoMan.EnumerateParents<WireLayoutPrototype>(wires.LayoutId))
|
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dummyWires += layoutPrototype.DummyWires;
|
||||||
|
|
||||||
if (layoutPrototype.Wires != null)
|
if (layoutPrototype.Wires != null)
|
||||||
{
|
{
|
||||||
foreach (var wire in layoutPrototype.Wires)
|
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
|
||||||
|
foreach (var parentLayout in _protoMan.EnumerateParents<WireLayoutPrototype>(wires.LayoutId))
|
||||||
|
{
|
||||||
|
if (parentLayout.Wires != null)
|
||||||
|
{
|
||||||
|
wireActions.AddRange(parentLayout.Wires);
|
||||||
|
}
|
||||||
|
|
||||||
|
dummyWires += parentLayout.DummyWires;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wireActions.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var wire in wireActions)
|
||||||
{
|
{
|
||||||
wire.Initialize();
|
wire.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
wireSet = CreateWireSet(uid, layout, layoutPrototype.Wires, layoutPrototype.DummyWires);
|
wireSet = CreateWireSet(uid, layout, wireActions, dummyWires);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wireSet == null || wireSet.Count == 0)
|
if (wireSet == null || wireSet.Count == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user