1
0

IWireAction.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Content.Shared.Wires;
  2. namespace Content.Server.Wires;
  3. /// <summary>
  4. /// An interface used by WiresSystem to allow compositional wiresets.
  5. /// This is expected to be flyweighted, do not store per-entity state
  6. /// within an object/class that implements IWireAction.
  7. /// </summary>
  8. public interface IWireAction
  9. {
  10. /// <summary>
  11. /// This is to link the wire's status with
  12. /// its corresponding UI key. If this is null,
  13. /// GetStatusLightData MUST also return null,
  14. /// otherwise nothing happens.
  15. /// </summary>
  16. public object? StatusKey { get; }
  17. /// <summary>
  18. /// Called when the wire in the layout
  19. /// is created for the first time. Ensures
  20. /// that the referenced action has all
  21. /// the correct system references (plus
  22. /// other information if needed,
  23. /// but wire actions should NOT be stateful!)
  24. /// </summary>
  25. public void Initialize();
  26. /// <summary>
  27. /// Called when a wire is finally processed
  28. /// by WiresSystem upon wire layout
  29. /// creation. Use this to set specific details
  30. /// about the state of the entity in question.
  31. ///
  32. /// If this returns false, this will convert
  33. /// the given wire into a 'dummy' wire instead.
  34. /// </summary>
  35. /// <param name="wire">The wire in the entity's WiresComponent.</param>
  36. /// <param name="count">The current count of this instance of the wire type.</param>
  37. public bool AddWire(Wire wire, int count);
  38. /// <summary>
  39. /// What happens when this wire is cut. If this returns false, the wire will not actually get cut.
  40. /// </summary>
  41. /// <param name="user">The user attempting to interact with the wire.</param>
  42. /// <param name="wire">The wire being interacted with.</param>
  43. /// <returns>true if successful, false otherwise.</returns>
  44. public bool Cut(EntityUid user, Wire wire);
  45. /// <summary>
  46. /// What happens when this wire is mended. If this returns false, the wire will not actually get cut.
  47. /// </summary>
  48. /// <param name="user">The user attempting to interact with the wire.</param>
  49. /// <param name="wire">The wire being interacted with.</param>
  50. /// <returns>true if successful, false otherwise.</returns>
  51. public bool Mend(EntityUid user, Wire wire);
  52. /// <summary>
  53. /// This method gets called when the wire is pulsed..
  54. /// </summary>
  55. /// <param name="user">The user attempting to interact with the wire.</param>
  56. /// <param name="wire">The wire being interacted with.</param>
  57. public void Pulse(EntityUid user, Wire wire);
  58. /// <summary>
  59. /// Used when a wire's state on an entity needs to be updated.
  60. /// Mostly for things related to entity events, e.g., power.
  61. /// </summary>
  62. public void Update(Wire wire);
  63. /// <summary>
  64. /// Used for when WiresSystem requires the status light data
  65. /// for display on the client.
  66. /// </summary>
  67. /// <returns>StatusLightData to display light data, null to have no status light.</returns>
  68. public StatusLightData? GetStatusLightData(Wire wire);
  69. }