From 57a7d97688bbc6775df0b939015d8883c7516756 Mon Sep 17 00:00:00 2001 From: BIGZi0348 Date: Mon, 23 Dec 2024 23:42:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=82=D0=B5=D1=80=D1=8F=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B7=D0=B3=D0=BE=D0=B2=D1=8B=D1=85=20=D0=BA=D0=BB=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=BA=20-=20=D0=B3=D0=B0=D1=80=D0=B0=D0=BD=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_White/AuthPanel/AuthPanelSystem.cs | 31 ++++++++++--------- .../ERTRecruitment/ERTRecruitmentRule.cs | 23 +++++++++++--- .../GhostRecruitmentSystem.cs | 3 +- .../Prototypes/_White/event_prototypes.yml | 2 +- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Content.Server/_White/AuthPanel/AuthPanelSystem.cs b/Content.Server/_White/AuthPanel/AuthPanelSystem.cs index adbe272363..73822ad222 100644 --- a/Content.Server/_White/AuthPanel/AuthPanelSystem.cs +++ b/Content.Server/_White/AuthPanel/AuthPanelSystem.cs @@ -33,13 +33,15 @@ public sealed class AuthPanelSystem : EntitySystem public static int MaxCount = 2; + public static int RandomAcceptRate = 8; + private TimeSpan? _delay; public override void Initialize() { - SubscribeLocalEvent(OnButtonPressed); - SubscribeLocalEvent(OnPerformAction); - SubscribeLocalEvent(OnReason); + SubscribeLocalEvent(OnButtonPressed); + SubscribeLocalEvent(OnPerformAction); + SubscribeLocalEvent(OnReason); SubscribeLocalEvent(OnRestart); } @@ -61,7 +63,7 @@ public sealed class AuthPanelSystem : EntitySystem { if (args.Action is AuthPanelAction.ERTRecruit) { - if (_random.Next(10) < 2) + if (_random.Next(10) < RandomAcceptRate) { _gameTicker.AddGameRule(ERTRecruitmentRuleComponent.EventName); } @@ -71,6 +73,7 @@ public sealed class AuthPanelSystem : EntitySystem if (station != null) _ert.DeclineERT(station.Value); + _adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - due to random"); } foreach (var entities in Counter.Values) @@ -91,7 +94,7 @@ public sealed class AuthPanelSystem : EntitySystem if (!access.Contains("Command")) { _popup.PopupEntity(Loc.GetString("auth-panel-no-access"), - args.Actor,args.Actor); + args.Actor, args.Actor); return; } @@ -112,22 +115,22 @@ public sealed class AuthPanelSystem : EntitySystem if (!Counter.TryGetValue(args.Button, out var hashSet)) { hashSet = new HashSet(); - Counter.Add(args.Button,hashSet); + Counter.Add(args.Button, hashSet); } - if(hashSet.Count == MaxCount) + if (hashSet.Count == MaxCount) return; if (!CardIndexes.TryGetValue(args.Button, out var cardSet)) { cardSet = new HashSet(); - CardIndexes.Add(args.Button,cardSet); + CardIndexes.Add(args.Button, cardSet); } if (cardSet.Contains(access.Count)) { _popup.PopupEntity(Loc.GetString("auth-panel-used-ID"), - args.Actor,args.Actor); + args.Actor, args.Actor); return; } @@ -148,19 +151,19 @@ public sealed class AuthPanelSystem : EntitySystem if (hashSet.Count == MaxCount) { var ev = new AuthPanelPerformActionEvent(args.Button); - RaiseLocalEvent(uid,ev); + RaiseLocalEvent(uid, ev); } } public void UpdateUserInterface(AuthPanelAction rawaction) { - if(!Counter.TryGetValue(rawaction,out var hashSet)) + if (!Counter.TryGetValue(rawaction, out var hashSet)) return; - var action = new AuthPanelConfirmationAction(rawaction, hashSet.Count, MaxCount,Reason); + var action = new AuthPanelConfirmationAction(rawaction, hashSet.Count, MaxCount, Reason); var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid,out _)) + while (query.MoveNext(out var uid, out _)) { if (!_ui.HasUi(uid, AuthPanelUiKey.Key)) return; @@ -168,7 +171,7 @@ public sealed class AuthPanelSystem : EntitySystem var state = new AuthPanelConfirmationActionState(action); _ui.SetUiState(uid, AuthPanelUiKey.Key, state); - _appearance.SetData(uid,AuthPanelVisualLayers.Confirm,true); + _appearance.SetData(uid, AuthPanelVisualLayers.Confirm, true); } } diff --git a/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs b/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs index 67aa919416..f493c36b1c 100644 --- a/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs +++ b/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs @@ -7,6 +7,8 @@ using Content.Server.GameTicking.Rules.Components; using Content.Server.StationEvents.Events; using Content.Server._White.GhostRecruitment; using Content.Server.GameTicking.Components; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; using Content.Shared._White; using Content.Shared._White.GhostRecruitment; using JetBrains.Annotations; @@ -29,6 +31,7 @@ public sealed class ERTRecruitmentRule : StationEventSystem(); - var check1 = component.IsBlocked; + var check1 = component.IsBlocked || ertsys.IsDisabled; var check2 = _recruitment.GetAllRecruited(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayer; - if (check1 || check2) + if (check1) { if (component.TargetStation != null) DeclineERT(component.TargetStation.Value); + _adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Event disabled"); + _recruitment.Cleanup(ERTRecruitmentRuleComponent.EventName); + return; + } + if (check2) + { + if (component.TargetStation != null) + DeclineERT(component.TargetStation.Value); + _adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough ghosts willing to play ERT"); _recruitment.Cleanup(ERTRecruitmentRuleComponent.EventName); return; } @@ -127,7 +141,6 @@ public sealed class ERTRecruitmentRule : StationEventSystem(); ertsys.IsDisabled = true; } diff --git a/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs b/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs index 2564b3c533..a7ed4e92a6 100644 --- a/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs +++ b/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs @@ -63,8 +63,7 @@ public sealed class GhostRecruitmentSystem : EntitySystem var count = 0; - //var maxCount = Math.Max(3, _playerManager.PlayerCount / 8); - var maxCount = 1; + var maxCount = Math.Max(3, _playerManager.PlayerCount / 8); var query = EntityQueryEnumerator(); while (query.MoveNext(out var uid, out var ghostRecruitedComponent)) diff --git a/Resources/Prototypes/_White/event_prototypes.yml b/Resources/Prototypes/_White/event_prototypes.yml index 1cdb0b0c01..7f403f51d8 100644 --- a/Resources/Prototypes/_White/event_prototypes.yml +++ b/Resources/Prototypes/_White/event_prototypes.yml @@ -5,7 +5,7 @@ components: - type: StationEvent weight: 0 - duration: 20 + duration: 30 - type: ERTRecruitmentRule minPlayer: 4 earliestStart: 30