1
0

CableComponent.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Content.Server.Power.EntitySystems;
  2. using Content.Shared.Power;
  3. using Content.Shared.Tools;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  6. using System.Diagnostics.Tracing;
  7. using Content.Shared.Tools.Systems;
  8. namespace Content.Server.Power.Components;
  9. /// <summary>
  10. /// Allows the attached entity to be destroyed by a cutting tool, dropping a piece of cable.
  11. /// </summary>
  12. [RegisterComponent]
  13. [Access(typeof(CableSystem))]
  14. public sealed partial class CableComponent : Component
  15. {
  16. [DataField]
  17. public EntProtoId CableDroppedOnCutPrototype = "CableHVStack1";
  18. /// <summary>
  19. /// The tool quality needed to cut the cable. Setting to null prevents cutting.
  20. /// </summary>
  21. [DataField]
  22. public ProtoId<ToolQualityPrototype>? CuttingQuality = SharedToolSystem.CutQuality;
  23. /// <summary>
  24. /// Checked by <see cref="CablePlacerComponent"/> to determine if there is
  25. /// already a cable of a type on a tile.
  26. /// </summary>
  27. [DataField("cableType")]
  28. public CableType CableType = CableType.HighVoltage;
  29. [DataField("cuttingDelay")]
  30. public float CuttingDelay = 1f;
  31. }
  32. /// <summary>
  33. /// Event to be raised when a cable is anchored / unanchored
  34. /// </summary>
  35. [ByRefEvent]
  36. public readonly struct CableAnchorStateChangedEvent
  37. {
  38. public readonly TransformComponent Transform;
  39. public EntityUid Entity => Transform.Owner;
  40. public bool Anchored => Transform.Anchored;
  41. /// <summary>
  42. /// If true, the entity is being detached to null-space
  43. /// </summary>
  44. public readonly bool Detaching;
  45. public CableAnchorStateChangedEvent(TransformComponent transform, bool detaching = false)
  46. {
  47. Detaching = detaching;
  48. Transform = transform;
  49. }
  50. }