Extended access system (#8469)

* Extended access system

Allows jobs to specify "extended" access levels, which will be granted if the round-start crew count is below a certain threshold.

* Extended accesses for jobs

* Spook
This commit is contained in:
Pieter-Jan Briers
2022-05-27 06:01:07 +02:00
committed by GitHub
parent c5982e0b10
commit a4685bab4c
15 changed files with 182 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Spawners.Components;
using Content.Server.Speech.Components;
using Content.Server.Station.Components;
using Content.Shared.Database;
using Content.Shared.GameTicking;
using Content.Shared.Ghost;
@@ -59,6 +60,15 @@ namespace Content.Server.GameTicking
_stationJobs.AssignOverflowJobs(ref assignedJobs, playerNetIds, profiles, _stationSystem.Stations.ToList());
// Calculate extended access for stations.
var stationJobCounts = _stationSystem.Stations.ToDictionary(e => e, _ => 0);
foreach (var (_, (_, station)) in assignedJobs)
{
stationJobCounts[station] += 1;
}
_stationJobs.CalcExtendedAccess(stationJobCounts);
// Spawn everybody in!
foreach (var (player, (job, station)) in assignedJobs)
{
@@ -173,6 +183,14 @@ namespace Content.Server.GameTicking
else
_adminLogSystem.Add(LogType.RoundStartJoin, LogImpact.Medium, $"Player {player.Name} joined as {character.Name:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {job.Name:jobName}.");
// Make sure they're aware of extended access.
if (Comp<StationJobsComponent>(station).ExtendedAccess
&& (jobPrototype.ExtendedAccess.Count > 0
|| jobPrototype.ExtendedAccessGroups.Count > 0))
{
_chatManager.DispatchServerMessage(player, Loc.GetString("job-greet-crew-shortages"));
}
// We raise this event directed to the mob, but also broadcast it so game rules can do something now.
var aev = new PlayerSpawnCompleteEvent(mob, player, jobId, lateJoin, station, character);
RaiseLocalEvent(mob, aev);