* Add door electronics configuration menu * Use file-scoped namespaces Signed-off-by: c4llv07e <kseandi@gmail.com> * Open door electronics configuration menu only with network configurator Signed-off-by: c4llv07e <kseandi@gmail.com> * Doors will now try to move their AccessReaderComponent to their door electronics when the map is initialized Signed-off-by: c4llv07e <kseandi@gmail.com> * Make the access list in the id card computer a separate control Signed-off-by: c4llv07e <kseandi@gmail.com> * Fix merge conflict Signed-off-by: c4llv07e <kseandi@gmail.com> * Remove DoorElectronics tag Signed-off-by: c4llv07e <kseandi@gmail.com> * Integrate doors with #17927 Signed-off-by: c4llv07e <kseandi@gmail.com> * Move door electornics ui stuff to the right place Signed-off-by: c4llv07e <kseandi@gmail.com> * Some review fixes Signed-off-by: c4llv07e <kseandi@gmail.com> * More fixes Signed-off-by: c4llv07e <kseandi@gmail.com> * review fix Signed-off-by: c4llv07e <kseandi@gmail.com> * move all accesses from airlock prototypes to door electronics Signed-off-by: c4llv07e <kseandi@gmail.com> * rework door electronics config access list Signed-off-by: c4llv07e <kseandi@gmail.com> * Remove Linq from the door electronics user interface * [WIP] Add EntityWhitelist to the activatable ui component Signed-off-by: c4llv07e <kseandi@gmail.com> * Better interaction system Signed-off-by: c4llv07e <kseandi@gmail.com> * Refactor Signed-off-by: c4llv07e <kseandi@gmail.com> * Fix some door electronics not working without AccessReaderComponent Signed-off-by: c4llv07e <kseandi@gmail.com> * Move AccessReaderComponent update code to the AccessReaderSystem Signed-off-by: c4llv07e <kseandi@gmail.com> * Remove unnecesary newlines in the door access prototypes Signed-off-by: c4llv07e <kseandi@gmail.com> * Remove unused variables in access level control Signed-off-by: c4llv07e <kseandi@gmail.com> * Remove unnecessary method from the door electronics configuration menu Signed-off-by: c4llv07e <kseandi@gmail.com> * [WIP] change access type from string to ProtoId<AccessLevelPrototype> Signed-off-by: c4llv07e <kseandi@gmail.com> * Remove unused methods Signed-off-by: c4llv07e <kseandi@gmail.com> * Newline fix Signed-off-by: c4llv07e <kseandi@gmail.com> * Restored to a functional state Signed-off-by: c4llv07e <kseandi@gmail.com> * Fix access configurator not working with door electronics AccessReaderComponent Signed-off-by: c4llv07e <kseandi@gmail.com> * Replace all string access fields with ProtoId Signed-off-by: c4llv07e <kseandi@gmail.com> * move access level control initialization into Populate method Signed-off-by: c4llv07e <kseandi@gmail.com> * Review --------- Signed-off-by: c4llv07e <kseandi@gmail.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
145 lines
5.8 KiB
C#
145 lines
5.8 KiB
C#
using Content.Shared.Access;
|
|
using Content.Shared.Players.PlayTimeTracking;
|
|
using Content.Shared.Roles;
|
|
using Content.Shared.StatusIcon;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
|
|
|
namespace Content.Shared.Roles
|
|
{
|
|
/// <summary>
|
|
/// Describes information for a single job on the station.
|
|
/// </summary>
|
|
[Prototype("job")]
|
|
public sealed partial class JobPrototype : IPrototype
|
|
{
|
|
[ViewVariables]
|
|
[IdDataField]
|
|
public string ID { get; private set; } = default!;
|
|
|
|
[DataField("playTimeTracker", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<PlayTimeTrackerPrototype>))]
|
|
public string PlayTimeTracker { get; private set; } = string.Empty;
|
|
|
|
[DataField("supervisors")]
|
|
public string Supervisors { get; private set; } = "nobody";
|
|
|
|
/// <summary>
|
|
/// The name of this job as displayed to players.
|
|
/// </summary>
|
|
[DataField("name")]
|
|
public string Name { get; private set; } = string.Empty;
|
|
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
|
public string LocalizedName => Loc.GetString(Name);
|
|
|
|
/// <summary>
|
|
/// The name of this job as displayed to players.
|
|
/// </summary>
|
|
[DataField("description")]
|
|
public string? Description { get; private set; }
|
|
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
|
public string? LocalizedDescription => Description is null ? null : Loc.GetString(Description);
|
|
|
|
[DataField("requirements")]
|
|
public HashSet<JobRequirement>? Requirements;
|
|
|
|
[DataField("joinNotifyCrew")]
|
|
public bool JoinNotifyCrew { get; private set; } = false;
|
|
|
|
[DataField("requireAdminNotify")]
|
|
public bool RequireAdminNotify { get; private set; } = false;
|
|
|
|
[DataField("setPreference")]
|
|
public bool SetPreference { get; private set; } = true;
|
|
|
|
/// <summary>
|
|
/// Whether this job should show in the ID Card Console.
|
|
/// If set to null, it will default to SetPreference's value.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool? OverrideConsoleVisibility { get; private set; } = null;
|
|
|
|
[DataField("canBeAntag")]
|
|
public bool CanBeAntag { get; private set; } = true;
|
|
|
|
/// <summary>
|
|
/// Whether this job is a head.
|
|
/// The job system will try to pick heads before other jobs on the same priority level.
|
|
/// </summary>
|
|
[DataField("weight")]
|
|
public int Weight { get; private set; }
|
|
|
|
/// <summary>
|
|
/// How to sort this job relative to other jobs in the UI.
|
|
/// Jobs with a higher value with sort before jobs with a lower value.
|
|
/// If not set, <see cref="Weight"/> is used as a fallback.
|
|
/// </summary>
|
|
[DataField]
|
|
public int? DisplayWeight { get; private set; }
|
|
|
|
public int RealDisplayWeight => DisplayWeight ?? Weight;
|
|
|
|
/// <summary>
|
|
/// A numerical score for how much easier this job is for antagonists.
|
|
/// For traitors, reduces starting TC by this amount. Other gamemodes can use it for whatever they find fitting.
|
|
/// </summary>
|
|
[DataField("antagAdvantage")]
|
|
public int AntagAdvantage = 0;
|
|
|
|
[DataField("startingGear", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
|
|
public string? StartingGear { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Use this to spawn in as a non-humanoid (borg, test subject, etc.)
|
|
/// Starting gear will be ignored.
|
|
/// If you want to just add special attributes to a humanoid, use AddComponentSpecial instead.
|
|
/// </summary>
|
|
[DataField("jobEntity", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
public string? JobEntity = null;
|
|
|
|
[DataField("icon", customTypeSerializer: typeof(PrototypeIdSerializer<StatusIconPrototype>))]
|
|
public string Icon { get; private set; } = "JobIconUnknown";
|
|
|
|
[DataField("special", serverOnly: true)]
|
|
public JobSpecial[] Special { get; private set; } = Array.Empty<JobSpecial>();
|
|
|
|
[DataField("access")]
|
|
public IReadOnlyCollection<ProtoId<AccessLevelPrototype>> Access { get; private set; } = Array.Empty<ProtoId<AccessLevelPrototype>>();
|
|
|
|
[DataField("accessGroups")]
|
|
public IReadOnlyCollection<ProtoId<AccessGroupPrototype>> AccessGroups { get; private set; } = Array.Empty<ProtoId<AccessGroupPrototype>>();
|
|
|
|
[DataField("extendedAccess")]
|
|
public IReadOnlyCollection<ProtoId<AccessLevelPrototype>> ExtendedAccess { get; private set; } = Array.Empty<ProtoId<AccessLevelPrototype>>();
|
|
|
|
[DataField("extendedAccessGroups")]
|
|
public IReadOnlyCollection<ProtoId<AccessGroupPrototype>> ExtendedAccessGroups { get; private set; } = Array.Empty<ProtoId<AccessGroupPrototype>>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sorts <see cref="JobPrototype"/>s appropriately for display in the UI,
|
|
/// respecting their <see cref="JobPrototype.Weight"/>.
|
|
/// </summary>
|
|
public sealed class JobUIComparer : IComparer<JobPrototype>
|
|
{
|
|
public static readonly JobUIComparer Instance = new();
|
|
|
|
public int Compare(JobPrototype? x, JobPrototype? y)
|
|
{
|
|
if (ReferenceEquals(x, y))
|
|
return 0;
|
|
if (ReferenceEquals(null, y))
|
|
return 1;
|
|
if (ReferenceEquals(null, x))
|
|
return -1;
|
|
|
|
var cmp = -x.RealDisplayWeight.CompareTo(y.RealDisplayWeight);
|
|
if (cmp != 0)
|
|
return cmp;
|
|
return string.Compare(x.ID, y.ID, StringComparison.Ordinal);
|
|
}
|
|
}
|
|
}
|