2024-06-04 11:53:24 +00:00
|
|
|
using Content.Shared.Destructible.Thresholds;
|
2024-06-03 12:39:25 +00:00
|
|
|
using Robust.Shared.Prototypes;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
2023-08-30 10:56:20 +03:00
|
|
|
|
2024-06-04 11:53:24 +00:00
|
|
|
namespace Content.Shared.GameTicking.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>
|
2024-06-03 12:39:25 +00:00
|
|
|
[RegisterComponent, EntityCategory("GameRules")]
|
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;
|
2024-04-24 21:31:45 -04:00
|
|
|
|
2024-06-16 15:37:43 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// If true, this rule not having enough players will cancel the preset selection.
|
|
|
|
|
/// If false, it will simply not run silently.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField]
|
|
|
|
|
public bool CancelPresetOnTooFewPlayers = true;
|
|
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// A delay for when the rule the is started and when the starting logic actually runs.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField]
|
|
|
|
|
public MinMax? Delay;
|
2024-07-08 17:39:04 +03:00
|
|
|
|
|
|
|
|
[DataField]
|
|
|
|
|
public bool CP14Allowed = false;
|
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);
|