Add initial delay for ActorSpawnManager

This commit is contained in:
N.N
2023-11-22 15:12:59 +01:00
committed by Gustas
parent ca6b87d05e
commit bb1e830264
3 changed files with 15 additions and 0 deletions

View File

@@ -27,6 +27,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Maximum number of actors.")]
public readonly int Maximum = 4;
[Desc("Initial delay before first actor is spawn")]
public readonly int InitialDelay = 0;
[Desc("Time (in ticks) between actor spawn. Supports 1 or 2 values.",
"If 2 values are provided they are used as a range from which a value is randomly selected.")]
public readonly int[] SpawnInterval = { 6000 };
@@ -64,6 +67,7 @@ namespace OpenRA.Mods.Common.Traits
bool enabled;
int spawnCountdown;
int initialDelay;
int actorsPresent;
public ActorSpawnManager(ActorSpawnManagerInfo info)
@@ -78,11 +82,20 @@ namespace OpenRA.Mods.Common.Traits
base.Created(self);
}
protected override void TraitEnabled(Actor self)
{
initialDelay = info.InitialDelay;
spawnCountdown = 0;
}
void ITick.Tick(Actor self)
{
if (IsTraitDisabled || !enabled)
return;
if (--initialDelay > 0)
return;
if (info.Maximum < 1 || actorsPresent >= info.Maximum)
return;

View File

@@ -32,6 +32,7 @@ World:
ActorSpawnManager:
Minimum: 0
Maximum: 1
InitialDelay: 5000
MapCreeps:
CheckboxVisible: False
CheckboxLocked: True

View File

@@ -130,6 +130,7 @@ World:
ProductionPaletteWidget: PRODUCTION_PALETTE
ActorSpawnManager:
Actors: sandworm
InitialDelay: 9000
CrateSpawner:
Minimum: 0
Maximum: 2