-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Port]Game presets can now have cooldowns to prevent back-to-back modes #2744
Open
Lyndomen
wants to merge
7
commits into
DeltaV-Station:master
Choose a base branch
from
Lyndomen:backtoback
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+44
−1
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1ef3dbe
nukeblops
Lyndomen 569aa0a
Update game_presets.yml
Lyndomen 810cc41
Update GamePresetPrototype.cs
Lyndomen 83efcc7
Update game_presets.yml
Lyndomen f3b9723
Update game_presets.yml
Lyndomen 0fa149e
Update game_presets.yml
Lyndomen 17de7f7
cvar making
Lyndomen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
using Content.Server.Chat.Managers; | ||
using Content.Server.GameTicking.Presets; | ||
using Content.Server.GameTicking.Rules.Components; | ||
using Content.Shared._DV.CCVars; | ||
using Content.Shared.GameTicking.Components; | ||
using Content.Shared.Random; | ||
using Content.Shared.CCVar; | ||
|
@@ -22,6 +23,11 @@ public sealed class SecretRuleSystem : GameRuleSystem<SecretRuleComponent> | |
[Dependency] private readonly IConfigurationManager _configurationManager = default!; | ||
[Dependency] private readonly IAdminLogManager _adminLogger = default!; | ||
[Dependency] private readonly IComponentFactory _compFact = default!; | ||
[Dependency] private readonly GameTicker _ticker = default!; // begin Imp | ||
|
||
// Dictionary that contains the minimum round number for certain preset | ||
// prototypes to be allowed to roll again | ||
private static Dictionary<ProtoId<GamePresetPrototype>, int> _nextRoundAllowed = new(); // end Imp | ||
|
||
private string _ruleCompName = default!; | ||
|
||
|
@@ -46,7 +52,16 @@ protected override void Added(EntityUid uid, SecretRuleComponent component, Game | |
Log.Info($"Selected {preset.ID} as the secret preset."); | ||
_adminLogger.Add(LogType.EventStarted, $"Selected {preset.ID} as the secret preset."); | ||
|
||
foreach (var rule in preset.Rules) | ||
if (_configurationManager.GetCVar(DCCVars.EnableBacktoBack) == true) // DeltaV | ||
{ | ||
if (preset.Cooldown > 0) // Begin Imp | ||
{ | ||
_nextRoundAllowed[preset.ID] = _ticker.RoundId + preset.Cooldown + 1; | ||
Log.Info($"{preset.ID} is now on cooldown until {_nextRoundAllowed[preset.ID]}"); | ||
} // End Imp | ||
} // DeltaV | ||
|
||
foreach (var rule in preset.Rules) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. untroll |
||
{ | ||
EntityUid ruleEnt; | ||
|
||
|
@@ -167,6 +182,15 @@ private bool CanPick([NotNullWhen(true)] GamePresetPrototype? selected, int play | |
return false; | ||
} | ||
|
||
if (_configurationManager.GetCVar(DCCVars.EnableBacktoBack) == true) // DeltaV | ||
{ | ||
if (_nextRoundAllowed.ContainsKey(selected.ID) && _nextRoundAllowed[selected.ID] > _ticker.RoundId) // Begin Imp | ||
{ | ||
Log.Info($"Skipping preset {selected.ID} (Not available until round {_nextRoundAllowed[selected.ID]}"); | ||
return false; | ||
} // End Imp | ||
} // DeltaV | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment