2022-05-13 00:59:03 -07:00
|
|
|
|
using System.Threading;
|
2021-10-14 11:09:16 +02:00
|
|
|
|
using Robust.Shared.Prototypes;
|
2020-06-23 20:24:25 +02:00
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
using Robust.Shared.Serialization;
|
2021-10-14 11:09:16 +02:00
|
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
2020-06-23 20:24:25 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Spawners.Components
|
2020-06-23 20:24:25 +02:00
|
|
|
|
{
|
|
|
|
|
|
[RegisterComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
|
public sealed partial class TimedSpawnerComponent : Component, ISerializationHooks
|
2020-06-23 20:24:25 +02:00
|
|
|
|
{
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-10-14 11:09:16 +02:00
|
|
|
|
[DataField("prototypes", customTypeSerializer:typeof(PrototypeIdListSerializer<EntityPrototype>))]
|
2020-11-27 11:00:49 +01:00
|
|
|
|
public List<string> Prototypes { get; set; } = new();
|
2020-06-23 20:24:25 +02:00
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("chance")]
|
2020-06-23 20:24:25 +02:00
|
|
|
|
public float Chance { get; set; } = 1.0f;
|
|
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("intervalSeconds")]
|
2020-06-23 20:24:25 +02:00
|
|
|
|
public int IntervalSeconds { get; set; } = 60;
|
|
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("MinimumEntitiesSpawned")]
|
2020-06-23 20:24:25 +02:00
|
|
|
|
public int MinimumEntitiesSpawned { get; set; } = 1;
|
|
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("MaximumEntitiesSpawned")]
|
2020-06-23 20:24:25 +02:00
|
|
|
|
public int MaximumEntitiesSpawned { get; set; } = 1;
|
|
|
|
|
|
|
2023-01-19 11:56:25 +11:00
|
|
|
|
public CancellationTokenSource? TokenSource;
|
2020-06-23 20:24:25 +02:00
|
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
|
void ISerializationHooks.AfterDeserialization()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (MinimumEntitiesSpawned > MaximumEntitiesSpawned)
|
|
|
|
|
|
throw new ArgumentException("MaximumEntitiesSpawned can't be lower than MinimumEntitiesSpawned!");
|
|
|
|
|
|
}
|
2020-06-23 20:24:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|