diff --git a/Content.IntegrationTests/Tests/Commands/ObjectiveCommandsTest.cs b/Content.IntegrationTests/Tests/Commands/ObjectiveCommandsTest.cs index eb18d8e1ae..0422f1bc3d 100644 --- a/Content.IntegrationTests/Tests/Commands/ObjectiveCommandsTest.cs +++ b/Content.IntegrationTests/Tests/Commands/ObjectiveCommandsTest.cs @@ -21,7 +21,7 @@ public sealed class ObjectiveCommandsTest : GameTest components: - type: Objective difficulty: 1 - issuer: objective-issuer-syndicate + issuer: TheSyndicate icon: sprite: error.rsi state: error diff --git a/Content.Server/CharacterInfo/CharacterInfoSystem.cs b/Content.Server/CharacterInfo/CharacterInfoSystem.cs index 608c9c49a3..9cc1488265 100644 --- a/Content.Server/CharacterInfo/CharacterInfoSystem.cs +++ b/Content.Server/CharacterInfo/CharacterInfoSystem.cs @@ -5,6 +5,7 @@ using Content.Shared.CharacterInfo; using Content.Shared.Objectives; using Content.Shared.Objectives.Components; using Content.Shared.Objectives.Systems; +using Robust.Shared.Prototypes; namespace Content.Server.CharacterInfo; @@ -14,6 +15,7 @@ public sealed partial class CharacterInfoSystem : EntitySystem [Dependency] private MindSystem _minds = default!; [Dependency] private RoleSystem _roles = default!; [Dependency] private SharedObjectivesSystem _objectives = default!; + [Dependency] private IPrototypeManager _protoMan = default!; public override void Initialize() { @@ -42,8 +44,14 @@ public sealed partial class CharacterInfoSystem : EntitySystem if (info == null) continue; + if (!_protoMan.TryIndex(Comp(objective).Issuer, out var issuerProto)) + { + Log.Error($"Found incorrect objective issuer {issuerProto} when generating character info for objective {MetaData(objective).EntityPrototype}."); + continue; + } + // group objectives by their issuer - var issuer = Comp(objective).LocIssuer; + var issuer = issuerProto.LocalizedName; if (!objectives.ContainsKey(issuer)) objectives[issuer] = new List(); objectives[issuer].Add(info.Value); diff --git a/Content.Server/Objectives/ObjectivesSystem.cs b/Content.Server/Objectives/ObjectivesSystem.cs index 53b6d3b71b..f7c9d41fe3 100644 --- a/Content.Server/Objectives/ObjectivesSystem.cs +++ b/Content.Server/Objectives/ObjectivesSystem.cs @@ -147,12 +147,18 @@ public sealed partial class ObjectivesSystem : SharedObjectivesSystem var agentSummary = new StringBuilder(); agentSummary.AppendLine(Loc.GetString("objectives-with-objectives", ("custody", custody), ("title", title), ("agent", agent))); - foreach (var objectiveGroup in objectives.GroupBy(o => Comp(o).LocIssuer)) + foreach (var objectiveGroup in objectives.GroupBy(o => Comp(o).Issuer)) { //TO DO: //check for the right group here. Getting the target issuer is easy: objectiveGroup.Key //It should be compared to the type of the group's issuer. - agentSummary.AppendLine(objectiveGroup.Key); + if (!_prototypeManager.TryIndex(objectiveGroup.Key, out var issuer)) + { + Log.Error($"Found incorrect objective issuer {issuer} when generating round end text."); + continue; + } + + agentSummary.AppendLine(issuer.LocalizedName); foreach (var objective in objectiveGroup) { diff --git a/Content.Shared/Objectives/Components/ObjectiveComponent.cs b/Content.Shared/Objectives/Components/ObjectiveComponent.cs index fb2e6ca0a6..feb2c444ef 100644 --- a/Content.Shared/Objectives/Components/ObjectiveComponent.cs +++ b/Content.Shared/Objectives/Components/ObjectiveComponent.cs @@ -1,5 +1,6 @@ using Content.Shared.Mind; using Content.Shared.Objectives; +using Content.Shared.Objectives.Prototypes; using Content.Shared.Objectives.Systems; using Robust.Shared.Utility; using Robust.Shared.Prototypes; @@ -22,11 +23,8 @@ public sealed partial class ObjectiveComponent : Component /// /// Organisation that issued this objective, used for grouping and as a header above common objectives. /// - [DataField("issuer", required: true)] - private LocId Issuer { get; set; } - - [ViewVariables(VVAccess.ReadOnly)] - public string LocIssuer => Loc.GetString(Issuer); + [DataField(required: true)] + public ProtoId Issuer = "Unknown"; /// /// Unique objectives can only have 1 per prototype id. diff --git a/Content.Shared/Objectives/Prototypes/ObjectiveIssuerPrototype.cs b/Content.Shared/Objectives/Prototypes/ObjectiveIssuerPrototype.cs new file mode 100644 index 0000000000..694d345e1e --- /dev/null +++ b/Content.Shared/Objectives/Prototypes/ObjectiveIssuerPrototype.cs @@ -0,0 +1,27 @@ +using Robust.Shared.Prototypes; + +namespace Content.Shared.Objectives.Prototypes; + +/// +/// Prototype for objective issuers. +/// They represent organizations that issue objectives, used for grouping and as a header above common objectives. +/// +[Prototype] +public sealed partial class ObjectiveIssuerPrototype : IPrototype +{ + /// + [IdDataField] + public string ID { get; private set; } = default!; + + /// + /// The LocId of the issuer name. + /// + [DataField(required: true)] + private LocId Name { get; set; } + + /// + /// Localized version of the issuer name. + /// + [ViewVariables] + public string LocalizedName => Loc.GetString(Name); +} diff --git a/Resources/Locale/en-US/game-ticking/game-presets/preset-secret.ftl b/Resources/Locale/en-US/game-ticking/game-presets/preset-secret.ftl index 2551b0073d..483b9e0b31 100644 --- a/Resources/Locale/en-US/game-ticking/game-presets/preset-secret.ftl +++ b/Resources/Locale/en-US/game-ticking/game-presets/preset-secret.ftl @@ -3,3 +3,5 @@ secret-description = It's a secret to everyone. The threats you encounter are ra dynamic-title = Dynamic dynamic-description = No one knows what's coming. You can encounter any number of threats. + +objective-issuer-unknown = [color=white]Unknown[/color] diff --git a/Resources/Prototypes/Objectives/changeling.yml b/Resources/Prototypes/Objectives/changeling.yml index b9e9a6b67f..34aea43344 100644 --- a/Resources/Prototypes/Objectives/changeling.yml +++ b/Resources/Prototypes/Objectives/changeling.yml @@ -4,7 +4,7 @@ id: BaseChangelingObjective components: - type: Objective - issuer: objective-issuer-changeling + issuer: Changeling difficulty: 1 - type: RoleRequirement roles: diff --git a/Resources/Prototypes/Objectives/dragon.yml b/Resources/Prototypes/Objectives/dragon.yml index 35740896e3..5225d9ede1 100644 --- a/Resources/Prototypes/Objectives/dragon.yml +++ b/Resources/Prototypes/Objectives/dragon.yml @@ -6,7 +6,7 @@ - type: Objective # difficulty isn't used at all since objective are fixed difficulty: 1.5 - issuer: objective-issuer-dragon + issuer: SpaceDragon - type: RoleRequirement roles: - DragonRole diff --git a/Resources/Prototypes/Objectives/issuers.yml b/Resources/Prototypes/Objectives/issuers.yml new file mode 100644 index 0000000000..92f645c835 --- /dev/null +++ b/Resources/Prototypes/Objectives/issuers.yml @@ -0,0 +1,31 @@ +- type: objectiveIssuer + id: Unknown + name: objective-issuer-unknown + +- type: objectiveIssuer + id: SpaceWizardsFederation + name: objective-issuer-swf + +- type: objectiveIssuer + id: TheSyndicate + name: objective-issuer-syndicate + +- type: objectiveIssuer + id: SpiderClan + name: objective-issuer-spiderclan + +- type: objectiveIssuer + id: Changeling + name: objective-issuer-changeling + +- type: objectiveIssuer + id: Paradox + name: objective-issuer-paradox + +- type: objectiveIssuer + id: SpaceDragon + name: objective-issuer-dragon + +- type: objectiveIssuer + id: Thief + name: objective-issuer-thief diff --git a/Resources/Prototypes/Objectives/ninja.yml b/Resources/Prototypes/Objectives/ninja.yml index 03980f7b31..a3b452931f 100644 --- a/Resources/Prototypes/Objectives/ninja.yml +++ b/Resources/Prototypes/Objectives/ninja.yml @@ -6,7 +6,7 @@ - type: Objective # difficulty isn't used since all objectives are picked difficulty: 1.5 - issuer: objective-issuer-spiderclan + issuer: SpiderClan - type: RoleRequirement roles: - NinjaRole diff --git a/Resources/Prototypes/Objectives/paradoxClone.yml b/Resources/Prototypes/Objectives/paradoxClone.yml index 7006e74a05..495991c921 100644 --- a/Resources/Prototypes/Objectives/paradoxClone.yml +++ b/Resources/Prototypes/Objectives/paradoxClone.yml @@ -6,7 +6,7 @@ - type: Objective # required but not used difficulty: 1 - issuer: objective-issuer-paradox + issuer: Paradox - type: RoleRequirement roles: - ParadoxCloneRole diff --git a/Resources/Prototypes/Objectives/thief.yml b/Resources/Prototypes/Objectives/thief.yml index ef67b560de..203d5ed697 100644 --- a/Resources/Prototypes/Objectives/thief.yml +++ b/Resources/Prototypes/Objectives/thief.yml @@ -4,7 +4,7 @@ id: BaseThiefObjective components: - type: Objective - issuer: objective-issuer-thief + issuer: Thief - type: RoleRequirement roles: - ThiefRole diff --git a/Resources/Prototypes/Objectives/traitor.yml b/Resources/Prototypes/Objectives/traitor.yml index cf1d04559f..c48e784a02 100644 --- a/Resources/Prototypes/Objectives/traitor.yml +++ b/Resources/Prototypes/Objectives/traitor.yml @@ -4,7 +4,7 @@ id: BaseTraitorObjective components: - type: Objective - issuer: objective-issuer-syndicate + issuer: TheSyndicate - type: RoleRequirement roles: - TraitorRole diff --git a/Resources/Prototypes/Objectives/wizard.yml b/Resources/Prototypes/Objectives/wizard.yml index 91ebc0bf1f..92c8b46f66 100644 --- a/Resources/Prototypes/Objectives/wizard.yml +++ b/Resources/Prototypes/Objectives/wizard.yml @@ -6,7 +6,7 @@ - type: Objective # required but not used difficulty: 1 - issuer: objective-issuer-swf + issuer: SpaceWizardsFederation - type: RoleRequirement roles: - WizardRole