DeviceLinkSourceComponent.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Robust.Shared.GameStates;
  2. using Robust.Shared.Prototypes;
  3. namespace Content.Shared.DeviceLinking;
  4. [RegisterComponent]
  5. [NetworkedComponent] // for interactions. Actual state isn't currently synced.
  6. [Access(typeof(SharedDeviceLinkSystem))]
  7. public sealed partial class DeviceLinkSourceComponent : Component
  8. {
  9. /// <summary>
  10. /// The ports the device link source sends signals from
  11. /// </summary>
  12. [DataField]
  13. public HashSet<ProtoId<SourcePortPrototype>> Ports = new();
  14. /// <summary>
  15. /// Dictionary mapping each port to a set of linked sink entities.
  16. /// </summary>
  17. [ViewVariables] // This is not serialized as it can be constructed from LinkedPorts
  18. public Dictionary<ProtoId<SourcePortPrototype>, HashSet<EntityUid>> Outputs = new();
  19. /// <summary>
  20. /// If set to High or Low, the last signal state for a given port.
  21. /// Used when linking ports of devices that are currently outputting a signal.
  22. /// Only set by <c>DeviceLinkSystem.SendSignal</c>.
  23. /// </summary>
  24. [DataField]
  25. public Dictionary<ProtoId<SourcePortPrototype>, bool> LastSignals = new();
  26. /// <summary>
  27. /// The list of source to sink ports for each linked sink entity for easier managing of links
  28. /// </summary>
  29. [DataField]
  30. public Dictionary<EntityUid, HashSet<(ProtoId<SourcePortPrototype> Source, ProtoId<SinkPortPrototype> Sink)>> LinkedPorts = new();
  31. /// <summary>
  32. /// Limits the range devices can be linked across.
  33. /// </summary>
  34. [DataField]
  35. public float Range = 30f;
  36. }