Skip to content

Commit

Permalink
Senior ID cards get a custom job name (#1218)
Browse files Browse the repository at this point in the history
* Allow preset id's to have different job names

* Senior roles

* Sync with Station Records

* Change markers
  • Loading branch information
NullWanderer authored May 18, 2024
1 parent 59ffd5b commit 72853c1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Content.Server/Access/Components/PresetIdCardComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ public sealed partial class PresetIdCardComponent : Component

[DataField("name")]
public string? IdName;

/// <summary>
/// DeltaV: Allow changing the job title, even if it'd be otherwise set by the JobPrototype
/// </summary>
[DataField("customJob")]
public string? CustomJobName;
}
24 changes: 24 additions & 0 deletions Content.Server/Access/Systems/PresetIdCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using Content.Server.GameTicking;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationRecords.Systems;
using Content.Shared.Access.Systems;
using Content.Shared.Roles;
using Content.Shared.StationRecords;
using Content.Shared.StatusIcon;
using Robust.Shared.Prototypes;

Expand All @@ -15,6 +17,7 @@ public sealed class PresetIdCardSystem : EntitySystem
[Dependency] private readonly IdCardSystem _cardSystem = default!;
[Dependency] private readonly SharedAccessSystem _accessSystem = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly StationRecordsSystem _record = default!; // DeltaV - Allow changing the job title within the prototype

public override void Initialize()
{
Expand All @@ -38,6 +41,7 @@ private void PlayerJobsAssigned(RulePlayerJobsAssignedEvent ev)

SetupIdAccess(uid, card, true);
SetupIdName(uid, card);
SetupIdJob(uid, card); // DeltaV - Allow changing the job title within the prototype
}
}

Expand All @@ -57,6 +61,7 @@ private void OnMapInit(EntityUid uid, PresetIdCardComponent id, MapInitEvent arg

SetupIdAccess(uid, id, extended);
SetupIdName(uid, id);
SetupIdJob(uid, id); // DeltaV - Allow changing the job title within the prototype
}

private void SetupIdName(EntityUid uid, PresetIdCardComponent id)
Expand All @@ -66,6 +71,25 @@ private void SetupIdName(EntityUid uid, PresetIdCardComponent id)
_cardSystem.TryChangeFullName(uid, id.IdName);
}

// DeltaV - Allow changing the job title within the prototype
private void SetupIdJob(EntityUid uid, PresetIdCardComponent id)
{
if (id.CustomJobName == null)
return;
_cardSystem.TryChangeJobTitle(uid, id.CustomJobName);

// The following code is taken from IdCardConsoleSystem
if (!TryComp<StationRecordKeyStorageComponent>(uid, out var keyStorage)
|| keyStorage.Key is not { } key
|| !_record.TryGetRecord<GeneralStationRecord>(key, out var record))
{
return;
}
record.JobTitle = id.CustomJobName;
_record.Synchronize(key);
}
// End of DeltaV code

private void SetupIdAccess(EntityUid uid, PresetIdCardComponent id, bool extended)
{
if (id.JobName == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,8 @@
layers:
- state: default
- state: idseniorengineer
- type: PresetIdCard # DeltaV - Change senior job titles
customJob: Senior Engineer

- type: entity
parent: ResearchIDCard
Expand All @@ -828,6 +830,8 @@
layers:
- state: default
- state: idseniorresearcher
- type: PresetIdCard # DeltaV - Change senior job titles
customJob: Senior Researcher

- type: entity
parent: MedicalIDCard
Expand All @@ -838,6 +842,8 @@
layers:
- state: default
- state: idseniorphysician
- type: PresetIdCard # DeltaV - Change senior job titles
customJob: Senior Physician

- type: entity
parent: SecurityIDCard
Expand All @@ -848,3 +854,5 @@
layers:
- state: default
- state: idseniorofficer
- type: PresetIdCard # DeltaV - Change senior job titles
customJob: Senior Officer

0 comments on commit 72853c1

Please sign in to comment.