diff --git a/Content.Server/Salvage/Magnet/SalvageMagnetComponent.cs b/Content.Server/Salvage/Magnet/SalvageMagnetComponent.cs index 6c1abf3654..5dd5f1ca80 100644 --- a/Content.Server/Salvage/Magnet/SalvageMagnetComponent.cs +++ b/Content.Server/Salvage/Magnet/SalvageMagnetComponent.cs @@ -3,5 +3,16 @@ namespace Content.Server.Salvage.Magnet; [RegisterComponent] public sealed partial class SalvageMagnetComponent : Component { + /// + /// The max distance at which the magnet will pull in wrecks. + /// Scales from 50% to 100%. + /// + [DataField] + public float MagnetSpawnDistance = 128f; + /// + /// How far offset to either side will the magnet wreck spawn. + /// + [DataField] + public float LateralOffset = 32f; } diff --git a/Content.Server/Salvage/SalvageSystem.Magnet.cs b/Content.Server/Salvage/SalvageSystem.Magnet.cs index 5e85fdb573..57a57d3c63 100644 --- a/Content.Server/Salvage/SalvageSystem.Magnet.cs +++ b/Content.Server/Salvage/SalvageSystem.Magnet.cs @@ -338,7 +338,7 @@ public sealed partial class SalvageSystem worldAngle = _random.NextAngle(); } - if (!TryGetSalvagePlacementLocation(mapId, attachedBounds, bounds!.Value, worldAngle, out var spawnLocation, out var spawnAngle)) + if (!TryGetSalvagePlacementLocation(magnet, mapId, attachedBounds, bounds!.Value, worldAngle, out var spawnLocation, out var spawnAngle)) { Report(magnet.Owner, MagnetChannel, "salvage-system-announcement-spawn-no-debris-available"); _mapManager.DeleteMap(salvMapXform.MapID); @@ -390,22 +390,19 @@ public sealed partial class SalvageSystem RaiseLocalEvent(ref active); } - private bool TryGetSalvagePlacementLocation(MapId mapId, Box2Rotated attachedBounds, Box2 bounds, Angle worldAngle, out MapCoordinates coords, out Angle angle) + private bool TryGetSalvagePlacementLocation(Entity magnet, MapId mapId, Box2Rotated attachedBounds, Box2 bounds, Angle worldAngle, out MapCoordinates coords, out Angle angle) { - // Grid intersection only does AABB atm. var attachedAABB = attachedBounds.CalcBoundingBox(); - - var minDistance = (attachedAABB.Height < attachedAABB.Width ? attachedAABB.Width : attachedAABB.Height) / 2f; - var minActualDistance = bounds.Height < bounds.Width ? minDistance + bounds.Width / 2f : minDistance + bounds.Height / 2f; - - var attachedCenter = attachedAABB.Center; - var fraction = 0.25f; + var magnetPos = _transform.GetWorldPosition(magnet) + worldAngle.ToVec() * bounds.MaxDimension; + var origin = attachedAABB.ClosestPoint(magnetPos); + var fraction = 0.50f; // Thanks 20kdc for (var i = 0; i < 20; i++) { - var randomPos = attachedCenter + - worldAngle.ToVec() * (minActualDistance * fraction); + var randomPos = origin + + worldAngle.ToVec() * (magnet.Comp.MagnetSpawnDistance * fraction) + + (worldAngle + Math.PI / 2).ToVec() * _random.NextFloat(-magnet.Comp.LateralOffset, magnet.Comp.LateralOffset); var finalCoords = new MapCoordinates(randomPos, mapId); angle = _random.NextAngle(); @@ -417,7 +414,7 @@ public sealed partial class SalvageSystem if (_mapManager.FindGridsIntersecting(finalCoords.MapId, box2Rot).Any()) { // Bump it further and further just in case. - fraction += 0.25f; + fraction += 0.1f; continue; } diff --git a/Resources/Prototypes/Entities/Stations/base.yml b/Resources/Prototypes/Entities/Stations/base.yml index 35c8ec9292..4d1114d285 100644 --- a/Resources/Prototypes/Entities/Stations/base.yml +++ b/Resources/Prototypes/Entities/Stations/base.yml @@ -84,8 +84,8 @@ - /Maps/Ruins/DeltaV/whiteship_ancient.yml #Delta V - Move to DV folder - /Maps/Ruins/DeltaV/whiteship_bluespacejumper.yml #Delta V - Move to DV folder vgroid: !type:DungeonSpawnGroup - minimumDistance: 400 - maximumDistance: 450 + minimumDistance: 300 + maximumDistance: 350 nameDataset: names_borer stationGrid: false addComponents: