Skip to content

Commit

Permalink
Add NextEvent to Ramping and Meteors
Browse files Browse the repository at this point in the history
  • Loading branch information
ewokswagger committed Nov 12, 2024
1 parent 1495cb1 commit 84903f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Content.Server/StationEvents/EventManagerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public bool TryBuildLimitedEvents(EntityTableSelector limitedEventsTable, out Di
limitedEvents = new Dictionary<EntityPrototype, StationEventComponent>();

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!");
Expand Down
22 changes: 22 additions & 0 deletions Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs
Original file line number Diff line number Diff line change
@@ -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<RampingStationEventSchedulerComponent>
{
[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

/// <summary>
/// Returns the ChaosModifier which increases as round time increases to a point.
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/GameRules/meteorswarms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
parent: BaseGameRule
id: MeteorSwarmScheduler
components:
- type: NextEvent # DeltaV: Queue Event
- type: GameRule
- type: BasicStationEventScheduler
minimumTimeUntilFirstEvent: 600 # 10 min
Expand All @@ -68,6 +69,7 @@
parent: BaseGameRule
id: MeteorSwarmMildScheduler
components:
- type: NextEvent # DeltaV: Queue Event
- type: GameRule
- type: BasicStationEventScheduler
minimumTimeUntilFirstEvent: 600 # 10 min
Expand All @@ -82,6 +84,7 @@
parent: BaseGameRule
id: KesslerSyndromeScheduler
components:
- type: NextEvent # DeltaV: Queue Event
- type: GameRule
- type: RampingStationEventScheduler
scheduledGameRules: !type:NestedSelector
Expand All @@ -94,6 +97,7 @@
id: GameRuleMeteorSwarm
abstract: true
components:
- type: NextEvent # DeltaV: Queue Event
- type: GameRule
- type: StationEvent
reoccurrenceDelay: 1
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/GameRules/roundstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
id: RampingStationEventScheduler
parent: BaseGameRule
components:
- type: NextEvent # DeltaV: Queue Event
- type: RampingStationEventScheduler
averageChaos: 4.5 # DeltaV
averageEndTime: 180 # DeltaV
Expand Down

0 comments on commit 84903f6

Please sign in to comment.