mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-06-09 15:06:34 +02:00
Make objective issuers into prototypes (#44168)
* woohoo * yeah * fuck * Update Content.Shared/Objectives/Prototypes/ObjectiveIssuerPrototype.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<ObjectiveComponent>(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<ObjectiveComponent>(objective).LocIssuer;
|
||||
var issuer = issuerProto.LocalizedName;
|
||||
if (!objectives.ContainsKey(issuer))
|
||||
objectives[issuer] = new List<ObjectiveInfo>();
|
||||
objectives[issuer].Add(info.Value);
|
||||
|
||||
@@ -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<ObjectiveComponent>(o).LocIssuer))
|
||||
foreach (var objectiveGroup in objectives.GroupBy(o => Comp<ObjectiveComponent>(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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Organisation that issued this objective, used for grouping and as a header above common objectives.
|
||||
/// </summary>
|
||||
[DataField("issuer", required: true)]
|
||||
private LocId Issuer { get; set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public string LocIssuer => Loc.GetString(Issuer);
|
||||
[DataField(required: true)]
|
||||
public ProtoId<ObjectiveIssuerPrototype> Issuer = "Unknown";
|
||||
|
||||
/// <summary>
|
||||
/// Unique objectives can only have 1 per prototype id.
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Objectives.Prototypes;
|
||||
|
||||
/// <summary>
|
||||
/// Prototype for objective issuers.
|
||||
/// They represent organizations that issue objectives, used for grouping and as a header above common objectives.
|
||||
/// </summary>
|
||||
[Prototype]
|
||||
public sealed partial class ObjectiveIssuerPrototype : IPrototype
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[IdDataField]
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The LocId of the issuer name.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
private LocId Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized version of the issuer name.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string LocalizedName => Loc.GetString(Name);
|
||||
}
|
||||
@@ -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]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
id: BaseChangelingObjective
|
||||
components:
|
||||
- type: Objective
|
||||
issuer: objective-issuer-changeling
|
||||
issuer: Changeling
|
||||
difficulty: 1
|
||||
- type: RoleRequirement
|
||||
roles:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
- type: Objective
|
||||
# required but not used
|
||||
difficulty: 1
|
||||
issuer: objective-issuer-paradox
|
||||
issuer: Paradox
|
||||
- type: RoleRequirement
|
||||
roles:
|
||||
- ParadoxCloneRole
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
id: BaseThiefObjective
|
||||
components:
|
||||
- type: Objective
|
||||
issuer: objective-issuer-thief
|
||||
issuer: Thief
|
||||
- type: RoleRequirement
|
||||
roles:
|
||||
- ThiefRole
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
id: BaseTraitorObjective
|
||||
components:
|
||||
- type: Objective
|
||||
issuer: objective-issuer-syndicate
|
||||
issuer: TheSyndicate
|
||||
- type: RoleRequirement
|
||||
roles:
|
||||
- TraitorRole
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
- type: Objective
|
||||
# required but not used
|
||||
difficulty: 1
|
||||
issuer: objective-issuer-swf
|
||||
issuer: SpaceWizardsFederation
|
||||
- type: RoleRequirement
|
||||
roles:
|
||||
- WizardRole
|
||||
|
||||
Reference in New Issue
Block a user