]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Move vgroid much closer (#29943)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 28 Jul 2024 03:14:18 +0000 (13:14 +1000)
committerGitHub <noreply@github.com>
Sun, 28 Jul 2024 03:14:18 +0000 (13:14 +1000)
* Move vgroid much closer

General feedback is map spam + it takes too long to get to. This is somewhat "close" (considering 1/4 of the distance is the vgroid itself) but without a jetpack / shuttle it's going to be an endeavour.

* Decrease max

* Tweaks

* godzilla

* Update Content.Server/Shuttles/Components/GridSpawnComponent.cs

Content.Server/Shuttles/Components/GridSpawnComponent.cs
Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
Content.Server/Shuttles/Systems/ShuttleSystem.cs
Resources/Prototypes/Entities/Stations/base.yml

index d8144354b8e7e88be321d135ed6a272e77c4f45e..430c9c8df285c60551534235c2068c475c0b6c74 100644 (file)
@@ -26,6 +26,11 @@ public interface IGridSpawnGroup
     /// </summary>
     public float MinimumDistance { get; }
 
+    /// <summary>
+    /// Maximum distance to spawn away from the station.
+    /// </summary>
+    public float MaximumDistance { get;  }
+
     /// <inheritdoc />
     public ProtoId<DatasetPrototype>? NameDataset { get; }
 
@@ -67,6 +72,8 @@ public sealed class DungeonSpawnGroup : IGridSpawnGroup
     /// <inheritdoc />
     public float MinimumDistance { get; }
 
+    public float MaximumDistance { get; }
+
     /// <inheritdoc />
     public ProtoId<DatasetPrototype>? NameDataset { get; }
 
@@ -94,7 +101,11 @@ public sealed class GridSpawnGroup : IGridSpawnGroup
 {
     public List<ResPath> Paths = new();
 
+    /// <inheritdoc />
     public float MinimumDistance { get; }
+
+    /// <inheritdoc />
+    public float MaximumDistance { get; }
     public ProtoId<DatasetPrototype>? NameDataset { get; }
     public int MinCount { get; set; } = 1;
     public int MaxCount { get; set; } = 1;
index 0976bc5de1c4c6ce673a2f901bb76d6cd6f75d7e..a31fda074f3621a183975497bbfdff03f85c135c 100644 (file)
@@ -10,6 +10,7 @@ using Content.Shared.Shuttles.Components;
 using Content.Shared.Station.Components;
 using Robust.Shared.Collections;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Random;
 using Robust.Shared.Utility;
 
@@ -86,9 +87,15 @@ public sealed partial class ShuttleSystem
         _mapManager.DeleteMap(mapId);
     }
 
-    private bool TryDungeonSpawn(EntityUid targetGrid, EntityUid stationUid, MapId mapId, DungeonSpawnGroup group, out EntityUid spawned)
+    private bool TryDungeonSpawn(Entity<MapGridComponent?> targetGrid, EntityUid stationUid, MapId mapId, DungeonSpawnGroup group, out EntityUid spawned)
     {
         spawned = EntityUid.Invalid;
+
+        if (!_gridQuery.Resolve(targetGrid.Owner, ref targetGrid.Comp))
+        {
+            return false;
+        }
+
         var dungeonProtoId = _random.Pick(group.Protos);
 
         if (!_protoManager.TryIndex(dungeonProtoId, out var dungeonProto))
@@ -96,11 +103,13 @@ public sealed partial class ShuttleSystem
             return false;
         }
 
-        var spawnCoords = new EntityCoordinates(targetGrid, Vector2.Zero);
+        var targetPhysics = _physicsQuery.Comp(targetGrid);
+        var spawnCoords = new EntityCoordinates(targetGrid, targetPhysics.LocalCenter);
 
         if (group.MinimumDistance > 0f)
         {
-            spawnCoords = spawnCoords.Offset(_random.NextVector2(group.MinimumDistance, group.MinimumDistance * 1.5f));
+            var distancePadding = MathF.Max(targetGrid.Comp.LocalAABB.Width, targetGrid.Comp.LocalAABB.Height);
+            spawnCoords = spawnCoords.Offset(_random.NextVector2(distancePadding + group.MinimumDistance, distancePadding + group.MaximumDistance));
         }
 
         var spawnMapCoords = _transform.ToMapCoordinates(spawnCoords);
index 85703389e9dec72e9e9a6f3c5c475d317ba98fac..aae466ba0dccbd4c4281fe18261750ffa1103f83 100644 (file)
@@ -58,12 +58,16 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
     [Dependency] private readonly ThrusterSystem _thruster = default!;
     [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
 
+    private EntityQuery<MapGridComponent> _gridQuery;
+
     public const float TileMassMultiplier = 0.5f;
 
     public override void Initialize()
     {
         base.Initialize();
 
+        _gridQuery = GetEntityQuery<MapGridComponent>();
+
         InitializeFTL();
         InitializeGridFills();
         InitializeIFF();
index c7b54f457170baf0e76c13ed00c580bf0fece03d..de191277aef71a2d10d3ec89e4402ea4f7d78b03 100644 (file)
@@ -73,7 +73,8 @@
           - /Maps/Ruins/whiteship_ancient.yml
           - /Maps/Ruins/whiteship_bluespacejumper.yml
         vgroid: !type:DungeonSpawnGroup
-          minimumDistance: 1000
+          minimumDistance: 400
+          maximumDistance: 450
           nameDataset: names_borer
           stationGrid: false
           addComponents: