Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Senior ID cards get a custom job name #1218

Merged
Merged
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
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
Loading