Add initial delay for ActorSpawnManager
This commit is contained in:
@@ -27,6 +27,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Maximum number of actors.")]
|
[Desc("Maximum number of actors.")]
|
||||||
public readonly int Maximum = 4;
|
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.",
|
[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.")]
|
"If 2 values are provided they are used as a range from which a value is randomly selected.")]
|
||||||
public readonly int[] SpawnInterval = { 6000 };
|
public readonly int[] SpawnInterval = { 6000 };
|
||||||
@@ -64,6 +67,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
int spawnCountdown;
|
int spawnCountdown;
|
||||||
|
int initialDelay;
|
||||||
int actorsPresent;
|
int actorsPresent;
|
||||||
|
|
||||||
public ActorSpawnManager(ActorSpawnManagerInfo info)
|
public ActorSpawnManager(ActorSpawnManagerInfo info)
|
||||||
@@ -78,11 +82,20 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
base.Created(self);
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void TraitEnabled(Actor self)
|
||||||
|
{
|
||||||
|
initialDelay = info.InitialDelay;
|
||||||
|
spawnCountdown = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled || !enabled)
|
if (IsTraitDisabled || !enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (--initialDelay > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (info.Maximum < 1 || actorsPresent >= info.Maximum)
|
if (info.Maximum < 1 || actorsPresent >= info.Maximum)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ World:
|
|||||||
ActorSpawnManager:
|
ActorSpawnManager:
|
||||||
Minimum: 0
|
Minimum: 0
|
||||||
Maximum: 1
|
Maximum: 1
|
||||||
|
InitialDelay: 5000
|
||||||
MapCreeps:
|
MapCreeps:
|
||||||
CheckboxVisible: False
|
CheckboxVisible: False
|
||||||
CheckboxLocked: True
|
CheckboxLocked: True
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ World:
|
|||||||
ProductionPaletteWidget: PRODUCTION_PALETTE
|
ProductionPaletteWidget: PRODUCTION_PALETTE
|
||||||
ActorSpawnManager:
|
ActorSpawnManager:
|
||||||
Actors: sandworm
|
Actors: sandworm
|
||||||
|
InitialDelay: 9000
|
||||||
CrateSpawner:
|
CrateSpawner:
|
||||||
Minimum: 0
|
Minimum: 0
|
||||||
Maximum: 2
|
Maximum: 2
|
||||||
|
|||||||
Reference in New Issue
Block a user