diff --git a/Content.Server/StationEvents/Events/StationEvent.cs b/Content.Server/StationEvents/Events/StationEvent.cs index bb93459883..e2960ccffc 100644 --- a/Content.Server/StationEvents/Events/StationEvent.cs +++ b/Content.Server/StationEvents/Events/StationEvent.cs @@ -1,6 +1,7 @@ using Content.Server.Administration.Logs; using Content.Server.Atmos.EntitySystems; using Content.Server.Chat.Managers; +using Content.Server.GameTicking; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Database; @@ -25,6 +26,11 @@ namespace Content.Server.StationEvents.Events /// public bool Running { get; set; } + /// + /// The time when this event last ran. + /// + public TimeSpan LastRun { get; set; } = TimeSpan.Zero; + /// /// Human-readable name for the event. /// @@ -62,6 +68,11 @@ namespace Content.Server.StationEvents.Events /// public virtual int EarliestStart { get; } = 5; + /// + /// In minutes, the amount of time before the same event can occur again + /// + public virtual int ReoccurrenceDelay { get; } = 30; + /// /// When in the lifetime to call Start(). /// @@ -112,6 +123,7 @@ namespace Content.Server.StationEvents.Events { Started = true; Occurrences += 1; + LastRun = EntitySystem.Get().RoundDuration(); EntitySystem.Get() .Add(LogType.EventStarted, LogImpact.High, $"Event startup: {Name}"); diff --git a/Content.Server/StationEvents/StationEventSystem.cs b/Content.Server/StationEvents/StationEventSystem.cs index 1e8f4f3c4d..6a230ed248 100644 --- a/Content.Server/StationEvents/StationEventSystem.cs +++ b/Content.Server/StationEvents/StationEventSystem.cs @@ -352,6 +352,12 @@ namespace Content.Server.StationEvents return false; } + if (stationEvent.LastRun != TimeSpan.Zero && currentTime.TotalMinutes < + stationEvent.ReoccurrenceDelay + stationEvent.LastRun.TotalMinutes) + { + return false; + } + return true; } @@ -372,6 +378,7 @@ namespace Content.Server.StationEvents foreach (var stationEvent in _stationEvents) { stationEvent.Occurrences = 0; + stationEvent.LastRun = TimeSpan.Zero; } _timeUntilNextEvent = MinimumTimeUntilFirstEvent;