Move vgroid much closer (#29943)

* 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
This commit is contained in:
metalgearsloth
2024-07-28 13:14:18 +10:00
committed by GitHub
parent e3d7c1bd6e
commit 093054f7e3
4 changed files with 29 additions and 4 deletions

View File

@@ -26,6 +26,11 @@ public interface IGridSpawnGroup
/// </summary> /// </summary>
public float MinimumDistance { get; } public float MinimumDistance { get; }
/// <summary>
/// Maximum distance to spawn away from the station.
/// </summary>
public float MaximumDistance { get; }
/// <inheritdoc /> /// <inheritdoc />
public ProtoId<DatasetPrototype>? NameDataset { get; } public ProtoId<DatasetPrototype>? NameDataset { get; }
@@ -67,6 +72,8 @@ public sealed class DungeonSpawnGroup : IGridSpawnGroup
/// <inheritdoc /> /// <inheritdoc />
public float MinimumDistance { get; } public float MinimumDistance { get; }
public float MaximumDistance { get; }
/// <inheritdoc /> /// <inheritdoc />
public ProtoId<DatasetPrototype>? NameDataset { get; } public ProtoId<DatasetPrototype>? NameDataset { get; }
@@ -94,7 +101,11 @@ public sealed class GridSpawnGroup : IGridSpawnGroup
{ {
public List<ResPath> Paths = new(); public List<ResPath> Paths = new();
/// <inheritdoc />
public float MinimumDistance { get; } public float MinimumDistance { get; }
/// <inheritdoc />
public float MaximumDistance { get; }
public ProtoId<DatasetPrototype>? NameDataset { get; } public ProtoId<DatasetPrototype>? NameDataset { get; }
public int MinCount { get; set; } = 1; public int MinCount { get; set; } = 1;
public int MaxCount { get; set; } = 1; public int MaxCount { get; set; } = 1;

View File

@@ -10,6 +10,7 @@ using Content.Shared.Shuttles.Components;
using Content.Shared.Station.Components; using Content.Shared.Station.Components;
using Robust.Shared.Collections; using Robust.Shared.Collections;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -86,9 +87,15 @@ public sealed partial class ShuttleSystem
_mapManager.DeleteMap(mapId); _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; spawned = EntityUid.Invalid;
if (!_gridQuery.Resolve(targetGrid.Owner, ref targetGrid.Comp))
{
return false;
}
var dungeonProtoId = _random.Pick(group.Protos); var dungeonProtoId = _random.Pick(group.Protos);
if (!_protoManager.TryIndex(dungeonProtoId, out var dungeonProto)) if (!_protoManager.TryIndex(dungeonProtoId, out var dungeonProto))
@@ -96,11 +103,13 @@ public sealed partial class ShuttleSystem
return false; 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) 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); var spawnMapCoords = _transform.ToMapCoordinates(spawnCoords);

View File

@@ -58,12 +58,16 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
[Dependency] private readonly ThrusterSystem _thruster = default!; [Dependency] private readonly ThrusterSystem _thruster = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
private EntityQuery<MapGridComponent> _gridQuery;
public const float TileMassMultiplier = 0.5f; public const float TileMassMultiplier = 0.5f;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
_gridQuery = GetEntityQuery<MapGridComponent>();
InitializeFTL(); InitializeFTL();
InitializeGridFills(); InitializeGridFills();
InitializeIFF(); InitializeIFF();

View File

@@ -73,7 +73,8 @@
- /Maps/Ruins/whiteship_ancient.yml - /Maps/Ruins/whiteship_ancient.yml
- /Maps/Ruins/whiteship_bluespacejumper.yml - /Maps/Ruins/whiteship_bluespacejumper.yml
vgroid: !type:DungeonSpawnGroup vgroid: !type:DungeonSpawnGroup
minimumDistance: 1000 minimumDistance: 400
maximumDistance: 450
nameDataset: names_borer nameDataset: names_borer
stationGrid: false stationGrid: false
addComponents: addComponents: