This commit is contained in:
BIGZi0348
2024-12-25 11:44:25 +03:00
parent 57a7d97688
commit dc570dcdb5
4 changed files with 40 additions and 23 deletions

View File

@@ -2,15 +2,19 @@ using Content.Server.GameTicking;
using Content.Server.Popups;
using Content.Server.Station.Systems;
using Content.Server._White.ERTRecruitment;
using Content.Server._White.JoinQueue;
using Content.Shared.Access.Systems;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Content.Shared._White.AuthPanel;
using Content.Shared._White.GhostRecruitment;
using Content.Shared.Ghost;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Player;
namespace Content.Server._White.AuthPanel;
@@ -26,17 +30,16 @@ public sealed class AuthPanelSystem : EntitySystem
[Dependency] private readonly ERTRecruitmentRule _ert = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly GameTicker _ticker = default!;
public Dictionary<AuthPanelAction, HashSet<EntityUid>> Counter = new();
public Dictionary<AuthPanelAction, HashSet<int>> CardIndexes = new();
public string Reason = "";
public static int MaxCount = 2;
public static int RandomAcceptRate = 8;
public static int MaxCount = 1;
public static int DelayNextAction = 10;
public static int EarliestStart = 45;
private TimeSpan? _delay;
public override void Initialize()
{
SubscribeLocalEvent<AuthPanelComponent, AuthPanelButtonPressedMessage>(OnButtonPressed);
@@ -52,6 +55,11 @@ public sealed class AuthPanelSystem : EntitySystem
}
private void OnRestart(RoundRestartCleanupEvent ev)
{
ClearPanel();
}
private void ClearPanel()
{
Counter.Clear();
CardIndexes.Clear();
@@ -63,7 +71,26 @@ public sealed class AuthPanelSystem : EntitySystem
{
if (args.Action is AuthPanelAction.ERTRecruit)
{
if (_random.Next(10) < RandomAcceptRate)
var query = EntityQueryEnumerator<GhostComponent, ActorComponent>();
var ghostList = new List<EntityUid>();
while (query.MoveNext(out var ghost, out _, out _))
{
ghostList.Add(ghost);
}
// if (_ticker.RoundDuration() < TimeSpan.FromMinutes(EarliestStart))
// {
// var station = _station.GetStationInMap(Transform(uid).MapID);
// if (station != null)
// _ert.DeclineERT(station.Value);
// _adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough time passed");
// return;
// }
var playerCount = _playerManager.PlayerCount;
//if (playerCount - ghostList.Count > playerCount / 2 && ghostList.Count > 3)
if (true)
{
_gameTicker.AddGameRule(ERTRecruitmentRuleComponent.EventName);
}
@@ -73,7 +100,7 @@ public sealed class AuthPanelSystem : EntitySystem
if (station != null)
_ert.DeclineERT(station.Value);
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - due to random");
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough ghosts");
}
foreach (var entities in Counter.Values)
@@ -85,6 +112,8 @@ public sealed class AuthPanelSystem : EntitySystem
}
}
}
Timer.Spawn(TimeSpan.FromSeconds(DelayNextAction), () => ClearPanel());
}
private void OnButtonPressed(EntityUid uid, AuthPanelComponent component, AuthPanelButtonPressedMessage args)

View File

@@ -29,7 +29,6 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
[Dependency] private readonly MapLoaderSystem _map = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
@@ -90,14 +89,6 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
return;
}
if (_ticker.RoundDuration() < TimeSpan.FromMinutes(component.EarliestStart))
{
_logger.Debug("Not enough time passed!");
DeclineERT(component.TargetStation.Value);
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough time passed");
return;
}
_chatSystem.DispatchStationAnnouncement(component.TargetStation.Value, Loc.GetString("ert-wait-message"), colorOverride: Color.Gold);
/*
@@ -123,7 +114,7 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
{
if (component.TargetStation != null)
DeclineERT(component.TargetStation.Value);
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Event disabled");
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"{"ERT Declined - Event disabled"}");
_recruitment.Cleanup(ERTRecruitmentRuleComponent.EventName);
return;
}

View File

@@ -11,9 +11,7 @@ public sealed partial class ERTRecruitmentRuleComponent : Component
[ViewVariables]
public MapId? MapId = null;
[DataField("minPlayer")] public int MinPlayer = 4;
[DataField("earliestStart")] public int EarliestStart = 45;
[DataField("minPlayer")] public int MinPlayer = 1;
public static SoundSpecifier ERTYes = new SoundPathSpecifier("/Audio/Announcements/ert_yes.ogg");
public static SoundSpecifier ERTNo = new SoundPathSpecifier("/Audio/Announcements/ert_no.ogg");

View File

@@ -7,5 +7,4 @@
weight: 0
duration: 30
- type: ERTRecruitmentRule
minPlayer: 4
earliestStart: 30
minPlayer: 3