using System.Linq; using Content.Server.Station.Systems; using Content.Shared.Roles; using JetBrains.Annotations; using Robust.Shared.Network; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; namespace Content.Server.Station.Components; /// /// Stores information about a station's job selection. /// [RegisterComponent, Access(typeof(StationJobsSystem)), PublicAPI] public sealed partial class StationJobsComponent : Component { /// /// Total *mid-round* jobs at station start. /// This is inferred automatically from . /// [ViewVariables] public int MidRoundTotalJobs; /// /// Current total jobs. /// [DataField] public int TotalJobs; /// /// Station is running on extended access. /// [DataField] public bool ExtendedAccess; /// /// If there are less than or equal this amount of players in the game at round start, /// people get extended access levels from job prototypes. /// /// /// Set to -1 to disable extended access. /// [DataField] public int ExtendedAccessThreshold { get; set; } = 15; /// /// The percentage of jobs remaining. /// /// /// Null if MidRoundTotalJobs is zero. This is a NaN free API. /// [ViewVariables] public float? PercentJobsRemaining => MidRoundTotalJobs > 0 ? TotalJobs / (float) MidRoundTotalJobs : null; /// /// The current list of jobs of available jobs. Null implies that is no limit. /// /// /// This should not be mutated or used directly unless you really know what you're doing, go through StationJobsSystem. /// [DataField] public Dictionary, int?> JobList = new(); /// /// Overflow jobs that round-start can spawn infinitely many of. /// This is inferred automatically from . /// [ViewVariables] public IReadOnlySet> OverflowJobs = default!; /// /// A dictionary relating a NetUserId to the jobs they have on station. /// An OOC way to track where job slots have gone. /// [DataField] public Dictionary>> PlayerJobs = new(); /// /// Mapping of jobs to an int[2] array that specifies jobs available at round start, and midround. /// Negative values implies that there is no limit. /// [DataField("availableJobs", required: true)] public Dictionary, int[]> SetupAvailableJobs = default!; }