PayloadTriggerComponent.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Content.Shared.Explosion.Components;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Prototypes;
  4. namespace Content.Shared.Payload.Components;
  5. /// <summary>
  6. /// Component for providing the means of triggering an explosive payload. Used in grenade construction.
  7. /// </summary>
  8. /// <remarks>
  9. /// This component performs two functions. Firstly, it will add or remove other components to some entity when this
  10. /// item is installed inside of it. This is intended for use with constructible grenades. For example, this allows
  11. /// you to add things like <see cref="OnUseTimerTriggerComponent"/>, or <see cref="TriggerOnProximityComponent"/>.
  12. /// This is required because otherwise you would have to forward arbitrary interaction directed at the casing
  13. /// through to the trigger, which would be quite complicated. Also proximity triggers don't really work inside of
  14. /// containers.
  15. ///
  16. /// Secondly, if the entity that this component is attached to is ever triggered directly (e.g., via a device
  17. /// network message), the trigger will be forwarded to the device that this entity is installed in (if any).
  18. /// </remarks>
  19. [RegisterComponent, NetworkedComponent]
  20. public sealed partial class PayloadTriggerComponent : Component
  21. {
  22. /// <summary>
  23. /// If true, triggering this entity will also cause the parent of this entity to be triggered.
  24. /// </summary>
  25. public bool Active = false;
  26. /// <summary>
  27. /// List of components to add or remove from an entity when this trigger is (un)installed.
  28. /// </summary>
  29. [DataField("components", serverOnly:true, readOnly: true)]
  30. public ComponentRegistry? Components = null;
  31. /// <summary>
  32. /// Keeps track of what components this trigger has granted to the payload case.
  33. /// </summary>
  34. /// <remarks>
  35. /// This is required in case someone creates a construction graph that accepts more than one trigger, and those
  36. /// trigger grant the same type of component (or the case just innately has that component). This list is used
  37. /// when removing the component, to ensure that removal of this trigger only removes the components that it was
  38. /// responsible for adding.
  39. /// </remarks>
  40. [DataField("grantedComponents", serverOnly: true)]
  41. public HashSet<Type> GrantedComponents = new();
  42. }