From 94b2bf108dec1132c128f06f235bf3c9b13e54c2 Mon Sep 17 00:00:00 2001 From: Just-a-Unity-Dev <67359748+Just-a-Unity-Dev@users.noreply.github.com> Date: Thu, 28 Mar 2024 22:41:18 +0800 Subject: [PATCH] Generate new sector on warp --- .../_FTL/FTLPoints/Systems/FtlPointsSystem.cs | 24 ++++++++++++++----- .../GeneratePoints/GeneratePointsSystem.cs | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.cs b/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.cs index 6a37fadf63..a603ff8aa9 100644 --- a/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.cs +++ b/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.cs @@ -70,6 +70,17 @@ public MapId GenerateSector(int maxStars, MapId? startingPoint, bool clear = fal { var centerStation = startingPoint ?? GeneratePoint(_prototypeManager.Index("StationPoint")); + StarMapComponent? component = null; + if (!TryGetStarMap(ref component)) + return MapId.Nullspace; + + var availableStars = component.StarMap.Where(x => x.Map == centerStation).ToList(); + + foreach (var star in availableStars) + { + component.StarMap.Remove(star); + } + if (clear) RemoveAllStars(deleteStars); @@ -101,19 +112,20 @@ public MapId GenerateSector(int maxStars, MapId? startingPoint, bool clear = fal var mapId = GeneratePoint(prototype); var mapUid = _mapManager.GetMapEntityId(mapId); var position = new Vector2( - origin.X + GenerateVectorWithRandomRadius(3, 5), - origin.Y + GenerateVectorWithRandomRadius(3, 5) + origin.X + _random.NextFloat(6, 8.5f), + origin.Y + _random.NextFloat(6, 8.5f) ); if (first) { position = new Vector2( - origin.X + _random.NextFloat(6, 8.5f), - origin.Y + _random.NextFloat(6, 8.5f) + origin.X + GenerateVectorWithRandomRadius(3, 5), + origin.Y + GenerateVectorWithRandomRadius(3, 5) ); } - TryAddPoint(mapId, position, MetaData(mapUid).EntityName); - _mapManager.SetMapPaused(mapId, false); + + if (first) + _mapManager.SetMapPaused(mapId, false); latestGeneration.Add(position); } starsCreated++; diff --git a/Content.Server/_FTL/ShipTracker/Rules/GeneratePoints/GeneratePointsSystem.cs b/Content.Server/_FTL/ShipTracker/Rules/GeneratePoints/GeneratePointsSystem.cs index f08f158c7f..2169ac64f0 100644 --- a/Content.Server/_FTL/ShipTracker/Rules/GeneratePoints/GeneratePointsSystem.cs +++ b/Content.Server/_FTL/ShipTracker/Rules/GeneratePoints/GeneratePointsSystem.cs @@ -21,7 +21,6 @@ public sealed class GeneratePointsSystem : GameRuleSystem(grid.Value); // _shuttleSystem.FTLTravel(grid.Value, shuttle, _mapManager.GetMapEntityId(station)); + _mapManager.SetMapPaused(station, false); _transformSystem.SetCoordinates(grid.Value, new EntityCoordinates(_mapManager.GetMapEntityId(station), new Vector2(_pointsSystem.GenerateVectorWithRandomRadius(100, 600), _pointsSystem.GenerateVectorWithRandomRadius(100, 600))));