Skip to content

Commit 1ef3dbe

Browse files
committed
nukeblops
1 parent 2ff232e commit 1ef3dbe

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

Content.Server/GameTicking/Presets/GamePresetPrototype.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ public sealed partial class GamePresetPrototype : IPrototype
3333
[DataField("maxPlayers")]
3434
public int? MaxPlayers;
3535

36+
// Begin Imp
37+
/// <summary>
38+
/// Ensures that this gamemode does not get selected for a number of rounds
39+
/// by something like Secret. This is not considered when the preset is forced.
40+
/// </summary>
41+
[DataField("cooldown")]
42+
public int Cooldown = 0;
43+
// End Imp
44+
45+
46+
3647
[DataField("rules", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
3748
public IReadOnlyList<string> Rules { get; private set; } = Array.Empty<string>();
3849

Content.Server/GameTicking/Rules/SecretRuleSystem.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public sealed class SecretRuleSystem : GameRuleSystem<SecretRuleComponent>
2222
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
2323
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
2424
[Dependency] private readonly IComponentFactory _compFact = default!;
25+
[Dependency] private readonly GameTicker _ticker = default!; // begin Imp
26+
27+
// Dictionary that contains the minimum round number for certain preset
28+
// prototypes to be allowed to roll again
29+
private static Dictionary<ProtoId<GamePresetPrototype>, int> _nextRoundAllowed = new(); // end Imp
2530

2631
private string _ruleCompName = default!;
2732

@@ -46,6 +51,12 @@ protected override void Added(EntityUid uid, SecretRuleComponent component, Game
4651
Log.Info($"Selected {preset.ID} as the secret preset.");
4752
_adminLogger.Add(LogType.EventStarted, $"Selected {preset.ID} as the secret preset.");
4853

54+
if (preset.Cooldown > 0) // Begin Imp
55+
{
56+
_nextRoundAllowed[preset.ID] = _ticker.RoundId + preset.Cooldown + 1;
57+
Log.Info($"{preset.ID} is now on cooldown until {_nextRoundAllowed[preset.ID]}");
58+
} // End Imp
59+
4960
foreach (var rule in preset.Rules)
5061
{
5162
EntityUid ruleEnt;
@@ -166,6 +177,11 @@ private bool CanPick([NotNullWhen(true)] GamePresetPrototype? selected, int play
166177
if (ruleComp.MinPlayers > players && ruleComp.CancelPresetOnTooFewPlayers)
167178
return false;
168179
}
180+
if (_nextRoundAllowed.ContainsKey(selected.ID) && _nextRoundAllowed[selected.ID] > _ticker.RoundId) // Begin Imp
181+
{
182+
Log.Info($"Skipping preset {selected.ID} (Not available until round {_nextRoundAllowed[selected.ID]}");
183+
return false;
184+
} // End Imp
169185

170186
return true;
171187
}

Resources/Prototypes/game_presets.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
name: survival-title
66
showInVote: true # secret # DeltaV - Me when the survival. Used for periapsis.
77
description: survival-description
8+
cooldown: 2 # Imp - Can't occur thrice
89
rules:
910
- MeteorSwarmScheduler
1011
- RampingStationEventScheduler
@@ -96,7 +97,7 @@
9697
showInVote: true #4boring4vote # DeltaV - Enable greenshift in gamemode vote
9798
description: greenshift-description
9899
rules:
99-
- SpaceTrafficControlFriendlyEventScheduler
100+
- SpaceTrafficControlFriendlyEventScheduler
100101
- BasicRoundstartVariation
101102
- GlimmerEventScheduler # DeltaV
102103

@@ -133,7 +134,7 @@
133134
showInVote: false #Admin Use
134135
description: secret-description
135136
rules:
136-
- SpaceTrafficControlFriendlyEventScheduler
137+
- SpaceTrafficControlFriendlyEventScheduler
137138
- BasicRoundstartVariation
138139
- GlimmerEventScheduler # DeltaV
139140

@@ -185,6 +186,7 @@
185186
name: nukeops-title
186187
description: nukeops-description
187188
showInVote: false
189+
cooldown: 1 # Imp - Can't occur back to back
188190
rules:
189191
- Nukeops
190192
- SubGamemodesRule

0 commit comments

Comments
 (0)