(24c49c72a) Added swarm behavior to crawlers. Any group of monsters spawned by a single MonsterEvent will now act as a swarm if they have SwarmBehavior defined in their xml

This commit is contained in:
Joonas Rikkonen
2019-04-18 12:02:35 +03:00
parent fe163b34b2
commit aed2c71806
4 changed files with 109 additions and 11 deletions
@@ -227,17 +227,17 @@ namespace Barotrauma
monsters = new List<Character>();
float offsetAmount = spawnPosType == Level.PositionType.MainPath ? 1000 : 100;
for (int i = 0; i < amount; i++)
{
{
CoroutineManager.InvokeAfter(() =>
{
bool isClient = false;
#if CLIENT
isClient = GameMain.Client != null;
#endif
bool isClient = GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient;
monsters.Add(Character.Create(characterFile, spawnPos + Rand.Vector(offsetAmount, Rand.RandSync.Server), i.ToString(), null, isClient, true, true));
if (monsters.Count == amount)
{
spawnReady = true;
//this will do nothing if the monsters have no swarm behavior defined,
//otherwise it'll make the spawned characters act as a swarm
SwarmBehavior.CreateSwarm(monsters.Cast<AICharacter>());
}
}, Rand.Range(0f, amount / 2, Rand.RandSync.Server));
}