hopefully make salvage more reliable (#17712)
This commit is contained in:
@@ -19,7 +19,6 @@ using Content.Server.Parallax;
|
|||||||
using Content.Server.Procedural;
|
using Content.Server.Procedural;
|
||||||
using Content.Server.Shuttles.Systems;
|
using Content.Server.Shuttles.Systems;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
using Content.Server.Worldgen.Systems;
|
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Random;
|
using Content.Shared.Random;
|
||||||
using Content.Shared.Random.Helpers;
|
using Content.Shared.Random.Helpers;
|
||||||
@@ -51,7 +50,7 @@ namespace Content.Server.Salvage
|
|||||||
[Dependency] private readonly StationSystem _station = default!;
|
[Dependency] private readonly StationSystem _station = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
|
|
||||||
private const int SalvageLocationPlaceAttempts = 16;
|
private const int SalvageLocationPlaceAttempts = 25;
|
||||||
|
|
||||||
// TODO: This is probably not compatible with multi-station
|
// TODO: This is probably not compatible with multi-station
|
||||||
private readonly Dictionary<EntityUid, SalvageGridState> _salvageGridStates = new();
|
private readonly Dictionary<EntityUid, SalvageGridState> _salvageGridStates = new();
|
||||||
@@ -307,8 +306,13 @@ namespace Content.Server.Salvage
|
|||||||
private bool TryGetSalvagePlacementLocation(EntityUid uid, SalvageMagnetComponent component, Box2 bounds, out MapCoordinates coords, out Angle angle)
|
private bool TryGetSalvagePlacementLocation(EntityUid uid, SalvageMagnetComponent component, Box2 bounds, out MapCoordinates coords, out Angle angle)
|
||||||
{
|
{
|
||||||
var xform = Transform(uid);
|
var xform = Transform(uid);
|
||||||
|
var smallestBound = (bounds.Height < bounds.Width
|
||||||
|
? bounds.Height
|
||||||
|
: bounds.Width) / 2f;
|
||||||
|
var maxRadius = component.OffsetRadiusMax + smallestBound;
|
||||||
|
|
||||||
angle = Angle.Zero;
|
angle = Angle.Zero;
|
||||||
coords = new EntityCoordinates(uid, new Vector2(0, -component.OffsetRadiusMax)).ToMap(EntityManager, _transform);
|
coords = new EntityCoordinates(uid, new Vector2(0, -maxRadius)).ToMap(EntityManager, _transform);
|
||||||
|
|
||||||
if (xform.GridUid is not null)
|
if (xform.GridUid is not null)
|
||||||
angle = _transform.GetWorldRotation(Transform(xform.GridUid.Value));
|
angle = _transform.GetWorldRotation(Transform(xform.GridUid.Value));
|
||||||
@@ -316,8 +320,8 @@ namespace Content.Server.Salvage
|
|||||||
for (var i = 0; i < SalvageLocationPlaceAttempts; i++)
|
for (var i = 0; i < SalvageLocationPlaceAttempts; i++)
|
||||||
{
|
{
|
||||||
var randomRadius = _random.NextFloat(component.OffsetRadiusMax);
|
var randomRadius = _random.NextFloat(component.OffsetRadiusMax);
|
||||||
var randomOffset = _random.NextAngle().ToWorldVec() * randomRadius;
|
var randomOffset = _random.NextAngle().ToVec() * randomRadius;
|
||||||
var finalCoords = coords.Offset(randomOffset);
|
var finalCoords = new MapCoordinates(coords.Position + randomOffset, coords.MapId);
|
||||||
|
|
||||||
var box2 = Box2.CenteredAround(finalCoords.Position, bounds.Size);
|
var box2 = Box2.CenteredAround(finalCoords.Position, bounds.Size);
|
||||||
var box2Rot = new Box2Rotated(box2, angle, finalCoords.Position);
|
var box2Rot = new Box2Rotated(box2, angle, finalCoords.Position);
|
||||||
|
|||||||
Reference in New Issue
Block a user