1
0

ReproductiveComponent.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using Content.Shared.Storage;
  2. using Content.Shared.Whitelist;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  4. namespace Content.Shared.Nutrition.AnimalHusbandry;
  5. /// <summary>
  6. /// This is used for simple animal husbandry. Entities with this component,
  7. /// given they are next to a particular entity that fulfills a whitelist,
  8. /// can create several "child" entities.
  9. /// </summary>
  10. [RegisterComponent, AutoGenerateComponentPause]
  11. public sealed partial class ReproductiveComponent : Component
  12. {
  13. /// <summary>
  14. /// The next time when breeding will be attempted.
  15. /// </summary>
  16. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
  17. [AutoPausedField]
  18. public TimeSpan NextBreedAttempt;
  19. /// <summary>
  20. /// Minimum length between each attempt to breed.
  21. /// </summary>
  22. [DataField, ViewVariables(VVAccess.ReadWrite)]
  23. public TimeSpan MinBreedAttemptInterval = TimeSpan.FromSeconds(45);
  24. /// <summary>
  25. /// Maximum length between each attempt to breed.
  26. /// </summary>
  27. [DataField, ViewVariables(VVAccess.ReadWrite)]
  28. public TimeSpan MaxBreedAttemptInterval = TimeSpan.FromSeconds(60);
  29. /// <summary>
  30. /// How close to a partner an entity must be in order to breed.
  31. /// Unrealistically long.
  32. /// </summary>
  33. [DataField, ViewVariables(VVAccess.ReadWrite)]
  34. public float BreedRange = 3f;
  35. /// <summary>
  36. /// How many other entities with this component are allowed in range before we stop.
  37. /// </summary>
  38. [DataField, ViewVariables(VVAccess.ReadWrite)]
  39. public int Capacity = 6;
  40. /// <summary>
  41. /// The chance that, on a given attempt,
  42. /// for each valid partner, the entity will breed.
  43. /// </summary>
  44. [DataField, ViewVariables(VVAccess.ReadWrite)]
  45. public float BreedChance = 0.15f;
  46. /// <summary>
  47. /// Entity prototypes for what type of
  48. /// offspring can be produced by this entity.
  49. /// </summary>
  50. [DataField(required: true)]
  51. public List<EntitySpawnEntry> Offspring = default!;
  52. /// <summary>
  53. /// Whether or not this entity has bred successfully
  54. /// and will produce offspring imminently
  55. /// </summary>
  56. [DataField]
  57. public bool Gestating;
  58. /// <summary>
  59. /// When gestation will end.
  60. /// Null if <see cref="Gestating"/> is false
  61. /// </summary>
  62. [DataField, ViewVariables(VVAccess.ReadWrite)]
  63. public TimeSpan? GestationEndTime;
  64. /// <summary>
  65. /// How long it takes the entity after breeding
  66. /// to produce offspring
  67. /// </summary>
  68. [DataField, ViewVariables(VVAccess.ReadWrite)]
  69. public TimeSpan GestationDuration = TimeSpan.FromMinutes(1.5);
  70. /// <summary>
  71. /// How much hunger is consumed when an entity
  72. /// gives birth. A balancing tool to require feeding.
  73. /// </summary>
  74. [DataField, ViewVariables(VVAccess.ReadWrite)]
  75. public float HungerPerBirth = 75f;
  76. /// <summary>
  77. /// Popup shown when an entity gives birth.
  78. /// Configurable for things like laying eggs.
  79. /// </summary>
  80. [DataField, ViewVariables(VVAccess.ReadWrite)]
  81. public LocId BirthPopup = "reproductive-birth-popup";
  82. /// <summary>
  83. /// Whether or not the offspring should be made into "infants".
  84. /// </summary>
  85. [DataField, ViewVariables(VVAccess.ReadWrite)]
  86. public bool MakeOffspringInfant = true;
  87. /// <summary>
  88. /// An entity whitelist for what entities
  89. /// can be this one's partner.
  90. /// </summary>
  91. [DataField(required: true)]
  92. public EntityWhitelist PartnerWhitelist = default!;
  93. }