Biome marker layer tweaks (#23663)
* Biome marker layer tweaks - Ensure veins get spawned at great perf cost (it's time-sliced anyway). - Bump asteroids from 6 nodes to 10 nodes. * Fixes * magnet * Magnet dictates wreck spawn * Update Content.Shared/Procedural/PostGeneration/BiomeMarkerLayerPostGen.cs * mraow
This commit is contained in:
@@ -317,20 +317,29 @@ public sealed partial class SalvageSystem
|
||||
}
|
||||
}
|
||||
|
||||
var magnetGridUid = _xformQuery.GetComponent(magnet.Owner).GridUid;
|
||||
Box2 attachedBounds = Box2.Empty;
|
||||
MapId mapId = MapId.Nullspace;
|
||||
var magnetXform = _xformQuery.GetComponent(magnet.Owner);
|
||||
var magnetGridUid = magnetXform.GridUid;
|
||||
var attachedBounds = new Box2Rotated();
|
||||
var mapId = MapId.Nullspace;
|
||||
Angle worldAngle;
|
||||
|
||||
if (magnetGridUid != null)
|
||||
{
|
||||
var magnetGridXform = _xformQuery.GetComponent(magnetGridUid.Value);
|
||||
attachedBounds = _transform.GetWorldMatrix(magnetGridXform)
|
||||
.TransformBox(_gridQuery.GetComponent(magnetGridUid.Value).LocalAABB);
|
||||
var (gridPos, gridRot) = _transform.GetWorldPositionRotation(magnetGridXform);
|
||||
var gridAABB = _gridQuery.GetComponent(magnetGridUid.Value).LocalAABB;
|
||||
|
||||
attachedBounds = new Box2Rotated(gridAABB.Translated(gridPos), gridRot, gridPos);
|
||||
|
||||
worldAngle = (gridRot + magnetXform.LocalRotation) - MathF.PI / 2;
|
||||
mapId = magnetGridXform.MapID;
|
||||
}
|
||||
else
|
||||
{
|
||||
worldAngle = _random.NextAngle();
|
||||
}
|
||||
|
||||
if (!TryGetSalvagePlacementLocation(mapId, attachedBounds, bounds!.Value, out var spawnLocation, out var spawnAngle))
|
||||
if (!TryGetSalvagePlacementLocation(mapId, attachedBounds, bounds!.Value, worldAngle, out var spawnLocation, out var spawnAngle))
|
||||
{
|
||||
Report(magnet.Owner, MagnetChannel, "salvage-system-announcement-spawn-no-debris-available");
|
||||
_mapManager.DeleteMap(salvMap);
|
||||
@@ -376,26 +385,25 @@ public sealed partial class SalvageSystem
|
||||
RaiseLocalEvent(ref active);
|
||||
}
|
||||
|
||||
private bool TryGetSalvagePlacementLocation(MapId mapId, Box2 attachedBounds, Box2 bounds, out MapCoordinates coords, out Angle angle)
|
||||
private bool TryGetSalvagePlacementLocation(MapId mapId, Box2Rotated attachedBounds, Box2 bounds, Angle worldAngle, out MapCoordinates coords, out Angle angle)
|
||||
{
|
||||
const float OffsetRadiusMin = 4f;
|
||||
const float OffsetRadiusMax = 16f;
|
||||
// Grid intersection only does AABB atm.
|
||||
var attachedAABB = attachedBounds.CalcBoundingBox();
|
||||
|
||||
var minDistance = (attachedBounds.Height < attachedBounds.Width ? attachedBounds.Width : attachedBounds.Height) / 2f;
|
||||
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 = attachedBounds.Center;
|
||||
|
||||
angle = _random.NextAngle();
|
||||
var attachedCenter = attachedAABB.Center;
|
||||
var fraction = 0.25f;
|
||||
|
||||
// Thanks 20kdc
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var randomPos = attachedCenter +
|
||||
_random.NextAngle().ToVec() * (minActualDistance +
|
||||
_random.NextFloat(OffsetRadiusMin, OffsetRadiusMax));
|
||||
worldAngle.ToVec() * (minActualDistance * fraction);
|
||||
var finalCoords = new MapCoordinates(randomPos, mapId);
|
||||
|
||||
angle = _random.NextAngle();
|
||||
var box2 = Box2.CenteredAround(finalCoords.Position, bounds.Size);
|
||||
var box2Rot = new Box2Rotated(box2, angle, finalCoords.Position);
|
||||
|
||||
@@ -404,7 +412,7 @@ public sealed partial class SalvageSystem
|
||||
if (_mapManager.FindGridsIntersecting(finalCoords.MapId, box2Rot).Any())
|
||||
{
|
||||
// Bump it further and further just in case.
|
||||
minActualDistance += 4f;
|
||||
fraction += 0.25f;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -412,6 +420,7 @@ public sealed partial class SalvageSystem
|
||||
return true;
|
||||
}
|
||||
|
||||
angle = Angle.Zero;
|
||||
coords = MapCoordinates.Nullspace;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user