Announce shuttle direction on proximity (#9885)
This commit is contained in:
@@ -254,24 +254,13 @@ public sealed partial class ShuttleSystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
if (TryFTLDock(shuttle, targetGrid.Value))
|
if (TryFTLDock(shuttle, targetGrid.Value))
|
||||||
{
|
{
|
||||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
|
||||||
|
|
||||||
if (TryComp<TransformComponent>(targetGrid.Value, out var targetXform))
|
if (TryComp<TransformComponent>(targetGrid.Value, out var targetXform))
|
||||||
{
|
{
|
||||||
var (shuttlePos, shuttleRot) = xform.GetWorldPositionRotation(xformQuery);
|
var angle = GetAngle(xform, targetXform, xformQuery);
|
||||||
var (targetPos, targetRot) = targetXform.GetWorldPositionRotation(xformQuery);
|
|
||||||
|
|
||||||
var shuttleCOM = Robust.Shared.Physics.Transform.Mul(new Transform(shuttlePos, shuttleRot),
|
|
||||||
Comp<PhysicsComponent>(shuttle.Owner).LocalCenter);
|
|
||||||
var targetCOM = Robust.Shared.Physics.Transform.Mul(new Transform(targetPos, targetRot),
|
|
||||||
Comp<PhysicsComponent>(targetGrid.Value).LocalCenter);
|
|
||||||
|
|
||||||
var mapDiff = shuttleCOM - targetCOM;
|
|
||||||
var targetRotation = targetRot;
|
|
||||||
var angle = mapDiff.ToWorldAngle();
|
|
||||||
angle -= targetRotation;
|
|
||||||
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", angle.GetDir())), playDefaultSound: false);
|
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", angle.GetDir())), playDefaultSound: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,13 +270,35 @@ public sealed partial class ShuttleSystem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (TryComp<TransformComponent>(targetGrid.Value, out var targetXform))
|
||||||
|
{
|
||||||
|
var angle = GetAngle(xform, targetXform, xformQuery);
|
||||||
|
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-nearby", ("direction", angle.GetDir())), playDefaultSound: false);
|
||||||
|
}
|
||||||
|
|
||||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid.Value)} unable to find a valid docking port for {ToPrettyString(stationUid.Value)}");
|
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid.Value)} unable to find a valid docking port for {ToPrettyString(stationUid.Value)}");
|
||||||
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-nearby"), playDefaultSound: false);
|
|
||||||
// TODO: Need filter extensions or something don't blame me.
|
// TODO: Need filter extensions or something don't blame me.
|
||||||
SoundSystem.Play("/Audio/Misc/notice1.ogg", Filter.Broadcast());
|
SoundSystem.Play("/Audio/Misc/notice1.ogg", Filter.Broadcast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Angle GetAngle(TransformComponent xform, TransformComponent targetXform, EntityQuery<TransformComponent> xformQuery)
|
||||||
|
{
|
||||||
|
var (shuttlePos, shuttleRot) = xform.GetWorldPositionRotation(xformQuery);
|
||||||
|
var (targetPos, targetRot) = targetXform.GetWorldPositionRotation(xformQuery);
|
||||||
|
|
||||||
|
var shuttleCOM = Robust.Shared.Physics.Transform.Mul(new Transform(shuttlePos, shuttleRot),
|
||||||
|
Comp<PhysicsComponent>(xform.Owner).LocalCenter);
|
||||||
|
var targetCOM = Robust.Shared.Physics.Transform.Mul(new Transform(targetPos, targetRot),
|
||||||
|
Comp<PhysicsComponent>(targetXform.Owner).LocalCenter);
|
||||||
|
|
||||||
|
var mapDiff = shuttleCOM - targetCOM;
|
||||||
|
var targetRotation = targetRot;
|
||||||
|
var angle = mapDiff.ToWorldAngle();
|
||||||
|
angle -= targetRotation;
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if 2 docks can be connected by moving the shuttle directly onto docks.
|
/// Checks if 2 docks can be connected by moving the shuttle directly onto docks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ emergency-shuttle-left = The Emergency Shuttle has left the station. Estimate {$
|
|||||||
emergency-shuttle-launch-time = The emergency shuttle will launch in {$consoleAccumulator} seconds.
|
emergency-shuttle-launch-time = The emergency shuttle will launch in {$consoleAccumulator} seconds.
|
||||||
emergency-shuttle-docked = The Emergency Shuttle has docked with the station on the {$direction} side. It will leave in {$time} seconds.
|
emergency-shuttle-docked = The Emergency Shuttle has docked with the station on the {$direction} side. It will leave in {$time} seconds.
|
||||||
emergency-shuttle-good-luck = The Emergency Shuttle is unable to find a station. Good luck.
|
emergency-shuttle-good-luck = The Emergency Shuttle is unable to find a station. Good luck.
|
||||||
emergency-shuttle-nearby = The Emergency Shuttle is unable to find a valid docking port. It has warped in nearby.
|
emergency-shuttle-nearby = The Emergency Shuttle is unable to find a valid docking port. It has warped in {$direction} of the station.
|
||||||
|
|
||||||
# Emergency shuttle console popup / announcement
|
# Emergency shuttle console popup / announcement
|
||||||
emergency-shuttle-console-auth-left = {$remaining} authorizations needed until shuttle is launched early.
|
emergency-shuttle-console-auth-left = {$remaining} authorizations needed until shuttle is launched early.
|
||||||
|
|||||||
Reference in New Issue
Block a user