1
0

ObjectiveComponent.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Content.Shared.Mind;
  2. using Content.Shared.Objectives;
  3. using Content.Shared.Objectives.Systems;
  4. using Robust.Shared.Utility;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Shared.Objectives.Components;
  7. /// <summary>
  8. /// Required component for an objective entity prototype.
  9. /// </summary>
  10. [RegisterComponent, Access(typeof(SharedObjectivesSystem))]
  11. [EntityCategory("Objectives")]
  12. public sealed partial class ObjectiveComponent : Component
  13. {
  14. /// <summary>
  15. /// Difficulty rating used to avoid assigning too many difficult objectives.
  16. /// </summary>
  17. [DataField(required: true)]
  18. public float Difficulty;
  19. /// <summary>
  20. /// Organisation that issued this objective, used for grouping and as a header above common objectives.
  21. /// </summary>
  22. [DataField("issuer", required: true)]
  23. private LocId Issuer { get; set; }
  24. [ViewVariables(VVAccess.ReadOnly)]
  25. public string LocIssuer => Loc.GetString(Issuer);
  26. /// <summary>
  27. /// Unique objectives can only have 1 per prototype id.
  28. /// Set this to false if you want multiple objectives of the same prototype.
  29. /// </summary>
  30. [DataField]
  31. public bool Unique = true;
  32. /// <summary>
  33. /// Icon of this objective to display in the character menu.
  34. /// Can be specified by an <see cref="ObjectiveGetInfoEvent"/> handler but is usually done in the prototype.
  35. /// </summary>
  36. [DataField]
  37. public SpriteSpecifier? Icon;
  38. }
  39. /// <summary>
  40. /// Event raised on an objective after spawning it to see if it meets all the requirements.
  41. /// Requirement components should have subscriptions and cancel if the requirements are not met.
  42. /// If a requirement is not met then the objective is deleted.
  43. /// </summary>
  44. [ByRefEvent]
  45. public record struct RequirementCheckEvent(EntityUid MindId, MindComponent Mind, bool Cancelled = false);
  46. /// <summary>
  47. /// Event raised on an objective after its requirements have been checked.
  48. /// If <see cref="Cancelled"/> is set to true, the objective is deleted.
  49. /// Use this if the objective cannot be used, like a kill objective with no people alive.
  50. /// </summary>
  51. [ByRefEvent]
  52. public record struct ObjectiveAssignedEvent(EntityUid MindId, MindComponent Mind, bool Cancelled = false);
  53. /// <summary>
  54. /// Event raised on an objective after everything has handled <see cref="ObjectiveAssignedEvent"/>.
  55. /// Use this to set the objective's title description or icon.
  56. /// </summary>
  57. [ByRefEvent]
  58. public record struct ObjectiveAfterAssignEvent(EntityUid MindId, MindComponent Mind, ObjectiveComponent Objective, MetaDataComponent Meta);
  59. /// <summary>
  60. /// Event raised on an objective to update the Progress field.
  61. /// To use this yourself call <see cref="SharedObjectivesSystem.GetInfo"/> with the mind.
  62. /// </summary>
  63. [ByRefEvent]
  64. public record struct ObjectiveGetProgressEvent(EntityUid MindId, MindComponent Mind, float? Progress = null);