forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from Lemirda/task14
todo task 14
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
Content.Server/Andromeda/GameTicker/GameTicker.SetGamePresetUTC.cs
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server.GameTicking | ||
{ | ||
public sealed partial class GameTicker | ||
{ | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
private TimeSpan _checkInterval = TimeSpan.FromMinutes(1); | ||
private TimeSpan _moscowTimeThreshold = new TimeSpan(10, 0, 0); // 10:00 МСК | ||
private int _playerThreshold = 25; | ||
private string _secretPresetId = "secret"; | ||
|
||
private void CheckAndChangeGamePreset() | ||
{ | ||
var utcNow = DateTime.UtcNow; | ||
TimeZoneInfo moscowTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Russian Standard Time"); | ||
DateTime moscowDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcNow, moscowTimeZone); | ||
|
||
if (_playerManager.PlayerCount >= _playerThreshold || moscowDateTime.TimeOfDay >= _moscowTimeThreshold) | ||
{ | ||
Log.Info($"В данный момент количетсво игроков больше или ровно 25, либо время больше 10:00 МСК"); | ||
if (TryFindGamePreset(_secretPresetId, out var preset)) | ||
{ | ||
Log.Info($"Выставляем {preset} в связи с тем что в данный момент количетсво игроков больше или ровно 25, либо время больше 10:00 МСК"); | ||
SetGamePreset(preset); | ||
} | ||
else | ||
{ | ||
Log.Error($"Почему то небыл найден режим {_secretPresetId}, невозможно выставить режим в связи с тем что в данный момент количетсво игроков больше или ровно 25, либо время больше 10:00 МСК"); | ||
} | ||
} | ||
else | ||
{ | ||
Log.Warning($"В данный момент количетсво игроков меньше 25, либо время меньше 10:00 МСК"); | ||
} | ||
} | ||
} | ||
} |
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