Skip to content

Commit

Permalink
fix auto aco timing (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewokswagger authored Dec 12, 2024
1 parent 45ab87a commit 3b9fa30
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Content.Server/DeltaV/Station/Systems/CaptainStateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace Content.Server.DeltaV.Station.Systems;

Expand All @@ -28,27 +29,20 @@ public override void Initialize()
{
SubscribeLocalEvent<CaptainStateComponent, PlayerJobAddedEvent>(OnPlayerJobAdded);
SubscribeLocalEvent<CaptainStateComponent, PlayerJobsRemovedEvent>(OnPlayerJobsRemoved);
SubscribeLocalEvent<CaptainStateComponent, ComponentInit>(OnInit);
Subs.CVar(_cfg, DCCVars.AutoUnlockAllAccessEnabled, a => _aaEnabled = a, true);
Subs.CVar(_cfg, DCCVars.RequestAcoOnCaptainDeparture, a => _acoOnDeparture = a, true);
Subs.CVar(_cfg, DCCVars.AutoUnlockAllAccessDelay, a => _aaDelay = TimeSpan.FromMinutes(a), true);
Subs.CVar(_cfg, DCCVars.RequestAcoDelay, a => _acoDelay = TimeSpan.FromMinutes(a), true);
base.Initialize();
}

private void OnInit(Entity<CaptainStateComponent> ent, ref ComponentInit args)
{
// There is some weird persistince issues this will hopefully fix
ent.Comp.IsACORequestActive = false;
ent.Comp.IsAAInPlay = false;
ent.Comp.HasCaptain = false;
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var currentTime = _ticker.RoundDuration(); // Caching to reduce redundant calls
if (currentTime < _acoDelay) // Avoid timing issues. No need to run before _acoDelay is reached anyways.
return;
var query = EntityQueryEnumerator<CaptainStateComponent>();
while (query.MoveNext(out var station, out var captainState))
{
Expand Down

0 comments on commit 3b9fa30

Please sign in to comment.