diff --git a/Content.Server/Spawners/Components/TimedSpawnerComponent.cs b/Content.Server/Spawners/Components/TimedSpawnerComponent.cs index abbfd37c6a..b60afbc88b 100644 --- a/Content.Server/Spawners/Components/TimedSpawnerComponent.cs +++ b/Content.Server/Spawners/Components/TimedSpawnerComponent.cs @@ -1,40 +1,54 @@ using System.Threading; using Robust.Shared.Prototypes; -using Robust.Shared.Random; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; -namespace Content.Server.Spawners.Components +namespace Content.Server.Spawners.Components; + +/// +/// Spawns entities at a set interval. +/// Can configure the set of entities, spawn timing, spawn chance, +/// and min/max number of entities to spawn. +/// +[RegisterComponent] +public sealed partial class TimedSpawnerComponent : Component, ISerializationHooks { - [RegisterComponent] - public sealed partial class TimedSpawnerComponent : Component, ISerializationHooks + /// + /// List of entities that can be spawned by this component. One will be randomly + /// chosen for each entity spawned. When multiple entities are spawned at once, + /// each will be randomly chosen separately. + /// + [DataField] + public List Prototypes = []; + + /// + /// Chance of an entity being spawned at the end of each interval. + /// + [DataField] + public float Chance = 1.0f; + + /// + /// Length of the interval between spawn attempts. + /// + [DataField] + public int IntervalSeconds = 60; + + /// + /// The minimum number of entities that can be spawned when an interval elapses. + /// + [DataField] + public int MinimumEntitiesSpawned = 1; + + /// + /// The maximum number of entities that can be spawned when an interval elapses. + /// + [DataField] + public int MaximumEntitiesSpawned = 1; + + public CancellationTokenSource? TokenSource; + + void ISerializationHooks.AfterDeserialization() { - [ViewVariables(VVAccess.ReadWrite)] - [DataField("prototypes", customTypeSerializer:typeof(PrototypeIdListSerializer))] - public List Prototypes { get; set; } = new(); - - [ViewVariables(VVAccess.ReadWrite)] - [DataField("chance")] - public float Chance { get; set; } = 1.0f; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField("intervalSeconds")] - public int IntervalSeconds { get; set; } = 60; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField("MinimumEntitiesSpawned")] - public int MinimumEntitiesSpawned { get; set; } = 1; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField("MaximumEntitiesSpawned")] - public int MaximumEntitiesSpawned { get; set; } = 1; - - public CancellationTokenSource? TokenSource; - - void ISerializationHooks.AfterDeserialization() - { - if (MinimumEntitiesSpawned > MaximumEntitiesSpawned) - throw new ArgumentException("MaximumEntitiesSpawned can't be lower than MinimumEntitiesSpawned!"); - } + if (MinimumEntitiesSpawned > MaximumEntitiesSpawned) + throw new ArgumentException("MaximumEntitiesSpawned can't be lower than MinimumEntitiesSpawned!"); } } diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index de9a3db19e..6dcf553da1 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -415,7 +415,6 @@ makeSentient: true allowSpeech: true allowMovement: true - whitelistRequired: false name: ghost-role-information-mothroach-name description: ghost-role-information-mothroach-description - type: Fixtures @@ -744,9 +743,8 @@ Quantity: 30 - type: Udder reagentId: Milk - targetSolution: udder - quantity: 25 - updateRate: 30 + quantityPerUpdate: 25 + growthDelay: 30 - type: Butcherable spawned: - id: FoodMeat @@ -3057,7 +3055,7 @@ - type: Bloodstream bloodMaxVolume: 60 - type: CanEscapeInventory - BaseResistTime: 3 + baseResistTime: 3 - type: MobPrice price: 60 - type: NonSpreaderZombie