From bb1e83026430811c4fd2ad28b8f51052520ac7cf Mon Sep 17 00:00:00 2001 From: "N.N" Date: Wed, 22 Nov 2023 15:12:59 +0100 Subject: [PATCH] Add initial delay for ActorSpawnManager --- .../Traits/World/ActorSpawnManager.cs | 13 +++++++++++++ mods/d2k/rules/campaign-rules.yaml | 1 + mods/d2k/rules/world.yaml | 1 + 3 files changed, 15 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs index 37ce2f94d4..a8a067b7d0 100644 --- a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs +++ b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs @@ -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; diff --git a/mods/d2k/rules/campaign-rules.yaml b/mods/d2k/rules/campaign-rules.yaml index 46c72a6a8e..a695bcf994 100644 --- a/mods/d2k/rules/campaign-rules.yaml +++ b/mods/d2k/rules/campaign-rules.yaml @@ -32,6 +32,7 @@ World: ActorSpawnManager: Minimum: 0 Maximum: 1 + InitialDelay: 5000 MapCreeps: CheckboxVisible: False CheckboxLocked: True diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index e5b5ae9340..2edd523b44 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -130,6 +130,7 @@ World: ProductionPaletteWidget: PRODUCTION_PALETTE ActorSpawnManager: Actors: sandworm + InitialDelay: 9000 CrateSpawner: Minimum: 0 Maximum: 2