AntagRandomObjectivesComponent.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Content.Server.Antag;
  2. using Content.Shared.Random;
  3. using Robust.Shared.Prototypes;
  4. namespace Content.Server.Antag.Components;
  5. /// <summary>
  6. /// Gives antags selected by this rule a random list of objectives.
  7. /// </summary>
  8. [RegisterComponent, Access(typeof(AntagRandomObjectivesSystem))]
  9. public sealed partial class AntagRandomObjectivesComponent : Component
  10. {
  11. /// <summary>
  12. /// Each set of objectives to add.
  13. /// </summary>
  14. [DataField(required: true)]
  15. public List<AntagObjectiveSet> Sets = new();
  16. /// <summary>
  17. /// If the total difficulty of the currently given objectives exceeds, no more will be given.
  18. /// </summary>
  19. [DataField(required: true)]
  20. public float MaxDifficulty;
  21. }
  22. /// <summary>
  23. /// A set of objectives to try picking.
  24. /// Difficulty is checked over all sets, but each set has its own probability and pick count.
  25. /// </summary>
  26. [DataRecord]
  27. public partial record struct AntagObjectiveSet()
  28. {
  29. /// <summary>
  30. /// The grouping used by the objective system to pick random objectives.
  31. /// First a group is picked from these, then an objective from that group.
  32. /// </summary>
  33. [DataField(required: true)]
  34. public ProtoId<WeightedRandomPrototype> Groups = string.Empty;
  35. /// <summary>
  36. /// Probability of this set being used.
  37. /// </summary>
  38. [DataField]
  39. public float Prob = 1f;
  40. /// <summary>
  41. /// Number of times to try picking objectives from this set.
  42. /// Even if there is enough difficulty remaining, no more will be given after this.
  43. /// </summary>
  44. [DataField]
  45. public int MaxPicks = 20;
  46. }