diff --git a/Content.Server/StationEvents/EventManagerSystem.cs b/Content.Server/StationEvents/EventManagerSystem.cs index 8ace51e3886..513530ee139 100644 --- a/Content.Server/StationEvents/EventManagerSystem.cs +++ b/Content.Server/StationEvents/EventManagerSystem.cs @@ -113,7 +113,7 @@ public bool TryBuildLimitedEvents(EntityTableSelector limitedEventsTable, out Di limitedEvents = new Dictionary(); var availableEvents = AvailableEvents(eventRunTime); // handles the player counts and individual event restrictions - // DeltaV - Overide time for stashing events + // DeltaV - Overide time for stashing events if (availableEvents.Count == 0) { Log.Warning("No events were available to run!"); diff --git a/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs b/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs index a5dbe102ca1..27213874e79 100644 --- a/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs +++ b/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs @@ -1,16 +1,20 @@ using Content.Server.GameTicking; using Content.Server.GameTicking.Rules; using Content.Server.StationEvents.Components; +using Content.Shared.DeltaV.StationEvents; using Content.Shared.GameTicking.Components; using Robust.Shared.Random; +using Robust.Shared.Timing; namespace Content.Server.StationEvents; public sealed class RampingStationEventSchedulerSystem : GameRuleSystem { + [Dependency] private readonly IGameTiming _timing = default!; // DeltaV [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly EventManagerSystem _event = default!; [Dependency] private readonly GameTicker _gameTicker = default!; + [Dependency] private readonly NextEventSystem _next = default!; // DeltaV /// /// Returns the ChaosModifier which increases as round time increases to a point. @@ -57,6 +61,24 @@ public override void Update(float frameTime) continue; } + // DeltaV events using NextEventComponent + NextEventComponent? nextEventComponent = null; + + if (Resolve(uid, ref nextEventComponent, false)) // If there is a nextEventComponent use the stashed event instead of running it directly. + { + PickNextEventTime(uid, scheduler); + TimeSpan nextEventTime = _timing.CurTime + TimeSpan.FromSeconds(scheduler.TimeUntilNextEvent); + if (!_event.TryGenerateRandomEvent(scheduler.ScheduledGameRules, out string? generatedEvent, nextEventTime) || generatedEvent == null) + continue; + // Cycle the stashed event with the new generated event and time. + string storedEvent = _next.UpdateNextEvent(nextEventComponent, generatedEvent, nextEventTime); + if (storedEvent == null || storedEvent == string.Empty) //If there was no stored event don't try to run it. + continue; + GameTicker.AddGameRule(storedEvent); + continue; + } + // DeltaV end events using NextEventComponent + PickNextEventTime(uid, scheduler); _event.RunRandomEvent(scheduler.ScheduledGameRules); } diff --git a/Resources/Prototypes/GameRules/meteorswarms.yml b/Resources/Prototypes/GameRules/meteorswarms.yml index 95f9985b6a2..61ae4312890 100644 --- a/Resources/Prototypes/GameRules/meteorswarms.yml +++ b/Resources/Prototypes/GameRules/meteorswarms.yml @@ -55,6 +55,7 @@ parent: BaseGameRule id: MeteorSwarmScheduler components: + - type: NextEvent # DeltaV: Queue Event - type: GameRule - type: BasicStationEventScheduler minimumTimeUntilFirstEvent: 600 # 10 min @@ -68,6 +69,7 @@ parent: BaseGameRule id: MeteorSwarmMildScheduler components: + - type: NextEvent # DeltaV: Queue Event - type: GameRule - type: BasicStationEventScheduler minimumTimeUntilFirstEvent: 600 # 10 min @@ -82,6 +84,7 @@ parent: BaseGameRule id: KesslerSyndromeScheduler components: + - type: NextEvent # DeltaV: Queue Event - type: GameRule - type: RampingStationEventScheduler scheduledGameRules: !type:NestedSelector @@ -94,6 +97,7 @@ id: GameRuleMeteorSwarm abstract: true components: + - type: NextEvent # DeltaV: Queue Event - type: GameRule - type: StationEvent reoccurrenceDelay: 1 diff --git a/Resources/Prototypes/GameRules/roundstart.yml b/Resources/Prototypes/GameRules/roundstart.yml index 688b399d113..56d1b6e2257 100644 --- a/Resources/Prototypes/GameRules/roundstart.yml +++ b/Resources/Prototypes/GameRules/roundstart.yml @@ -309,6 +309,7 @@ id: RampingStationEventScheduler parent: BaseGameRule components: + - type: NextEvent # DeltaV: Queue Event - type: RampingStationEventScheduler averageChaos: 4.5 # DeltaV averageEndTime: 180 # DeltaV