Skip to content

Commit

Permalink
Generate new sector on warp
Browse files Browse the repository at this point in the history
  • Loading branch information
Just-a-Unity-Dev committed Mar 28, 2024
1 parent 6f4e52a commit 94b2bf1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 18 additions & 6 deletions Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public MapId GenerateSector(int maxStars, MapId? startingPoint, bool clear = fal
{
var centerStation = startingPoint ?? GeneratePoint(_prototypeManager.Index<FtlPointPrototype>("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);

Expand Down Expand Up @@ -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++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public sealed class GeneratePointsSystem : GameRuleSystem<GeneratePointsComponen
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly FtlPointsSystem _pointsSystem = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly ShuttleSystem _shuttleSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;

Expand Down Expand Up @@ -53,6 +52,7 @@ private void OnPlayerSpawnEvent(PlayerSpawningEvent ev)
{
var shuttle = EnsureComp<ShuttleComponent>(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))));
Expand Down

0 comments on commit 94b2bf1

Please sign in to comment.