Rejig device link sink & source startup & shutdown (#29035)

* Fix DeviceLinkSinkComponent not updating sources on shutdown

* Log error

* Misc link changes & fixes

* Fix core
This commit is contained in:
Leon Friedrich
2024-06-20 03:03:32 +12:00
committed by GitHub
parent 8a4ce13d1c
commit 20544b0c76
4 changed files with 63 additions and 112 deletions

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Shared.DeviceLinking;
@@ -11,13 +12,14 @@ public sealed partial class DeviceLinkSinkComponent : Component
/// <summary>
/// The ports this sink has
/// </summary>
[DataField("ports", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<SinkPortPrototype>))]
public HashSet<string>? Ports;
[DataField]
public HashSet<ProtoId<SinkPortPrototype>> Ports = new();
/// <summary>
/// Used for removing a sink from all linked sources when it gets removed
/// Used for removing a sink from all linked sources when this component gets removed.
/// This is not serialized to yaml as it can be inferred from source components.
/// </summary>
[DataField("links")]
[ViewVariables]
public HashSet<EntityUid> LinkedSources = new();
/// <summary>
@@ -25,14 +27,13 @@ public sealed partial class DeviceLinkSinkComponent : Component
/// The counter is counted down by one every tick if it's higher than 0
/// This is for preventing infinite loops
/// </summary>
[DataField("invokeCounter")]
[DataField]
public int InvokeCounter;
/// <summary>
/// How high the invoke counter is allowed to get before the links to the sink are removed and the DeviceLinkOverloadedEvent gets raised
/// If the invoke limit is smaller than 1 the sink can't overload
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("invokeLimit")]
[DataField]
public int InvokeLimit = 10;
}