Migrate machine linking and resave all maps (#18243)
This commit is contained in:
@@ -19,6 +19,7 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<DeviceLinkSourceComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<DeviceLinkSourceComponent, ComponentStartup>(OnSourceStartup);
|
||||
SubscribeLocalEvent<DeviceLinkSinkComponent, ComponentStartup>(OnSinkStartup);
|
||||
SubscribeLocalEvent<DeviceLinkSourceComponent, ComponentRemove>(OnSourceRemoved);
|
||||
@@ -27,6 +28,19 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
|
||||
}
|
||||
|
||||
#region Link Validation
|
||||
|
||||
private void OnInit(EntityUid uid, DeviceLinkSourceComponent component, ComponentInit args)
|
||||
{
|
||||
// Populate the output dictionary.
|
||||
foreach (var (sinkUid, links) in component.LinkedPorts)
|
||||
{
|
||||
foreach (var link in links)
|
||||
{
|
||||
component.Outputs.GetOrNew(link.source).Add(sinkUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes invalid links where the saved sink doesn't exist/have a sink component for example
|
||||
/// </summary>
|
||||
@@ -84,7 +98,7 @@ public abstract class SharedDeviceLinkSystem : EntitySystem
|
||||
List<(string, string)> invalidLinks = new();
|
||||
foreach (var link in linkedPorts)
|
||||
{
|
||||
if (!sinkComponent.Ports.Contains(link.sink) || !(sourceComponent.Outputs.GetValueOrDefault(link.source)?.Contains(sinkUid) ?? false))
|
||||
if (!sinkComponent.Ports.Contains(link.sink))
|
||||
invalidLinks.Add(link);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user