Skip to content

Commit

Permalink
Some stuff to make Stinger Work
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Aug 27, 2018
1 parent 589c4b3 commit 2a606f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 10 additions & 3 deletions OpenRA.Mods.Gen/Traits/BaseSpawnerMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Linq;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<IMove>();
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)
Expand Down
9 changes: 7 additions & 2 deletions OpenRA.Mods.Gen/Traits/MobSpawnerMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2a606f1

Please sign in to comment.