Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheackraze committed Jan 8, 2024
1 parent a41e00a commit 3119ae2
Show file tree
Hide file tree
Showing 2 changed files with 2,216 additions and 2,188 deletions.
31 changes: 16 additions & 15 deletions Content.Server/_NF/PublicTransit/PublicTransitSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;

using Content.Server.GameTicking.Events;
using Content.Server._NF.PublicTransit.Components;
using Content.Server.GameTicking;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Shuttles.Systems;
Expand All @@ -22,6 +23,7 @@ public sealed class PublicTransitSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly MapLoaderSystem _loader = default!;
[Dependency] private readonly ShuttleSystem _shuttles = default!;
Expand All @@ -45,14 +47,13 @@ public override void Initialize()
SubscribeLocalEvent<TransitShuttleComponent, EntityUnpausedEvent>(OnShuttleUnpaused);
SubscribeLocalEvent<TransitShuttleComponent, FTLTagEvent>(OnShuttleTag);

SubscribeLocalEvent<RoundStartingEvent>(OnRoundStarting);

// Don't invoke immediately as it will get set in the natural course of things.
Enabled = _cfgManager.GetCVar(NF14CVars.PublicTransit);
FlyTime = _cfgManager.GetCVar(NF14CVars.PublicTransitFlyTime);
Counter = 0;
StationList.Clear();
_cfgManager.OnValueChanged(NF14CVars.PublicTransit, SetTransit);
_cfgManager.OnValueChanged(NF14CVars.PublicTransitFlyTime, SetFly);
}

private void OnShuttleTag(EntityUid uid, TransitShuttleComponent component, ref FTLTagEvent args)
Expand All @@ -73,9 +74,13 @@ public override void Shutdown()

private void OnStationStartup(EntityUid uid, StationTransitComponent component, ComponentStartup args)
{
StationList.Add(uid);
if (Enabled)
SetupPublicTransit();
if (Transform(uid).MapID == _ticker.DefaultMap)
{
if (!StationList.Contains(uid))
StationList.Add(uid);
if (Enabled)
SetupPublicTransit();
}
}

private void OnStationShutdown(EntityUid uid, StationTransitComponent component, ComponentShutdown args)
Expand Down Expand Up @@ -131,15 +136,6 @@ public override void Update(float frameTime)
}
}

private void OnRoundStarting(RoundStartingEvent ev)
{
// Setup arrivals station
if (!Enabled)
return;

SetupPublicTransit();
}

private void SetTransit(bool obj)
{
Enabled = obj;
Expand All @@ -159,6 +155,11 @@ private void SetTransit(bool obj)
}
}

private void SetFly(float obj)
{
FlyTime = obj;
}

private void SetupPublicTransit()
{
var query = EntityQueryEnumerator<TransitShuttleComponent>();
Expand Down
Loading

0 comments on commit 3119ae2

Please sign in to comment.