From 503883a885846cd02dfd4b5f8c0f19d15deb14d3 Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 28 Aug 2016 20:28:24 +0300 Subject: [PATCH] Artifacts are spread out better throughout the levels --- Subsurface/Source/Events/ArtifactEvent.cs | 3 ++- .../Source/Events/Missions/SalvageMission.cs | 2 +- Subsurface/Source/Map/Levels/Level.cs | 15 +++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Subsurface/Source/Events/ArtifactEvent.cs b/Subsurface/Source/Events/ArtifactEvent.cs index 2ce06c449..70767c0c5 100644 --- a/Subsurface/Source/Events/ArtifactEvent.cs +++ b/Subsurface/Source/Events/ArtifactEvent.cs @@ -31,7 +31,8 @@ namespace Barotrauma protected override void Start() { - Vector2 position = Level.Loaded.GetRandomItemPos(Level.PositionType.Cave, 30.0f); + Vector2 position = Level.Loaded.GetRandomItemPos( + Level.PositionType.Cave | Level.PositionType.MainPath | Level.PositionType.Ruin, 500.0f, 30.0f); item = new Item(itemPrefab, position, null); item.MoveWithLevel = true; diff --git a/Subsurface/Source/Events/Missions/SalvageMission.cs b/Subsurface/Source/Events/Missions/SalvageMission.cs index 5751ee291..74f7b65c7 100644 --- a/Subsurface/Source/Events/Missions/SalvageMission.cs +++ b/Subsurface/Source/Events/Missions/SalvageMission.cs @@ -49,7 +49,7 @@ namespace Barotrauma public override void Start(Level level) { - Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 30.0f); + Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 100.0f, 30.0f); item = new Item(itemPrefab, position, null); item.MoveWithLevel = true; diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 5f30db6fc..2fb7dbe02 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -203,11 +203,6 @@ namespace Barotrauma pathNodes.Add(new Vector2(x, Rand.Range(pathBorders.Y, pathBorders.Bottom, false))); } - for (int i = 2; i < pathNodes.Count; i+=3 ) - { - positionsOfInterest.Add(new InterestingPosition(pathNodes[i], PositionType.MainPath)); - } - pathNodes.Add(endPosition); pathNodes.Add(new Vector2(endPosition.X, borders.Height)); @@ -277,6 +272,12 @@ namespace Barotrauma List mainPath = CaveGenerator.GeneratePath(pathNodes, cells, cellGrid, GridCellSize, new Rectangle(pathBorders.X, pathBorders.Y, pathBorders.Width, borders.Height), 0.3f, mirror); + + for (int i = 2; i < mainPath.Count; i += 3) + { + positionsOfInterest.Add(new InterestingPosition(mainPath[i].Center, PositionType.MainPath)); + } + List pathCells = new List(mainPath); EnlargeMainPath(pathCells, minWidth); @@ -734,7 +735,7 @@ namespace Barotrauma return newCells; } - public Vector2 GetRandomItemPos(PositionType spawnPosType, float offsetFromWall = 10.0f) + public Vector2 GetRandomItemPos(PositionType spawnPosType, float randomSpread, float offsetFromWall = 10.0f) { if (!positionsOfInterest.Any()) return Size*0.5f; @@ -746,6 +747,8 @@ namespace Barotrauma do { Vector2 startPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType); + + startPos += Rand.Vector(Rand.Range(0.0f, randomSpread, false), false); Vector2 endPos = startPos - Vector2.UnitY * Size.Y;