1
0

GameRuleComponent.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Content.Shared.Destructible.Thresholds;
  2. using Robust.Shared.Prototypes;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  4. namespace Content.Shared.GameTicking.Components;
  5. /// <summary>
  6. /// Component attached to all gamerule entities.
  7. /// Used to both track the entity as well as store basic data
  8. /// </summary>
  9. [RegisterComponent, EntityCategory("GameRules")]
  10. public sealed partial class GameRuleComponent : Component
  11. {
  12. /// <summary>
  13. /// Game time when game rule was activated
  14. /// </summary>
  15. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  16. public TimeSpan ActivatedAt;
  17. /// <summary>
  18. /// The minimum amount of players needed for this game rule.
  19. /// </summary>
  20. [DataField]
  21. public int MinPlayers;
  22. /// <summary>
  23. /// If true, this rule not having enough players will cancel the preset selection.
  24. /// If false, it will simply not run silently.
  25. /// </summary>
  26. [DataField]
  27. public bool CancelPresetOnTooFewPlayers = true;
  28. /// <summary>
  29. /// A delay for when the rule the is started and when the starting logic actually runs.
  30. /// </summary>
  31. [DataField]
  32. public MinMax? Delay;
  33. }
  34. /// <summary>
  35. /// Raised when a rule is added but hasn't formally begun yet.
  36. /// Good for announcing station events and other such things.
  37. /// </summary>
  38. [ByRefEvent]
  39. public readonly record struct GameRuleAddedEvent(EntityUid RuleEntity, string RuleId);
  40. /// <summary>
  41. /// Raised when the rule actually begins.
  42. /// Player-facing logic should begin here.
  43. /// </summary>
  44. [ByRefEvent]
  45. public readonly record struct GameRuleStartedEvent(EntityUid RuleEntity, string RuleId);
  46. /// <summary>
  47. /// Raised when the rule ends.
  48. /// Do cleanup and other such things here.
  49. /// </summary>
  50. [ByRefEvent]
  51. public readonly record struct GameRuleEndedEvent(EntityUid RuleEntity, string RuleId);