2023-08-30 10:56:20 +03:00
|
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameTicking.Rules.Components;
|
2023-04-25 20:23:14 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Component attached to all gamerule entities.
|
|
|
|
|
|
/// Used to both track the entity as well as store basic data
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[RegisterComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
|
public sealed partial class GameRuleComponent : Component
|
2023-04-25 20:23:14 -04:00
|
|
|
|
{
|
2023-08-30 10:56:20 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Game time when game rule was activated
|
|
|
|
|
|
/// </summary>
|
2023-09-28 07:48:59 -07:00
|
|
|
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
2023-08-30 10:56:20 +03:00
|
|
|
|
public TimeSpan ActivatedAt;
|
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
|
/// <summary>
|
2023-09-28 07:48:59 -07:00
|
|
|
|
/// The minimum amount of players needed for this game rule.
|
2023-04-25 20:23:14 -04:00
|
|
|
|
/// </summary>
|
2023-09-28 07:48:59 -07:00
|
|
|
|
[DataField]
|
|
|
|
|
|
public int MinPlayers;
|
2023-04-25 20:23:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <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);
|