Preventing monsters from spawning too close to any sub (not just the main sub)

This commit is contained in:
Regalis
2016-10-06 21:17:33 +03:00
parent 0ea9600198
commit 70b8bf1937
3 changed files with 16 additions and 29 deletions
@@ -28,17 +28,7 @@ namespace Barotrauma
public override void Start(Level level)
{
float minDist = Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height);
//find a random spawnpos that isn't too close to the main sub
int tries = 0;
Vector2 spawnPos = Vector2.Zero;
do
{
spawnPos = Level.Loaded.GetRandomInterestingPosition(true, Level.PositionType.MainPath);
tries++;
} while (tries < 50 && Vector2.Distance(spawnPos, Submarine.MainSub.WorldPosition) < minDist);
Vector2 spawnPos = Level.Loaded.GetRandomInterestingPosition(true, Level.PositionType.MainPath, true);
monster = Character.Create(monsterFile, spawnPos, null, GameMain.Client != null);
monster.Enabled = false;
+4 -17
View File
@@ -62,30 +62,17 @@ namespace Barotrauma
private void SpawnMonsters()
{
if (disallowed) return;
float minDist = Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height);
//find a random spawnpos that isn't too close to the main sub
int tries = 0;
Vector2 spawnPos = Vector2.Zero;
do
{
spawnPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType);
tries++;
} while (tries < 50 && Vector2.Distance(spawnPos, Submarine.MainSub.WorldPosition) < minDist);
Vector2 spawnPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType, true);
int amount = Rand.Range(minAmount, maxAmount, false);
monsters = new Character[amount];
if (spawnDeep) spawnPos.Y -= Level.Loaded.Size.Y;
for (int i = 0; i < amount; i++)
{
if (spawnDeep)
{
spawnPos.Y -= Level.Loaded.Size.Y;
}
spawnPos.X += Rand.Range(-0.5f, 0.5f, false);
spawnPos.Y += Rand.Range(-0.5f, 0.5f, false);
monsters[i] = Character.Create(characterFile, spawnPos, null, GameMain.Client != null);