Skip to content

Commit

Permalink
spelling ops
Browse files Browse the repository at this point in the history
  • Loading branch information
ewokswagger committed Dec 9, 2024
1 parent 6584cfc commit 1d35c10
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Content.Server.Station.Systems;
using Content.Shared.Access;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;

namespace Content.Server.DeltaV.Station.Components;

Expand Down
46 changes: 30 additions & 16 deletions Content.Server/DeltaV/Station/Systems/CaptainStateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@
using Content.Server.GameTicking;
using Content.Server.Station.Components;
using Content.Shared.Access.Components;
using Content.Shared.Access;
using Content.Shared.Access.Systems;
using Content.Shared.Access;
using Content.Shared.DeltaV.CCVars;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using System.Linq;
using Robust.Shared.Configuration;
using Content.Shared.DeltaV.CCVars;
using static Content.Shared.Administration.Notes.AdminMessageEuiState;

namespace Content.Server.DeltaV.Station.Systems;

public sealed class CaptainStateSystem : EntitySystem
{
[Dependency] private readonly AccessReaderSystem _reader = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

private bool _aaEnabled;
private TimeSpan _aaDelay;
private bool _aaEnabled;
private TimeSpan _acoDelay;
private bool _acoOnDeparture;

public override void Initialize()
{
SubscribeLocalEvent<CaptainStateComponent, PlayerJobAddedEvent>(OnPlayerJobAdded);
SubscribeLocalEvent<CaptainStateComponent, PlayerJobsRemovedEvent>(OnPlayerJobsRemoved);
Subs.CVar(_cfg, DCCVars.AutoUnlockAllAccessEnabled, a => _aaEnabled = a, true);
Subs.CVar(_cfg, DCCVars.AutoUnlockAllAccessDelay, a => _aaDelay = a, true);
Subs.CVar(_cfg, DCCVars.AutoUnlockAllAccessEnabled, a => _aaEnabled = a, true);
Subs.CVar(_cfg, DCCVars.RequestAcoDelay, a => _acoDelay = a, true);
Subs.CVar(_cfg, DCCVars.RequestAcoOnCaptainDeparture, a => _acoOnDeparture = a, true);
base.Initialize();
Expand Down Expand Up @@ -66,14 +64,18 @@ private void OnPlayerJobsRemoved(Entity<CaptainStateComponent> ent, ref PlayerJo
{
if (!TryComp<StationJobsComponent>(ent, out var stationJobs))
return;
if (args.PlayerJobs == null || !args.PlayerJobs.Contains("Captain")) // If the player that left was a captain we need to check if there are any captains left
if (!args.PlayerJobs.Contains("Captain")) // If the player that left was a captain we need to check if there are any captains left
return;
if (stationJobs.PlayerJobs.Any(playerJobs => playerJobs.Value.Contains("Captain"))) // We check the PlayerJobs if there are any cpatins left
return;
ent.Comp.HasCaptain = false;
if (_acoOnDeparture)
{
_chat.DispatchStationAnnouncement(ent, Loc.GetString(ent.Comp.ACORequestNoAAMessage, ("minutes", _aaDelay.TotalMinutes)), colorOverride: Color.Gold);
_chat.DispatchStationAnnouncement(
ent,
Loc.GetString(ent.Comp.ACORequestNoAAMessage, ("minutes", _aaDelay.TotalMinutes)),
colorOverride: Color.Gold);

ent.Comp.IsACORequestActive = true;
}
}
Expand All @@ -88,7 +90,11 @@ private void HandleHasCaptain(Entity<CaptainStateComponent?> station, CaptainSta
// If ACO vote has been called we need to cancel and alert to return to normal chain of command
if (!captainState.IsACORequestActive)
return;
_chat.DispatchStationAnnouncement(station, Loc.GetString(captainState.RevokeACOMessage), colorOverride: Color.Gold);

_chat.DispatchStationAnnouncement(station,
Loc.GetString(captainState.RevokeACOMessage),
colorOverride: Color.Gold);

captainState.IsACORequestActive = false;
}

Expand All @@ -101,8 +107,16 @@ private void HandleNoCaptain(Entity<CaptainStateComponent?> station, CaptainStat
{
if (CheckACORequest(captainState, currentTime))
{
var message = CheckUnlockAA(captainState, null) ? captainState.ACORequestWithAAMessage : captainState.ACORequestNoAAMessage;
_chat.DispatchStationAnnouncement(station, Loc.GetString(message, ("minutes", _aaDelay.TotalMinutes)), colorOverride: Color.Gold);
var message =
CheckUnlockAA(captainState, null)
? captainState.ACORequestWithAAMessage
: captainState.ACORequestNoAAMessage;

_chat.DispatchStationAnnouncement(
station,
Loc.GetString(message, ("minutes", _aaDelay.TotalMinutes)),
colorOverride: Color.Gold);

captainState.IsACORequestActive = true;
}
if (CheckUnlockAA(captainState, currentTime))
Expand All @@ -112,15 +126,15 @@ private void HandleNoCaptain(Entity<CaptainStateComponent?> station, CaptainStat

// Extend access of spare id lockers to command so they can access emergency AA
var query = EntityQueryEnumerator<SpareIDSafeComponent>();
while (query.MoveNext(out var spareIDSafe, out var _))
while (query.MoveNext(out var spareIDSafe, out _))
{
if (!TryComp<AccessReaderComponent>(spareIDSafe, out var accessReader))
continue;
var acceses = accessReader.AccessLists;
if (acceses.Count <= 0) // Avoid restricting access for readers with no accesses
var accesses = accessReader.AccessLists;
if (accesses.Count <= 0) // Avoid restricting access for readers with no accesses
continue;
// Awful and disgusting but the accessReader has no proper api for adding acceses to readers without awful type casting. See AccessOverriderSystem
acceses.Add(new HashSet<ProtoId<AccessLevelPrototype>> { captainState.ACOAccess });
accesses.Add(new HashSet<ProtoId<AccessLevelPrototype>> { captainState.ACOAccess });
Dirty(spareIDSafe, accessReader);
RaiseLocalEvent(spareIDSafe, new AccessReaderConfigurationChangedEvent());
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/ConfigPresets/DeltaV/apoapsis.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[game]
hostname = "[EN][MRP] Delta-v (Ψ) | Apoapsis [US East 1]"
soft_max_players = 80
auto_unlock_aa_enabled = false # Disabled for peri until if/when command whitelist
auto_unlock_aa_enabled = false # Disabled for apo until if/when command whitelist

[shuttle]
emergency_early_launch_allowed = true
Expand Down

0 comments on commit 1d35c10

Please sign in to comment.