Round event frequency simulation command (#27718)

This commit is contained in:
Kara
2024-05-06 00:33:30 -07:00
committed by GitHub
parent b8d03b814b
commit c1aae2398b
2 changed files with 68 additions and 8 deletions

View File

@@ -61,7 +61,7 @@ public sealed class EventManagerSystem : EntitySystem
/// Pick a random event from the available events at this time, also considering their weightings.
/// </summary>
/// <returns></returns>
private string? FindEvent(Dictionary<EntityPrototype, StationEventComponent> availableEvents)
public string? FindEvent(Dictionary<EntityPrototype, StationEventComponent> availableEvents)
{
if (availableEvents.Count == 0)
{
@@ -95,16 +95,20 @@ public sealed class EventManagerSystem : EntitySystem
/// <summary>
/// Gets the events that have met their player count, time-until start, etc.
/// </summary>
/// <param name="ignoreEarliestStart"></param>
/// <param name="playerCountOverride">Override for player count, if using this to simulate events rather than in an actual round.</param>
/// <param name="currentTimeOverride">Override for round time, if using this to simulate events rather than in an actual round.</param>
/// <returns></returns>
private Dictionary<EntityPrototype, StationEventComponent> AvailableEvents(bool ignoreEarliestStart = false)
public Dictionary<EntityPrototype, StationEventComponent> AvailableEvents(
bool ignoreEarliestStart = false,
int? playerCountOverride = null,
TimeSpan? currentTimeOverride = null)
{
var playerCount = _playerManager.PlayerCount;
var playerCount = playerCountOverride ?? _playerManager.PlayerCount;
// playerCount does a lock so we'll just keep the variable here
var currentTime = !ignoreEarliestStart
var currentTime = currentTimeOverride ?? (!ignoreEarliestStart
? GameTicker.RoundDuration()
: TimeSpan.Zero;
: TimeSpan.Zero);
var result = new Dictionary<EntityPrototype, StationEventComponent>();
@@ -112,7 +116,6 @@ public sealed class EventManagerSystem : EntitySystem
{
if (CanRun(proto, stationEvent, playerCount, currentTime))
{
Log.Debug($"Adding event {proto.ID} to possibilities");
result.Add(proto, stationEvent);
}
}