Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Require Sheriff for Bluespace Vaults events (new-frontiers-14#2305)
Browse files Browse the repository at this point in the history
* Code

* Fixups

* Update StationEventComponent.cs

* Update nf_events_bluespace.yml

* Minor required job cleanup

* Remove unused bits from EventManagerSystem

---------

Co-authored-by: Whatstone <[email protected]>
  • Loading branch information
dvir001 and whatston3 authored Oct 23, 2024
1 parent 7f840af commit da7c71d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
12 changes: 10 additions & 2 deletions Content.Server/StationEvents/Components/StationEventComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Content.Shared.Roles; // Frontier
using Robust.Shared.Audio;
using Robust.Shared.Prototypes; // Frontier
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;

namespace Content.Server.StationEvents.Components;
Expand Down Expand Up @@ -70,8 +72,8 @@ public sealed partial class StationEventComponent : Component
public int MinimumPlayers;

/// <summary>
/// Frontier - How many players need to be present on station for the event to not run, to avoid running safe events with high-pop
/// </remarks>
/// Frontier: How many players need to be present on station for the event to not run, to avoid running safe events with high-pop
/// </summary>
[DataField]
public int MaximumPlayers = 999;

Expand All @@ -93,4 +95,10 @@ public sealed partial class StationEventComponent : Component
/// </summary>
[DataField]
public bool OccursDuringRoundEnd = true;

/// <summary>
/// Frontier: Require active job to run the event.
/// </summary>
[DataField]
public Dictionary<ProtoId<JobPrototype>, int> RequiredJobs = new();
}
18 changes: 17 additions & 1 deletion Content.Server/StationEvents/EventManagerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Robust.Shared.Random;
using Content.Shared.EntityTable.EntitySelectors;
using Content.Shared.EntityTable;
using Content.Server.Station.Systems; // Frontier
using Content.Server.Station.Components; // Frontier

namespace Content.Server.StationEvents;

Expand All @@ -21,6 +23,7 @@ public sealed class EventManagerSystem : EntitySystem
[Dependency] private readonly EntityTableSystem _entityTable = default!;
[Dependency] public readonly GameTicker GameTicker = default!;
[Dependency] private readonly RoundEndSystem _roundEnd = default!;
[Dependency] private readonly StationJobsSystem _stationJobs = default!; // Frontier

public bool EventsEnabled { get; private set; }
private void SetEnabled(bool value) => EventsEnabled = value;
Expand Down Expand Up @@ -267,11 +270,24 @@ private bool CanRun(EntityPrototype prototype, StationEventComponent stationEven
return false;
}

// Frontier: max players
// Frontier: Check max players
if (playerCount > stationEvent.MaximumPlayers)
{
return false;
}

// Frontier: require jobs to run event - TODO: actually count jobs, compare vs. numJobs
foreach (var (jobProtoId, numJobs) in stationEvent.RequiredJobs)
{
var jobPrototype = _prototype.Index(jobProtoId);
var query = EntityQueryEnumerator<StationJobsComponent>();
while (query.MoveNext(out var station, out var comp))
{
// If a job slot is open, nobody has the job, or the player with the job should be leaving.
if (_stationJobs.TryGetJobSlot(station, jobPrototype, out var slots, comp) && slots >= 1)
return false;
}
}
// End Frontier

if (_roundEnd.IsRoundEndRequested() && !stationEvent.OccursDuringRoundEnd)
Expand Down
6 changes: 6 additions & 0 deletions Resources/Prototypes/_NF/Events/nf_events_bluespace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
duration: 1350
maxDuration: 1560
reoccurrenceDelay: 480 # 8 hours
requiredJobs:
Sheriff: 1
- type: BluespaceErrorRule
gridPaths:
- /Maps/_NF/Bluespace/cache.yml
Expand All @@ -33,6 +35,8 @@
duration: 1020
maxDuration: 1350
reoccurrenceDelay: 480 # 8 hours
requiredJobs:
Sheriff: 1
- type: BluespaceErrorRule
gridPaths:
- /Maps/_NF/Bluespace/vault.yml
Expand All @@ -54,6 +58,8 @@
duration: 590
maxDuration: 780
reoccurrenceDelay: 480 # 8 hours
requiredJobs:
Sheriff: 1
- type: BluespaceErrorRule
gridPaths:
- /Maps/_NF/Bluespace/vaultsmall.yml
Expand Down

0 comments on commit da7c71d

Please sign in to comment.