(2ed298287) Add temporal spreading to monster events when spawning multiple monsters. Increase the spatial spread when spawning monsters along the main path.
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private int minAmount, maxAmount;
|
private int minAmount, maxAmount;
|
||||||
|
|
||||||
private Character[] monsters;
|
private List<Character> monsters;
|
||||||
|
|
||||||
private bool spawnDeep;
|
private bool spawnDeep;
|
||||||
|
|
||||||
@@ -209,6 +209,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//isActive = false;
|
//isActive = false;
|
||||||
|
|
||||||
|
bool spawnReady = false;
|
||||||
if (spawnPending)
|
if (spawnPending)
|
||||||
{
|
{
|
||||||
//wait until there are no submarines at the spawnpos
|
//wait until there are no submarines at the spawnpos
|
||||||
@@ -219,25 +220,31 @@ namespace Barotrauma
|
|||||||
if (Vector2.DistanceSquared(submarine.WorldPosition, spawnPos) < minDist * minDist) return;
|
if (Vector2.DistanceSquared(submarine.WorldPosition, spawnPos) < minDist * minDist) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spawnPending = false;
|
||||||
|
|
||||||
//+1 because Range returns an integer less than the max value
|
//+1 because Range returns an integer less than the max value
|
||||||
int amount = Rand.Range(minAmount, maxAmount + 1, Rand.RandSync.Server);
|
int amount = Rand.Range(minAmount, maxAmount + 1, Rand.RandSync.Server);
|
||||||
monsters = new Character[amount];
|
monsters = new List<Character>();
|
||||||
|
float offsetAmount = spawnPosType == Level.PositionType.MainPath ? 1000 : 100;
|
||||||
for (int i = 0; i < amount; i++)
|
for (int i = 0; i < amount; i++)
|
||||||
{
|
{
|
||||||
bool isClient = false;
|
CoroutineManager.InvokeAfter(() =>
|
||||||
|
{
|
||||||
|
bool isClient = false;
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
isClient = GameMain.Client != null;
|
isClient = GameMain.Client != null;
|
||||||
#endif
|
#endif
|
||||||
|
monsters.Add(Character.Create(characterFile, spawnPos + Rand.Vector(offsetAmount, Rand.RandSync.Server), i.ToString(), null, isClient, true, true));
|
||||||
monsters[i] = Character.Create(
|
if (monsters.Count == amount)
|
||||||
characterFile, spawnPos + Rand.Vector(100.0f, Rand.RandSync.Server),
|
{
|
||||||
i.ToString(), null, isClient, true, true);
|
spawnReady = true;
|
||||||
|
}
|
||||||
|
}, Rand.Range(0f, amount / 2, Rand.RandSync.Server));
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnPending = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!spawnReady) { return; }
|
||||||
|
|
||||||
Entity targetEntity = Submarine.FindClosest(GameMain.GameScreen.Cam.WorldViewCenter);
|
Entity targetEntity = Submarine.FindClosest(GameMain.GameScreen.Cam.WorldViewCenter);
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
if (Character.Controlled != null) targetEntity = (Entity)Character.Controlled;
|
if (Character.Controlled != null) targetEntity = (Entity)Character.Controlled;
|
||||||
|
|||||||
Reference in New Issue
Block a user