2023-09-16 07:18:10 +01:00
using Content.Shared.Mind ;
using Content.Shared.Objectives ;
using Content.Shared.Objectives.Systems ;
using Robust.Shared.Utility ;
2024-06-03 13:23:52 +00:00
using Robust.Shared.Prototypes ;
2023-09-16 07:18:10 +01:00
namespace Content.Shared.Objectives.Components ;
/// <summary>
/// Required component for an objective entity prototype.
/// </summary>
[RegisterComponent, Access(typeof(SharedObjectivesSystem))]
2024-06-03 13:23:52 +00:00
[EntityCategory("Objectives")]
2023-09-16 07:18:10 +01:00
public sealed partial class ObjectiveComponent : Component
{
/// <summary>
/// Difficulty rating used to avoid assigning too many difficult objectives.
/// </summary>
2024-06-03 13:23:52 +00:00
[DataField(required: true)]
2023-09-16 07:18:10 +01:00
public float Difficulty ;
/// <summary>
/// Organisation that issued this objective, used for grouping and as a header above common objectives.
/// </summary>
2024-07-17 08:47:50 +03:00
[DataField("issuer", required: true)]
private LocId Issuer { get ; set ; }
[ViewVariables(VVAccess.ReadOnly)]
public string LocIssuer = > Loc . GetString ( Issuer ) ;
2023-09-16 07:18:10 +01:00
/// <summary>
/// Unique objectives can only have 1 per prototype id.
/// Set this to false if you want multiple objectives of the same prototype.
/// </summary>
2024-06-03 13:23:52 +00:00
[DataField]
2023-09-16 07:18:10 +01:00
public bool Unique = true ;
/// <summary>
/// Icon of this objective to display in the character menu.
/// Can be specified by an <see cref="ObjectiveGetInfoEvent"/> handler but is usually done in the prototype.
/// </summary>
2024-06-03 13:23:52 +00:00
[DataField]
2023-09-16 07:18:10 +01:00
public SpriteSpecifier ? Icon ;
}
/// <summary>
/// Event raised on an objective after spawning it to see if it meets all the requirements.
/// Requirement components should have subscriptions and cancel if the requirements are not met.
/// If a requirement is not met then the objective is deleted.
/// </summary>
[ByRefEvent]
public record struct RequirementCheckEvent ( EntityUid MindId , MindComponent Mind , bool Cancelled = false ) ;
/// <summary>
/// Event raised on an objective after its requirements have been checked.
/// If <see cref="Cancelled"/> is set to true, the objective is deleted.
/// Use this if the objective cannot be used, like a kill objective with no people alive.
/// </summary>
[ByRefEvent]
public record struct ObjectiveAssignedEvent ( EntityUid MindId , MindComponent Mind , bool Cancelled = false ) ;
/// <summary>
/// Event raised on an objective after everything has handled <see cref="ObjectiveAssignedEvent"/>.
/// Use this to set the objective's title description or icon.
/// </summary>
[ByRefEvent]
2024-10-20 21:20:16 +03:00
public record struct ObjectiveAfterAssignEvent ( EntityUid ? MindId , MindComponent ? Mind , ObjectiveComponent Objective , MetaDataComponent Meta ) ; //CP14 add ? to mindId and Mind. For Common goals
2023-09-16 07:18:10 +01:00
/// <summary>
/// Event raised on an objective to update the Progress field.
/// To use this yourself call <see cref="SharedObjectivesSystem.GetInfo"/> with the mind.
/// </summary>
[ByRefEvent]
public record struct ObjectiveGetProgressEvent ( EntityUid MindId , MindComponent Mind , float? Progress = null ) ;