Artifacts and monsters are allowed to spawn close to the sub if they spawn inside ruins. Fixes "could not find a suitable position" errors in levels where there's only one ruin next to the spawnpos of the sub.

This commit is contained in:
Joonas Rikkonen
2018-01-25 13:58:08 +02:00
parent e6e132aa1e
commit 490e373c7a
2 changed files with 5 additions and 2 deletions
@@ -46,7 +46,9 @@ namespace Barotrauma
public override void Start(Level level) public override void Start(Level level)
{ {
Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 100.0f, Level.Loaded.Size.X * 0.3f, 30.0f); //ruin items are allowed to spawn close to the sub
float minDistance = spawnPositionType == Level.PositionType.Ruin ? 0.0f : Level.Loaded.Size.X * 0.3f;
Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 100.0f, minDistance, 30.0f);
item = new Item(itemPrefab, position, null); item = new Item(itemPrefab, position, null);
item.MoveWithLevel = true; item.MoveWithLevel = true;
@@ -85,7 +85,8 @@ namespace Barotrauma
if (disallowed) return null; if (disallowed) return null;
Vector2 spawnPos; Vector2 spawnPos;
if (!Level.Loaded.TryGetInterestingPosition(true, spawnPosType, 20000.0f, out spawnPos)) float minDist = spawnPosType == Level.PositionType.Ruin ? 0.0f : 20000.0f;
if (!Level.Loaded.TryGetInterestingPosition(true, spawnPosType, minDist, out spawnPos))
{ {
//no suitable position found, disable the event //no suitable position found, disable the event
repeat = false; repeat = false;