1
0

ConfirmableActionComponent.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Robust.Shared.GameStates;
  2. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  3. namespace Content.Shared.Actions;
  4. /// <summary>
  5. /// An action that must be confirmed before using it.
  6. /// Using it for the first time primes it, after a delay you can then confirm it.
  7. /// Used for dangerous actions that cannot be undone (unlike screaming).
  8. /// </summary>
  9. [RegisterComponent, NetworkedComponent, Access(typeof(ConfirmableActionSystem))]
  10. [AutoGenerateComponentState, AutoGenerateComponentPause]
  11. public sealed partial class ConfirmableActionComponent : Component
  12. {
  13. /// <summary>
  14. /// Warning popup shown when priming the action.
  15. /// </summary>
  16. [DataField(required: true)]
  17. public LocId Popup = string.Empty;
  18. /// <summary>
  19. /// If not null, this is when the action can be confirmed at.
  20. /// This is the time of priming plus the delay.
  21. /// </summary>
  22. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  23. [AutoNetworkedField, AutoPausedField]
  24. public TimeSpan? NextConfirm;
  25. /// <summary>
  26. /// If not null, this is when the action will unprime at.
  27. /// This is <c>NextConfirm> plus <c>PrimeTime</c>
  28. /// </summary>
  29. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  30. [AutoNetworkedField, AutoPausedField]
  31. public TimeSpan? NextUnprime;
  32. /// <summary>
  33. /// Forced delay between priming and confirming to prevent accidents.
  34. /// </summary>
  35. [DataField]
  36. public TimeSpan ConfirmDelay = TimeSpan.FromSeconds(1);
  37. /// <summary>
  38. /// Once you prime the action it will unprime after this length of time.
  39. /// </summary>
  40. [DataField]
  41. public TimeSpan PrimeTime = TimeSpan.FromSeconds(5);
  42. }