Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Content.Server/StationEvents/Events/StationEvent.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,6 +26,11 @@ public abstract class StationEvent
/// </summary>
public bool Running { get; set; }

/// <summary>
/// The time when this event last ran.
/// </summary>
public TimeSpan LastRun { get; set; } = TimeSpan.Zero;

/// <summary>
/// Human-readable name for the event.
/// </summary>
Expand Down Expand Up @@ -62,6 +68,11 @@ public abstract class StationEvent
/// </summary>
public virtual int EarliestStart { get; } = 5;

/// <summary>
/// In minutes, the amount of time before the same event can occur again
/// </summary>
public virtual int ReoccurrenceDelay { get; } = 30;

/// <summary>
/// When in the lifetime to call Start().
/// </summary>
Expand Down Expand Up @@ -112,6 +123,7 @@ public virtual void Startup()
{
Started = true;
Occurrences += 1;
LastRun = IoCManager.Resolve<GameTicker>().RoundDuration();

EntitySystem.Get<AdminLogSystem>()
.Add(LogType.EventStarted, LogImpact.High, $"Event startup: {Name}");
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/StationEvents/StationEventSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ private bool CanRun(StationEvent stationEvent, int playerCount, TimeSpan current
return false;
}

if (stationEvent.LastRun != TimeSpan.Zero && currentTime.TotalMinutes <
stationEvent.ReoccurrenceDelay + stationEvent.LastRun.TotalMinutes)
{
return false;
}

return true;
}

Expand Down