Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move vgroid much closer #29943

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Content.Server/Shuttles/Components/GridSpawnComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -67,6 +72,8 @@ public sealed class DungeonSpawnGroup : IGridSpawnGroup
/// <inheritdoc />
public float MinimumDistance { get; }

public float MaximumDistance { get; }

/// <inheritdoc />
public ProtoId<DatasetPrototype>? NameDataset { get; }

Expand Down Expand Up @@ -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;
Expand Down
15 changes: 12 additions & 3 deletions Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Shuttles.Components;
using Robust.Shared.Collections;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Random;
using Robust.Shared.Utility;

Expand Down Expand Up @@ -85,21 +86,29 @@ private void CargoSpawn(EntityUid uid, StationCargoShuttleComponent component)
_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))
{
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);
Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Shuttles/Systems/ShuttleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Entities/Stations/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading