PopupBehavior.cs 946 B

123456789101112131415161718192021222324252627282930
  1. using Content.Shared.Popups;
  2. namespace Content.Server.Destructible.Thresholds.Behaviors;
  3. /// <summary>
  4. /// Shows a popup for everyone.
  5. /// </summary>
  6. [DataDefinition]
  7. public sealed partial class PopupBehavior : IThresholdBehavior
  8. {
  9. /// <summary>
  10. /// Locale id of the popup message.
  11. /// </summary>
  12. [DataField("popup", required: true)]
  13. public string Popup;
  14. /// <summary>
  15. /// Type of popup to show.
  16. /// </summary>
  17. [DataField("popupType")]
  18. public PopupType PopupType;
  19. public void Execute(EntityUid uid, DestructibleSystem system, EntityUid? cause = null)
  20. {
  21. var popup = system.EntityManager.System<SharedPopupSystem>();
  22. // popup is placed at coords since the entity could be deleted after, no more popup then
  23. var coords = system.EntityManager.GetComponent<TransformComponent>(uid).Coordinates;
  24. popup.PopupCoordinates(Loc.GetString(Popup), coords, PopupType);
  25. }
  26. }