Random events no longer start while in lobby and round ending forces current event to end (#1782)

* Random events cannot run in lobby and round ending forces events to end.

* Thanks p4merge

* Get rid of unused

* Apply suggestions from code review

Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
nuke
2020-08-19 02:54:10 -04:00
committed by GitHub
parent 259762717b
commit b8fef91922
2 changed files with 20 additions and 8 deletions

View File

@@ -1,4 +1,8 @@
using Content.Server.StationEvents;
using System;
using System.Collections.Generic;
using System.Text;
using Content.Server.StationEvents;
using Content.Server.Interfaces.GameTicking;
using JetBrains.Annotations;
using Robust.Server.Console;
using Robust.Server.Interfaces.Player;
@@ -9,25 +13,23 @@ using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using System;
using System.Collections.Generic;
using System.Text;
using static Content.Shared.StationEvents.SharedStationEvent;
namespace Content.Server.GameObjects.EntitySystems.StationEvents
{
[UsedImplicitly]
// Somewhat based off of TG's implementation of events
public sealed class StationEventSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private readonly IServerNetManager _netManager;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IGameTicker _gameTicker;
#pragma warning restore 649
// Somewhat based off of TG's implementation of events
public StationEvent CurrentEvent { get; private set; }
public IReadOnlyCollection<StationEvent> StationEvents => _stationEvents;
private List<StationEvent> _stationEvents = new List<StationEvent>();
private const float MinimumTimeUntilFirstEvent = 600;
@@ -194,7 +196,18 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
{
return;
}
// Stop events from happening in lobby and force active event to end if the round ends
if (_gameTicker.RunLevel != GameTicking.GameRunLevel.InRound)
{
if (CurrentEvent != null)
{
Enabled = false;
}
return;
}
// Keep running the current event
if (CurrentEvent != null)
{

View File

@@ -1,5 +1,4 @@
#nullable enable
using Content.Server.GameObjects.EntitySystems;
using Content.Server.GameObjects.EntitySystems.StationEvents;
using JetBrains.Annotations;
using Robust.Server.Interfaces.Console;