Files
tbd-station-14/Content.Server/GameTicking/Rules/Components/GameRuleComponent.cs
DrSmugleaf 2f4b2cc887 Add active and ended game rule components, generic TryRoundStartAttempt and minPlayers field (#20564)
* Improve active game rule querying, add generic try round start attempt method, move minPlayers to GameRuleComponent

* Nukeops todo and cleanup

* Remove Active field

* Add EndedGameRuleComponent
2023-09-28 10:48:59 -04:00

45 lines
1.3 KiB
C#

using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.GameTicking.Rules.Components;
/// <summary>
/// Component attached to all gamerule entities.
/// Used to both track the entity as well as store basic data
/// </summary>
[RegisterComponent]
public sealed partial class GameRuleComponent : Component
{
/// <summary>
/// Game time when game rule was activated
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan ActivatedAt;
/// <summary>
/// The minimum amount of players needed for this game rule.
/// </summary>
[DataField]
public int MinPlayers;
}
/// <summary>
/// Raised when a rule is added but hasn't formally begun yet.
/// Good for announcing station events and other such things.
/// </summary>
[ByRefEvent]
public readonly record struct GameRuleAddedEvent(EntityUid RuleEntity, string RuleId);
/// <summary>
/// Raised when the rule actually begins.
/// Player-facing logic should begin here.
/// </summary>
[ByRefEvent]
public readonly record struct GameRuleStartedEvent(EntityUid RuleEntity, string RuleId);
/// <summary>
/// Raised when the rule ends.
/// Do cleanup and other such things here.
/// </summary>
[ByRefEvent]
public readonly record struct GameRuleEndedEvent(EntityUid RuleEntity, string RuleId);