From 2a606f1c23fdee3fd59ac930c135751a5af56de9 Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Mon, 27 Aug 2018 15:29:32 +0300 Subject: [PATCH] Some stuff to make Stinger Work --- OpenRA.Mods.Gen/Traits/BaseSpawnerMaster.cs | 13 ++++++++++--- OpenRA.Mods.Gen/Traits/MobSpawnerMaster.cs | 9 +++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Gen/Traits/BaseSpawnerMaster.cs b/OpenRA.Mods.Gen/Traits/BaseSpawnerMaster.cs index 58d139627b81..4cad8334777e 100644 --- a/OpenRA.Mods.Gen/Traits/BaseSpawnerMaster.cs +++ b/OpenRA.Mods.Gen/Traits/BaseSpawnerMaster.cs @@ -14,6 +14,7 @@ using System; using System.Linq; +using OpenRA.Mods.Common; using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; using OpenRA.Traits; @@ -58,6 +59,9 @@ public class BaseSpawnerMasterInfo : ConditionalTraitInfo [Desc("Only spawn initial load of slaves?")] public readonly bool NoRegeneration = false; + [Desc("Set slave subcell to this if it allows.")] + public readonly int SubCell = -1; + [Desc("Spawn all slaves at once when regenerating slaves, instead of one by one?")] public readonly bool SpawnAllAtOnce = false; @@ -167,9 +171,12 @@ public void Replenish(Actor self, BaseSpawnerSlaveEntry entry) if (entry.IsValid) throw new InvalidOperationException("Replenish must not be run on a valid entry!"); + var td = new TypeDictionary { new OwnerInit(self.Owner) }; + if (Info.SubCell > 0) + td.Add(new SubCellInit(Info.SubCell)); + // Some members are missing. Create a new one. - var slave = self.World.CreateActor(false, entry.ActorName, - new TypeDictionary { new OwnerInit(self.Owner) }); + var slave = self.World.CreateActor(false, entry.ActorName, td); // Initialize slave entry InitializeSlaveEntry(slave, entry); @@ -239,7 +246,7 @@ public void SpawnIntoWorld(Actor self, Actor slave, WPos centerPosition) var location = self.World.Map.CellContaining(centerPosition + spawnOffset); var mv = slave.Trait(); - slave.QueueActivity(mv.MoveIntoWorld(slave, location)); + slave.QueueActivity(mv.MoveIntoWorld(slave, location, Info.SubCell > 0 ? (SubCell)Info.SubCell : SubCell.Any)); // Move to rally point if any. if (rallyPoint != null) diff --git a/OpenRA.Mods.Gen/Traits/MobSpawnerMaster.cs b/OpenRA.Mods.Gen/Traits/MobSpawnerMaster.cs index 4cd51e93e670..086166d5c980 100644 --- a/OpenRA.Mods.Gen/Traits/MobSpawnerMaster.cs +++ b/OpenRA.Mods.Gen/Traits/MobSpawnerMaster.cs @@ -47,9 +47,12 @@ public class MobSpawnerMasterInfo : BaseSpawnerMasterInfo [Desc("Can the slaves be controlled independently?")] public readonly bool SlavesHaveFreeWill = false; - [Desc("This is a dummy spawner like cin C&C Generals and use virtual position and health.")] + [Desc("This is a dummy spawner like in C&C Generals and use virtual position and health.")] public readonly bool AggregateHealth = true; + [Desc("Spawn actors with this offset to nexus.")] + public readonly WVec Offset = WVec.Zero; + public readonly int AggregateHealthUpdateDelay = 17; // Just a visual parameter, Doesn't affect the game. public override void RulesetLoaded(Ruleset rules, ActorInfo ai) @@ -206,8 +209,10 @@ void SpawnReplenishedSlaves(Actor self) return; foreach (var se in slaveEntries) + { if (se.IsValid && !se.Actor.IsInWorld) - SpawnIntoWorld(self, se.Actor, centerPosition); + SpawnIntoWorld(self, se.Actor, centerPosition + Info.Offset); + } } public override void OnSlaveKilled(Actor self, Actor slave)