Salvage expeditions (#12745)
This commit is contained in:
@@ -6,4 +6,4 @@ namespace Content.Server.Shuttles.Events;
|
||||
/// Raised when <see cref="ShuttleSystem.FasterThanLight"/> has completed FTL Travel.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly record struct FTLCompletedEvent;
|
||||
public readonly record struct FTLCompletedEvent(EntityUid Entity, EntityUid MapUid);
|
||||
|
||||
7
Content.Server/Shuttles/Events/FTLRequestEvent.cs
Normal file
7
Content.Server/Shuttles/Events/FTLRequestEvent.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised by a shuttle when it has requested an FTL.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct FTLRequestEvent(EntityUid MapUid);
|
||||
@@ -6,4 +6,4 @@ namespace Content.Server.Shuttles.Events;
|
||||
/// Raised when a shuttle has moved to FTL space.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly record struct FTLStartedEvent(EntityUid? FromMapUid, Matrix3 FTLFrom, Angle FromRotation);
|
||||
public readonly record struct FTLStartedEvent(EntityUid Entity, EntityCoordinates TargetCoordinates, EntityUid? FromMapUid, Matrix3 FTLFrom, Angle FromRotation);
|
||||
|
||||
@@ -150,6 +150,8 @@ public sealed partial class ShuttleSystem
|
||||
hyperspace.Dock = false;
|
||||
hyperspace.PriorityTag = priorityTag;
|
||||
_console.RefreshShuttleConsoles();
|
||||
var ev = new FTLRequestEvent(_mapManager.GetMapEntityId(coordinates.ToMap(EntityManager, _transform).MapId));
|
||||
RaiseLocalEvent(shuttleUid, ref ev, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -249,8 +251,10 @@ public sealed partial class ShuttleSystem
|
||||
|
||||
SetDockBolts(uid, true);
|
||||
_console.RefreshShuttleConsoles(uid);
|
||||
var ev = new FTLStartedEvent(fromMapUid, fromMatrix, fromRotation);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
var target = comp.TargetUid != null ? new EntityCoordinates(comp.TargetUid.Value, Vector2.Zero) : comp.TargetCoordinates;
|
||||
|
||||
var ev = new FTLStartedEvent(uid, target, fromMapUid, fromMatrix, fromRotation);
|
||||
RaiseLocalEvent(uid, ref ev, true);
|
||||
|
||||
if (comp.TravelSound != null)
|
||||
{
|
||||
@@ -344,7 +348,7 @@ public sealed partial class ShuttleSystem
|
||||
comp.Accumulator += FTLCooldown;
|
||||
_console.RefreshShuttleConsoles(uid);
|
||||
_mapManager.SetMapPaused(mapId, false);
|
||||
var ftlEvent = new FTLCompletedEvent();
|
||||
var ftlEvent = new FTLCompletedEvent(uid, _mapManager.GetMapEntityId(mapId));
|
||||
RaiseLocalEvent(uid, ref ftlEvent, true);
|
||||
break;
|
||||
case FTLState.Cooldown:
|
||||
@@ -499,6 +503,7 @@ public sealed partial class ShuttleSystem
|
||||
public bool TryFTLProximity(EntityUid shuttleUid, ShuttleComponent component, EntityUid targetUid, TransformComponent? xform = null, TransformComponent? targetXform = null)
|
||||
{
|
||||
if (!Resolve(targetUid, ref targetXform) ||
|
||||
targetXform.GridUid == null ||
|
||||
targetXform.MapUid == null ||
|
||||
!targetXform.MapUid.Value.IsValid() ||
|
||||
!Resolve(shuttleUid, ref xform))
|
||||
@@ -592,6 +597,23 @@ public sealed partial class ShuttleSystem
|
||||
spawnPos = _transform.GetWorldPosition(targetXform, xformQuery);
|
||||
}
|
||||
|
||||
// TODO: This is pretty crude for multiple landings.
|
||||
if (nearbyGrids.Count > 1 || !HasComp<MapComponent>(targetXform.GridUid.Value))
|
||||
{
|
||||
var minRadius = (MathF.Max(targetAABB.Width, targetAABB.Height) + MathF.Max(shuttleAABB.Width, shuttleAABB.Height)) / 2f;
|
||||
spawnPos = targetAABB.Center + _random.NextVector2(minRadius, minRadius + 64f);
|
||||
}
|
||||
else if (shuttleBody != null)
|
||||
{
|
||||
var (targetPos, targetRot) = _transform.GetWorldPositionRotation(targetXform, xformQuery);
|
||||
var transform = new Transform(targetPos, targetRot);
|
||||
spawnPos = Robust.Shared.Physics.Transform.Mul(transform, -shuttleBody.LocalCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnPos = _transform.GetWorldPosition(targetXform, xformQuery);
|
||||
}
|
||||
|
||||
xform.Coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos);
|
||||
|
||||
if (!HasComp<MapComponent>(targetXform.GridUid))
|
||||
|
||||
Reference in New Issue
Block a user