Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server._Starlight.Roles.Ranks;
using Content.Server.Access.Systems;
using Content.Server.Forensics;
using Content.Shared.Access.Components;
Expand Down Expand Up @@ -41,6 +42,7 @@ public sealed partial class StationRecordsSystem : SharedStationRecordsSystem
[Dependency] private IPrototypeManager _prototypeManager = default!;
[Dependency] private IdCardSystem _idCard = default!;
[Dependency] private IRobustRandom _random = default!;
[Dependency] private RankSystem _rank = default!;

public override void Initialize()
{
Expand All @@ -55,6 +57,13 @@ private void OnPlayerSpawn(PlayerSpawnCompleteEvent args)
if (!TryComp<StationRecordsComponent>(args.Station, out var stationRecords))
return;

#region Starlight
// This is kind of janky, but basically to make ranks show up properly in the manifest, I have to run CreateGeneralRecord
// somewhere else, which creates a duplicate manifest entry. This prevents that.
if (_rank.TryGetHighestEligibleRank(args.Player.UserId, null, args.JobId, out _))
return;
#endregion

CreateGeneralRecord(args.Station, args.Mob, args.Profile, args.JobId, stationRecords);
}

Expand Down
121 changes: 121 additions & 0 deletions Content.Server/_Starlight/Roles/Ranks/RankSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using Content.Server._NullLink.PlayerData;
using Content.Server.Access.Systems;
using Content.Server.StationRecords.Systems;
using Content.Shared._NullLink;
using Content.Shared._Starlight.Roles.Ranks;
using Content.Shared.Forensics.Components;
using Content.Shared.GameTicking;
using Content.Shared.Roles;
using Content.Shared.StationRecords;
using Robust.Shared.Prototypes;

namespace Content.Server._Starlight.Roles.Ranks;

public sealed partial class RankSystem : EntitySystem
{
[Dependency] private readonly IdCardSystem _idCard = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly NullLinkPlayerManager _linkPlayerManager = default!;
[Dependency] private readonly StationRecordsSystem _record = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<PlayerSpawnCompleteEvent>(OnPlayerSpawn);
}

private void OnPlayerSpawn(PlayerSpawnCompleteEvent ev)
{
if (!_idCard.TryFindIdCard(ev.Mob, out var idCard))
return;

if (ev.JobId == null)
return;

if (!_prototype.TryIndex(ev.JobId, out JobPrototype? job))
return;

if (!TryGetHighestEligibleRank(ev.Player.UserId, job, null, out var highestRank))
return;

if (highestRank == null)
return;

if (!_prototype.TryIndex(highestRank.Icon, out var jobIcon))
return;

var jobName = Loc.GetString(highestRank.Name);

_idCard.TryChangeJobTitle(idCard, jobName, idCard.Comp, ev.Player.AttachedEntity);
_idCard.TryChangeJobIcon(idCard, jobIcon, idCard.Comp, ev.Player.AttachedEntity);

if (!TryComp<StationRecordsComponent>(ev.Station, out var stationRecords))
return;

TryComp<FingerprintComponent>(ev.Player.AttachedEntity, out var fingerprintComponent);
TryComp<DnaComponent>(ev.Player.AttachedEntity, out var dnaComponent);

_record.CreateGeneralRecord(
ev.Station,
idCard,
ev.Profile.Name,
ev.Profile.Age,
ev.Profile.CustomSpecieName,
ev.Profile.Gender,
ev.JobId,
fingerprintComponent?.Fingerprint,
dnaComponent?.DNA,
ev.Profile,
stationRecords);

if (!TryComp<StationRecordKeyStorageComponent>(idCard.Owner, out var keyStorage)
|| keyStorage.Key is not { } key
|| !_record.TryGetRecord<GeneralStationRecord>(key, out var record))
return;

record.JobTitle = jobName;
record.JobIcon = idCard.Comp.JobIcon;

_record.Synchronize(key);
}

public bool TryGetHighestEligibleRank(Guid userId, JobPrototype? job, string? jobId, out RankPrototype? highestRank)
{
highestRank = null;

if (!_linkPlayerManager.TryGetPlayerData(userId, out PlayerData? playerData))
return false;

if (jobId != null && _prototype.TryIndex(jobId, out JobPrototype? jobPrototype))
job = jobPrototype;

if (job == null)
return false;

if (job.Ranks == null)
return false;

foreach (var rankId in job.Ranks)
{
if (!_prototype.TryIndex(rankId, out RankPrototype? rank))
continue;

if (!_prototype.TryIndex(rank.Requirement, out RoleRequirementPrototype? roleRequirement))
continue;

if (!playerData.Roles.Overlaps(roleRequirement.Roles))
continue;

highestRank ??= rank;

if (highestRank.Priority < rank.Priority)
highestRank = rank;
}

if (highestRank != null)
return true;

return false;
}
}
6 changes: 5 additions & 1 deletion Content.Shared/Roles/JobPrototype.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
锘縰sing Content.Shared.Access;
锘縰sing Content.Shared._Starlight.Roles.Ranks;
using Content.Shared.Access;
using Content.Shared.Guidebook;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.StatusIcon;
Expand Down Expand Up @@ -166,6 +167,9 @@ public sealed partial class JobPrototype : IPrototype
/// </summary>
[DataField]
public List<ProtoId<GuideEntryPrototype>>? Guides;

[DataField]
public List<ProtoId<RankPrototype>>? Ranks; // Starlight
}

/// <summary>
Expand Down
35 changes: 35 additions & 0 deletions Content.Shared/_Starlight/Roles/Ranks/RankPrototype.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Content.Shared._NullLink;
using Content.Shared.StatusIcon;
using Robust.Shared.Prototypes;

namespace Content.Shared._Starlight.Roles.Ranks;

[Prototype]
public sealed partial class RankPrototype : IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;

[DataField(required: true)]
public string Name { get; private set; } = string.Empty;

[DataField(required: true)]
public ProtoId<RoleRequirementPrototype> Requirement { get; private set; } = default!;

[DataField]
public Priority Priority = Priority.VeryLow;

[DataField(required: true)]
public ProtoId<JobIconPrototype> Icon { get; private set; } = default!;
}

public enum Priority
{
Top,
VeryHigh,
High,
Medium,
Low,
VeryLow,
Bottom
}
10 changes: 10 additions & 0 deletions Resources/Locale/en-US/_NullLink/requirements.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,15 @@ roles-req-first-writing-roles = First Writing Contest Winner
roles-req-senior-developer = Senior Developer
roles-req-developer = Developer

roles-req-sec-prestige = Chief of Security
roles-req-med-prestige = Surgeon General
roles-req-cargo-prestige = Quartermaster General
roles-req-sci-prestige = Master Researcher
roles-req-engi-prestige = Master Engineer
roles-req-service-prestige = Chief Steward
roles-req-cap-prestige = Admiral
roles-req-ntr-prestige = Protocol Commissar
roles-req-law-prestige = Grand Magistrate

triesteport-main = TRIESTEPORT
overall = overall
27 changes: 27 additions & 0 deletions Resources/Locale/en-US/_Starlight/job/prestige-ranks.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
job-name-masterbartender = Master Bartender
job-name-masterbotanist = Master Botanist
job-name-brigmedicalspecialist = Brigmedical Specialist
job-name-admiral = Admiral
job-name-cargospecialist = Cargo Specialist
job-name-messofficer = Mess Officer
job-name-chemicalspecialist = Chemical Specialist
job-name-masterengineer = Master Engineer
job-name-chiefsteward = Chief Steward
job-name-chiefofsecurity = Chief of Security
job-name-internalaffairsofficer = Internal Affairs Officer
job-name-masterjanitor = Master Janitor
job-name-medicalspecialist = Medical Specialist
job-name-protocolcommissar = Protocol Commissar
job-name-quartermastergeneral = Quartermaster General
job-name-chiefofresearch = Chief of Research
job-name-modelsalvagelead = Model Salvage Lead
job-name-modelsalvager = Model Salvager
job-name-masterscientist = Master Scientist
job-name-modelofficer = Model Officer
job-name-engineeringspecialist = Engineering Specialist
job-name-specialistsurgeon = Specialist Surgeon
job-name-modelwarden = Model Warden
job-name-atmosphericspecialist = Atmospheric Specialist
job-name-dutyspecialist = Duty Specialist
job-name-surgeongeneral = Surgeon General
job-name-grandmagistrate = Grand Magistrate
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Cargo/cargo_technician.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
- !type:GiveItemOnHolidaySpecial
holiday: BoxingDay
prototype: BoxCardboard
# Starlight
ranks:
- CargoSpecialist
# StarlightEnd

- type: startingGear
id: CargoTechGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Cargo/quartermaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
# Starlight
ranks:
- QuartermasterGeneral
# StarlightEnd

- type: startingGear
id: QuartermasterGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
special:
- !type:AddImplantSpecial
implants: [ MindShieldImplant ]
# Starlight
ranks:
- ModelSalvager
# StarlightEnd

- type: startingGear
id: SalvageSpecialistGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/bartender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
extendedAccess:
- Kitchen
- Hydroponics
# Starlight
ranks:
- MasterBartender
# StarlightEnd

- type: startingGear
id: BartenderGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/botanist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
- !type:GiveItemOnHolidaySpecial
holiday: FourTwenty
prototype: CannabisSeeds
# Starlight
ranks:
- MasterBotanist
# StarlightEnd

- type: startingGear
id: BotanistGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/chef.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
extendedAccess:
- Hydroponics
- Bar
# Starlight
ranks:
- MessOfficer
# StarlightEnd

- type: startingGear
id: ChefGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/janitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- !type:GiveItemOnHolidaySpecial
holiday: GarbageDay
prototype: WeaponRevolverInspector
# Starlight
ranks:
- MasterJanitor
# StarlightEnd

- type: startingGear
id: JanitorGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Command/captain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
# Starlight
ranks:
- Admiral
# StarlightEnd

- type: startingGear
id: CaptainGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
# Starlight
ranks:
- ChiefSteward
# StarlightEnd

- type: startingGear
id: HoPGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
- !type:GiveItemOnHolidaySpecial
holiday: FirefighterDay
prototype: FireAxe
# Starlight
ranks:
- AtmosphericSpecialist
# StarlightEnd

- type: startingGear
id: AtmosphericTechnicianGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
# Starlight
ranks:
- MasterEngineer
# StarlightEnd

- type: startingGear
id: ChiefEngineerGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- External
extendedAccess:
- Atmospherics
# Starlight
ranks:
- EngineeringSpecialist
# StarlightEnd

- type: startingGear
id: StationEngineerGear
Expand Down
5 changes: 4 additions & 1 deletion Resources/Prototypes/Roles/Jobs/Medical/chemist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
extendedAccess:
- Paramedic
- Surgery
# Starlight End
ranks:
- ChemicalSpecialist
# StarlightEnd


- type: startingGear
id: ChemistGear
Expand Down
Loading
Loading