diff --git a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs
index af7b6055c80..f2eb8363411 100644
--- a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs
+++ b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs
@@ -7,7 +7,7 @@
namespace Content.Client.Shuttles.BUI;
[UsedImplicitly]
-public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
+public sealed partial class ShuttleConsoleBoundUserInterface : BoundUserInterface // Frontier: added partial
{
[ViewVariables]
private ShuttleConsoleWindow? _window;
@@ -27,6 +27,7 @@ protected override void Open()
_window.RequestBeaconFTL += OnFTLBeaconRequest;
_window.DockRequest += OnDockRequest;
_window.UndockRequest += OnUndockRequest;
+ NfOpen(); // Frontier
}
private void OnUndockRequest(NetEntity entity)
diff --git a/Content.Client/Shuttles/UI/NavScreen.xaml b/Content.Client/Shuttles/UI/NavScreen.xaml
index 1a1d5747335..28b316d02b0 100644
--- a/Content.Client/Shuttles/UI/NavScreen.xaml
+++ b/Content.Client/Shuttles/UI/NavScreen.xaml
@@ -74,22 +74,48 @@
Text="{controls:Loc 'shuttle-console-dock-toggle'}"
TextAlign="Center"
ToggleMode="True"/>
-
+
+
+
+
+
+
+
-
-
+
+
-
+
+
+ Access="Public"
+ MinValue="0"
+ MaxValue="3000"
+ Value="3000"
+ HorizontalExpand="True"/>
+
+
-
diff --git a/Content.Client/Shuttles/UI/NavScreen.xaml.cs b/Content.Client/Shuttles/UI/NavScreen.xaml.cs
index 2fa34bfcc9b..590d0d196f4 100644
--- a/Content.Client/Shuttles/UI/NavScreen.xaml.cs
+++ b/Content.Client/Shuttles/UI/NavScreen.xaml.cs
@@ -33,12 +33,7 @@ public NavScreen()
DockToggle.OnToggled += OnDockTogglePressed;
DockToggle.Pressed = NavRadar.ShowDocks;
- // Frontier - IFF search
- IffSearchCriteria.OnTextChanged += args => OnIffSearchChanged(args.Text);
-
- // Frontier - Maximum IFF Distance
- MaximumIFFDistanceValue.GetChild(0).GetChild(1).Margin = new Thickness(8,0,0,0);
- MaximumIFFDistanceValue.OnValueChanged += args => OnRangeFilterChanged(args);
+ NfInitialize(); // Frontier Initialization for the NavScreen
}
// Frontier - IFF search
@@ -55,30 +50,11 @@ private void OnIffSearchChanged(string text)
};
}
- // Frontier - Maximum IFF Distance
- private void OnRangeFilterChanged(int value)
- {
- NavRadar.MaximumIFFDistance = (float) value;
- }
-
public void SetShuttle(EntityUid? shuttle)
{
_shuttleEntity = shuttle;
- // Frontier - PR #1284 Add Shuttle Designation
- if (_entManager.TryGetComponent(shuttle, out var metadata))
- {
- var shipNameParts = metadata.EntityName.Split(' ');
- var designation = shipNameParts[^1];
- if (designation.Length > 2 && designation[2] == '-')
- {
- NavDisplayLabel.Text = string.Join(' ', shipNameParts[..^1]);
- ShuttleDesignation.Text = designation;
- }
- else
- NavDisplayLabel.Text = metadata.EntityName;
- }
- // End Frontier - PR #1284
+ NfAddShuttleDesignation(shuttle); // Frontier - PR #1284 Add Shuttle Designation
}
private void OnIFFTogglePressed(BaseButton.ButtonEventArgs args)
@@ -102,6 +78,7 @@ private void OnDockTogglePressed(BaseButton.ButtonEventArgs args)
public void UpdateState(NavInterfaceState scc)
{
NavRadar.UpdateState(scc);
+ NfUpdateState(); // Frontier Update State
}
public void SetMatrix(EntityCoordinates? coordinates, Angle? angle)
diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
index a4b42fb672c..8df3eb4d93e 100644
--- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
+++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
@@ -62,6 +62,8 @@ public ShuttleConsoleWindow()
{
UndockRequest?.Invoke(entity);
};
+
+ NfInitialize(); // Frontier Initialization for the ShuttleConsoleWindow
}
private void ClearModes(ShuttleConsoleMode mode)
diff --git a/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs b/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs
index 19946875fb2..8e5545d29c0 100644
--- a/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs
+++ b/Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs
@@ -1,4 +1,5 @@
using System.Numerics;
+using Content.Client.Station; // Frontier
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Components;
using Content.Shared.Shuttles.Systems;
@@ -7,13 +8,11 @@
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
-using Robust.Shared.Collections;
using Robust.Shared.Input;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
-using Robust.Shared.Utility;
namespace Content.Client.Shuttles.UI;
@@ -22,6 +21,7 @@ public sealed partial class ShuttleNavControl : BaseShuttleControl
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
+ private readonly StationSystem _station; // Frontier
private readonly SharedShuttleSystem _shuttles;
private readonly SharedTransformSystem _transform;
@@ -57,6 +57,7 @@ public ShuttleNavControl() : base(64f, 256f, 256f)
RobustXamlLoader.Load(this);
_shuttles = EntManager.System();
_transform = EntManager.System();
+ _station = EntManager.System(); // Frontier
}
public void SetMatrix(EntityCoordinates? coordinates, Angle? angle)
@@ -117,6 +118,8 @@ public void UpdateState(NavInterfaceState state)
ActualRadarRange = Math.Clamp(ActualRadarRange, WorldMinRange, WorldMaxRange);
_docks = state.Docks;
+
+ NfUpdateState(state); // Frontier Update State
}
protected override void Draw(DrawingHandleScreen handle)
@@ -226,19 +229,7 @@ protected override void Draw(DrawingHandleScreen handle)
shouldDrawIFF &= ShowIFFShuttles;
}
- // New Frontiers - Maximum IFF Distance - checks distance to object, draws if closer than max range
- // This code is licensed under AGPLv3. See AGPLv3.txt
- if (shouldDrawIFF && MaximumIFFDistance >= 0.0f)
- {
- var gridCentre = Vector2.Transform(gridBody.LocalCenter, matty);
- var distance = gridCentre.Length();
-
- if (distance > MaximumIFFDistance)
- {
- shouldDrawIFF = false;
- }
- }
- // End of modified code
+ shouldDrawIFF = NfCheckShouldDrawIffRangeCondition(shouldDrawIFF, gridBody, matty); // Frontier code
if (shouldDrawIFF)
{
@@ -298,17 +289,11 @@ protected override void Draw(DrawingHandleScreen handle)
handle.DrawString(Font, (uiPosition + labelOffset) * UIScale, labelText, UIScale, color);
}
- blipDataList.Add(new BlipData
- {
- IsOutsideRadarCircle = isOutsideRadarCircle,
- UiPosition = uiPosition,
- VectorToPosition = uiPosition - new Vector2(uiXCentre, uiYCentre),
- Color = color
- });
+ NfAddBlipToList(blipDataList, isOutsideRadarCircle, uiPosition, uiXCentre, uiYCentre, color); // Frontier code
}
- // Don't skip drawing blips if they're out of range.
- DrawBlips(handle, blipDataList);
+ // Frontier Don't skip drawing blips if they're out of range.
+ NfDrawBlips(handle, blipDataList);
// Detailed view
var gridAABB = gridMatrix.TransformBox(grid.Comp.LocalAABB);
@@ -379,78 +364,4 @@ public class BlipData
private const int RadarBlipSize = 15;
private const int RadarFontSize = 10;
- /**
- * Frontier - Adds blip style triangles that are on ships or pointing towards ships on the edges of the radar.
- * Draws blips at the BlipData's uiPosition and uses VectorToPosition to rotate to point towards ships.
- */
- private void DrawBlips(
- DrawingHandleBase handle,
- List blipDataList
- )
- {
- var blipValueList = new Dictionary>();
-
- foreach (var blipData in blipDataList)
- {
- var triangleShapeVectorPoints = new[]
- {
- new Vector2(0, 0),
- new Vector2(RadarBlipSize, 0),
- new Vector2(RadarBlipSize * 0.5f, RadarBlipSize)
- };
-
- if (blipData.IsOutsideRadarCircle)
- {
- // Calculate the angle of rotation
- var angle = (float) Math.Atan2(blipData.VectorToPosition.Y, blipData.VectorToPosition.X) + -1.6f;
-
- // Manually create a rotation matrix
- var cos = (float) Math.Cos(angle);
- var sin = (float) Math.Sin(angle);
- float[,] rotationMatrix = { { cos, -sin }, { sin, cos } };
-
- // Rotate each vertex
- for (var i = 0; i < triangleShapeVectorPoints.Length; i++)
- {
- var vertex = triangleShapeVectorPoints[i];
- var x = vertex.X * rotationMatrix[0, 0] + vertex.Y * rotationMatrix[0, 1];
- var y = vertex.X * rotationMatrix[1, 0] + vertex.Y * rotationMatrix[1, 1];
- triangleShapeVectorPoints[i] = new Vector2(x, y);
- }
- }
-
- var triangleCenterVector =
- (triangleShapeVectorPoints[0] + triangleShapeVectorPoints[1] + triangleShapeVectorPoints[2]) / 3;
-
- // Calculate the vectors from the center to each vertex
- var vectorsFromCenter = new Vector2[3];
- for (int i = 0; i < 3; i++)
- {
- vectorsFromCenter[i] = (triangleShapeVectorPoints[i] - triangleCenterVector) * UIScale;
- }
-
- // Calculate the vertices of the new triangle
- var newVerts = new Vector2[3];
- for (var i = 0; i < 3; i++)
- {
- newVerts[i] = (blipData.UiPosition * UIScale) + vectorsFromCenter[i];
- }
-
- if (!blipValueList.TryGetValue(blipData.Color, out var valueList))
- {
- valueList = new ValueList();
-
- }
- valueList.Add(newVerts[0]);
- valueList.Add(newVerts[1]);
- valueList.Add(newVerts[2]);
- blipValueList[blipData.Color] = valueList;
- }
-
- // One draw call for every color we have
- foreach (var color in blipValueList)
- {
- handle.DrawPrimitives(DrawPrimitiveTopology.TriangleList, color.Value.Span, color.Key);
- }
- }
}
diff --git a/Content.Client/_NF/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs b/Content.Client/_NF/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs
new file mode 100644
index 00000000000..715c67f888f
--- /dev/null
+++ b/Content.Client/_NF/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs
@@ -0,0 +1,26 @@
+// New Frontiers - This file is licensed under AGPLv3
+// Copyright (c) 2024 New Frontiers Contributors
+// See AGPLv3.txt for details.
+using Content.Client.Shuttles.UI;
+using Content.Shared._NF.Shuttles.Events;
+
+namespace Content.Client.Shuttles.BUI
+{
+ public sealed partial class ShuttleConsoleBoundUserInterface
+ {
+ private void NfOpen()
+ {
+ _window ??= new ShuttleConsoleWindow();
+ _window.OnInertiaDampeningModeChanged += OnInertiaDampeningModeChanged;
+ }
+ private void OnInertiaDampeningModeChanged(NetEntity? entityUid, InertiaDampeningMode mode)
+ {
+ SendMessage(new SetInertiaDampeningRequest
+ {
+ ShuttleEntityUid = entityUid,
+ Mode = mode,
+ });
+ }
+
+ }
+}
diff --git a/Content.Client/_NF/Shuttles/UI/NavScreen.xaml.cs b/Content.Client/_NF/Shuttles/UI/NavScreen.xaml.cs
new file mode 100644
index 00000000000..25369baddf6
--- /dev/null
+++ b/Content.Client/_NF/Shuttles/UI/NavScreen.xaml.cs
@@ -0,0 +1,83 @@
+// New Frontiers - This file is licensed under AGPLv3
+// Copyright (c) 2024 New Frontiers Contributors
+// See AGPLv3.txt for details.
+using Content.Shared._NF.Shuttles.Events;
+using Robust.Client.UserInterface.Controls;
+
+namespace Content.Client.Shuttles.UI
+{
+ public sealed partial class NavScreen
+ {
+ private readonly ButtonGroup _buttonGroup = new();
+ public event Action? OnInertiaDampeningModeChanged;
+
+ private void NfInitialize()
+ {
+ // Frontier - IFF search
+ IffSearchCriteria.OnTextChanged += args => OnIffSearchChanged(args.Text);
+
+ // Frontier - Maximum IFF Distance
+ MaximumIFFDistanceValue.GetChild(0).GetChild(1).Margin = new Thickness(8, 0, 0, 0);
+ MaximumIFFDistanceValue.OnValueChanged += args => OnRangeFilterChanged(args);
+
+ DampenerOff.OnPressed += _ => SetDampenerMode(InertiaDampeningMode.Off);
+ DampenerOn.OnPressed += _ => SetDampenerMode(InertiaDampeningMode.Dampen);
+ AnchorOn.OnPressed += _ => SetDampenerMode(InertiaDampeningMode.Anchor);
+
+ DampenerOff.Group = _buttonGroup;
+ DampenerOn.Group = _buttonGroup;
+ AnchorOn.Group = _buttonGroup;
+
+ // Send off a request to get the current dampening mode.
+ _entManager.TryGetNetEntity(_shuttleEntity, out var shuttle);
+ OnInertiaDampeningModeChanged?.Invoke(shuttle, InertiaDampeningMode.Query);
+ }
+
+ private void SetDampenerMode(InertiaDampeningMode mode)
+ {
+ NavRadar.DampeningMode = mode;
+ _entManager.TryGetNetEntity(_shuttleEntity, out var shuttle);
+ OnInertiaDampeningModeChanged?.Invoke(shuttle, mode);
+ }
+
+ private void NfUpdateState()
+ {
+ if (NavRadar.DampeningMode == InertiaDampeningMode.Station)
+ {
+ DampenerModeButtons.Visible = false;
+ }
+ else
+ {
+ DampenerModeButtons.Visible = true;
+ DampenerOff.Pressed = NavRadar.DampeningMode == InertiaDampeningMode.Off;
+ DampenerOn.Pressed = NavRadar.DampeningMode == InertiaDampeningMode.Dampen;
+ AnchorOn.Pressed = NavRadar.DampeningMode == InertiaDampeningMode.Anchor;
+ }
+ }
+
+ // Frontier - Maximum IFF Distance
+ private void OnRangeFilterChanged(int value)
+ {
+ NavRadar.MaximumIFFDistance = (float) value;
+ }
+
+ private void NfAddShuttleDesignation(EntityUid? shuttle)
+ {
+ // Frontier - PR #1284 Add Shuttle Designation
+ if (_entManager.TryGetComponent(shuttle, out var metadata))
+ {
+ var shipNameParts = metadata.EntityName.Split(' ');
+ var designation = shipNameParts[^1];
+ if (designation.Length > 2 && designation[2] == '-')
+ {
+ NavDisplayLabel.Text = string.Join(' ', shipNameParts[..^1]);
+ ShuttleDesignation.Text = designation;
+ }
+ else
+ NavDisplayLabel.Text = metadata.EntityName;
+ }
+ // End Frontier - PR #1284
+ }
+
+ }
+}
diff --git a/Content.Client/_NF/Shuttles/UI/ShuttleConsoleWindow.xaml.cs b/Content.Client/_NF/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
new file mode 100644
index 00000000000..7ba3f952b46
--- /dev/null
+++ b/Content.Client/_NF/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
@@ -0,0 +1,21 @@
+// New Frontiers - This file is licensed under AGPLv3
+// Copyright (c) 2024 New Frontiers Contributors
+// See AGPLv3.txt for details.
+using Content.Shared._NF.Shuttles.Events;
+
+namespace Content.Client.Shuttles.UI
+{
+ public sealed partial class ShuttleConsoleWindow
+ {
+ public event Action? OnInertiaDampeningModeChanged;
+
+ private void NfInitialize()
+ {
+ NavContainer.OnInertiaDampeningModeChanged += (entity, mode) =>
+ {
+ OnInertiaDampeningModeChanged?.Invoke(entity, mode);
+ };
+ }
+
+ }
+}
diff --git a/Content.Client/_NF/Shuttles/UI/ShuttleNavControl.xaml.cs b/Content.Client/_NF/Shuttles/UI/ShuttleNavControl.xaml.cs
new file mode 100644
index 00000000000..3520967548e
--- /dev/null
+++ b/Content.Client/_NF/Shuttles/UI/ShuttleNavControl.xaml.cs
@@ -0,0 +1,131 @@
+// New Frontiers - This file is licensed under AGPLv3
+// Copyright (c) 2024 New Frontiers Contributors
+// See AGPLv3.txt for details.
+using Content.Shared._NF.Shuttles.Events;
+using Content.Shared.Shuttles.BUIStates;
+using Robust.Shared.Physics.Components;
+using System.Numerics;
+using Robust.Client.Graphics;
+using Robust.Shared.Collections;
+
+namespace Content.Client.Shuttles.UI
+{
+ public sealed partial class ShuttleNavControl
+ {
+ public InertiaDampeningMode DampeningMode { get; set; }
+
+ private void NfUpdateState(NavInterfaceState state)
+ {
+
+ if (!EntManager.GetCoordinates(state.Coordinates).HasValue ||
+ !EntManager.TryGetComponent(EntManager.GetCoordinates(state.Coordinates).GetValueOrDefault().EntityId,out TransformComponent? transform) ||
+ !EntManager.TryGetComponent(transform.GridUid, out PhysicsComponent? physicsComponent))
+ {
+ return;
+ }
+
+ DampeningMode = state.DampeningMode;
+ }
+
+ // New Frontiers - Maximum IFF Distance - checks distance to object, draws if closer than max range
+ // This code is licensed under AGPLv3. See AGPLv3.txt
+ private bool NfCheckShouldDrawIffRangeCondition(bool shouldDrawIff, PhysicsComponent gridBody, Matrix3x2 matty)
+ {
+ if (shouldDrawIff && MaximumIFFDistance >= 0.0f)
+ {
+ var gridCentre = Vector2.Transform(gridBody.LocalCenter, matty);
+ var distance = gridCentre.Length();
+
+ if (distance > MaximumIFFDistance)
+ {
+ shouldDrawIff = false;
+ }
+ }
+
+ return shouldDrawIff;
+ }
+
+ private static void NfAddBlipToList(List blipDataList, bool isOutsideRadarCircle, Vector2 uiPosition, int uiXCentre, int uiYCentre, Color color)
+ {
+ blipDataList.Add(new BlipData
+ {
+ IsOutsideRadarCircle = isOutsideRadarCircle,
+ UiPosition = uiPosition,
+ VectorToPosition = uiPosition - new Vector2(uiXCentre, uiYCentre),
+ Color = color
+ });
+ }
+
+ /**
+ * Frontier - Adds blip style triangles that are on ships or pointing towards ships on the edges of the radar.
+ * Draws blips at the BlipData's uiPosition and uses VectorToPosition to rotate to point towards ships.
+ */
+ private void NfDrawBlips(DrawingHandleBase handle, List blipDataList)
+ {
+ var blipValueList = new Dictionary>();
+
+ foreach (var blipData in blipDataList)
+ {
+ var triangleShapeVectorPoints = new[]
+ {
+ new Vector2(0, 0),
+ new Vector2(RadarBlipSize, 0),
+ new Vector2(RadarBlipSize * 0.5f, RadarBlipSize)
+ };
+
+ if (blipData.IsOutsideRadarCircle)
+ {
+ // Calculate the angle of rotation
+ var angle = (float) Math.Atan2(blipData.VectorToPosition.Y, blipData.VectorToPosition.X) + -1.6f;
+
+ // Manually create a rotation matrix
+ var cos = (float) Math.Cos(angle);
+ var sin = (float) Math.Sin(angle);
+ float[,] rotationMatrix = { { cos, -sin }, { sin, cos } };
+
+ // Rotate each vertex
+ for (var i = 0; i < triangleShapeVectorPoints.Length; i++)
+ {
+ var vertex = triangleShapeVectorPoints[i];
+ var x = vertex.X * rotationMatrix[0, 0] + vertex.Y * rotationMatrix[0, 1];
+ var y = vertex.X * rotationMatrix[1, 0] + vertex.Y * rotationMatrix[1, 1];
+ triangleShapeVectorPoints[i] = new Vector2(x, y);
+ }
+ }
+
+ var triangleCenterVector =
+ (triangleShapeVectorPoints[0] + triangleShapeVectorPoints[1] + triangleShapeVectorPoints[2]) / 3;
+
+ // Calculate the vectors from the center to each vertex
+ var vectorsFromCenter = new Vector2[3];
+ for (int i = 0; i < 3; i++)
+ {
+ vectorsFromCenter[i] = (triangleShapeVectorPoints[i] - triangleCenterVector) * UIScale;
+ }
+
+ // Calculate the vertices of the new triangle
+ var newVerts = new Vector2[3];
+ for (var i = 0; i < 3; i++)
+ {
+ newVerts[i] = (blipData.UiPosition * UIScale) + vectorsFromCenter[i];
+ }
+
+ if (!blipValueList.TryGetValue(blipData.Color, out var valueList))
+ {
+ valueList = new ValueList();
+
+ }
+ valueList.Add(newVerts[0]);
+ valueList.Add(newVerts[1]);
+ valueList.Add(newVerts[2]);
+ blipValueList[blipData.Color] = valueList;
+ }
+
+ // One draw call for every color we have
+ foreach (var color in blipValueList)
+ {
+ handle.DrawPrimitives(DrawPrimitiveTopology.TriangleList, color.Value.Span, color.Key);
+ }
+ }
+ }
+}
diff --git a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
index 640cb2b52b1..4456bcda03f 100644
--- a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
+++ b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
@@ -3,6 +3,7 @@
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Station.Systems;
+using Content.Shared._NF.Shuttles.Events; // Frontier
using Content.Shared.ActionBlocker;
using Content.Shared.Alert;
using Content.Shared.Popups;
@@ -256,7 +257,7 @@ private void UpdateState(EntityUid consoleUid, ref DockingInterfaceState? dockSt
}
else
{
- navState = new NavInterfaceState(0f, null, null, new Dictionary>());
+ navState = new NavInterfaceState(0f, null, null, new Dictionary>(), InertiaDampeningMode.Dampen); // Frontier: inertia dampening);
mapState = new ShuttleMapInterfaceState(
FTLState.Invalid,
default,
@@ -371,7 +372,7 @@ public void ClearPilots(ShuttleConsoleComponent component)
public NavInterfaceState GetNavState(Entity entity, Dictionary> docks)
{
if (!Resolve(entity, ref entity.Comp1, ref entity.Comp2))
- return new NavInterfaceState(SharedRadarConsoleSystem.DefaultMaxRange, null, null, docks);
+ return new NavInterfaceState(SharedRadarConsoleSystem.DefaultMaxRange, null, null, docks, Shared._NF.Shuttles.Events.InertiaDampeningMode.Dampen); // Frontier: add inertia dampening
return GetNavState(
entity,
@@ -387,13 +388,14 @@ public NavInterfaceState GetNavState(
Angle angle)
{
if (!Resolve(entity, ref entity.Comp1, ref entity.Comp2))
- return new NavInterfaceState(SharedRadarConsoleSystem.DefaultMaxRange, GetNetCoordinates(coordinates), angle, docks);
+ return new NavInterfaceState(SharedRadarConsoleSystem.DefaultMaxRange, GetNetCoordinates(coordinates), angle, docks, InertiaDampeningMode.Dampen); // Frontier: add inertial dampening
return new NavInterfaceState(
entity.Comp1.MaxRange,
GetNetCoordinates(coordinates),
angle,
- docks);
+ docks,
+ _shuttle.NfGetInertiaDampeningMode(entity)); // Frontier: inertia dampening
}
///
diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.cs
index 843e3e82676..4e058fd0f96 100644
--- a/Content.Server/Shuttles/Systems/ShuttleSystem.cs
+++ b/Content.Server/Shuttles/Systems/ShuttleSystem.cs
@@ -76,6 +76,9 @@ public override void Initialize()
SubscribeLocalEvent(OnGridInit);
SubscribeLocalEvent(OnGridFixtureChange);
+
+ NfInitialize(); // Frontier Initialization for the ShuttleSystem
+
}
public override void Update(float frameTime)
diff --git a/Content.Server/_NF/Shuttles/Systems/ShuttleSystem.cs b/Content.Server/_NF/Shuttles/Systems/ShuttleSystem.cs
new file mode 100644
index 00000000000..f027d3cce44
--- /dev/null
+++ b/Content.Server/_NF/Shuttles/Systems/ShuttleSystem.cs
@@ -0,0 +1,86 @@
+// New Frontiers - This file is licensed under AGPLv3
+// Copyright (c) 2024 New Frontiers Contributors
+// See AGPLv3.txt for details.
+using Content.Server._NF.Station.Components;
+using Content.Server.Shuttles.Components;
+using Content.Shared._NF.Shuttles.Events;
+using Content.Shared.Shipyard.Components;
+using Robust.Shared.Physics.Components;
+
+namespace Content.Server.Shuttles.Systems;
+
+public sealed partial class ShuttleSystem
+{
+ private const float SpaceFrictionStrength = 0.0015f;
+ private const float AnchorDampeningStrength = 0.5f;
+ private void NfInitialize()
+ {
+ SubscribeLocalEvent(OnSetInertiaDampening);
+ }
+
+ private void OnSetInertiaDampening(EntityUid uid, ShuttleConsoleComponent component, SetInertiaDampeningRequest args)
+ {
+ // Ensure that the entity requested is a valid shuttle (stations should not be togglable)
+ if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform) ||
+ !transform.GridUid.HasValue ||
+ !EntityManager.TryGetComponent(transform.GridUid, out PhysicsComponent? physicsComponent) ||
+ !EntityManager.TryGetComponent(transform.GridUid, out ShuttleComponent? shuttleComponent))
+ {
+ return;
+ }
+
+ if (args.Mode == InertiaDampeningMode.Query)
+ {
+ _console.RefreshShuttleConsoles(transform.GridUid.Value);
+ return;
+ }
+
+ if (!EntityManager.HasComponent(transform.GridUid) ||
+ EntityManager.HasComponent(_station.GetOwningStation(transform.GridUid)))
+ {
+ return;
+ }
+
+ var linearDampeningStrength = args.Mode switch
+ {
+ InertiaDampeningMode.Off => SpaceFrictionStrength,
+ InertiaDampeningMode.Dampen => shuttleComponent.LinearDamping,
+ InertiaDampeningMode.Anchor => AnchorDampeningStrength,
+ _ => shuttleComponent.LinearDamping, // other values: default to some sane behaviour (assume normal dampening)
+ };
+
+ var angularDampeningStrength = args.Mode switch
+ {
+ InertiaDampeningMode.Off => SpaceFrictionStrength,
+ InertiaDampeningMode.Dampen => shuttleComponent.AngularDamping,
+ InertiaDampeningMode.Anchor => AnchorDampeningStrength,
+ _ => shuttleComponent.AngularDamping, // other values: default to some sane behaviour (assume normal dampening)
+ };
+
+ _physics.SetLinearDamping(transform.GridUid.Value, physicsComponent, linearDampeningStrength);
+ _physics.SetAngularDamping(transform.GridUid.Value, physicsComponent, angularDampeningStrength);
+ _console.RefreshShuttleConsoles(transform.GridUid.Value);
+ }
+
+ public InertiaDampeningMode NfGetInertiaDampeningMode(EntityUid entity)
+ {
+ if (!EntityManager.TryGetComponent(entity, out var xform))
+ return InertiaDampeningMode.Dampen;
+
+ // Not a shuttle, shouldn't be togglable
+ if (!EntityManager.HasComponent(xform.GridUid) ||
+ EntityManager.HasComponent(_station.GetOwningStation(xform.GridUid)))
+ return InertiaDampeningMode.Station;
+
+ if (!EntityManager.TryGetComponent(xform.GridUid, out PhysicsComponent? physicsComponent))
+ return InertiaDampeningMode.Dampen;
+
+ if (physicsComponent.LinearDamping >= AnchorDampeningStrength)
+ return InertiaDampeningMode.Anchor;
+ else if (physicsComponent.LinearDamping <= SpaceFrictionStrength)
+ return InertiaDampeningMode.Off;
+ else
+ return InertiaDampeningMode.Dampen;
+ }
+
+}
diff --git a/Content.Server/_NF/Station/Components/StationDampeningComponent.cs b/Content.Server/_NF/Station/Components/StationDampeningComponent.cs
new file mode 100644
index 00000000000..f6e184077a9
--- /dev/null
+++ b/Content.Server/_NF/Station/Components/StationDampeningComponent.cs
@@ -0,0 +1,10 @@
+// New Frontiers - This file is licensed under AGPLv3
+// Copyright (c) 2024 New Frontiers Contributors
+// See AGPLv3.txt for details.
+
+namespace Content.Server._NF.Station.Components;
+
+[RegisterComponent]
+public sealed partial class StationDampeningComponent : Component
+{
+}
diff --git a/Content.Shared/Shuttles/BUIStates/NavInterfaceState.cs b/Content.Shared/Shuttles/BUIStates/NavInterfaceState.cs
index a6f4c01657d..70716742dd2 100644
--- a/Content.Shared/Shuttles/BUIStates/NavInterfaceState.cs
+++ b/Content.Shared/Shuttles/BUIStates/NavInterfaceState.cs
@@ -1,5 +1,6 @@
using Robust.Shared.Map;
using Robust.Shared.Serialization;
+using Content.Shared._NF.Shuttles.Events; // Frontier - InertiaDampeningMode access
namespace Content.Shared.Shuttles.BUIStates;
@@ -20,16 +21,23 @@ public sealed class NavInterfaceState
public Dictionary> Docks;
+ ///
+ /// Frontier - the state of the shuttle's inertial dampeners
+ ///
+ public InertiaDampeningMode DampeningMode;
+
public NavInterfaceState(
float maxRange,
NetCoordinates? coordinates,
Angle? angle,
- Dictionary> docks)
+ Dictionary> docks,
+ InertiaDampeningMode dampeningMode) // Frontier: add dampeningMode
{
MaxRange = maxRange;
Coordinates = coordinates;
Angle = angle;
Docks = docks;
+ DampeningMode = dampeningMode; // Frontier
}
}
diff --git a/Content.Shared/_NF/Shuttles/Events/SetInertiaDampeningRequest.cs b/Content.Shared/_NF/Shuttles/Events/SetInertiaDampeningRequest.cs
new file mode 100644
index 00000000000..70d7dddabb5
--- /dev/null
+++ b/Content.Shared/_NF/Shuttles/Events/SetInertiaDampeningRequest.cs
@@ -0,0 +1,27 @@
+// New Frontiers - This file is licensed under AGPLv3
+// Copyright (c) 2024 New Frontiers Contributors
+// See AGPLv3.txt for details.
+using Robust.Shared.Serialization;
+
+namespace Content.Shared._NF.Shuttles.Events
+{
+ ///
+ /// Raised on the client when it wishes to change the inertial dampening of a ship.
+ ///
+ [Serializable, NetSerializable]
+ public sealed class SetInertiaDampeningRequest : BoundUserInterfaceMessage
+ {
+ public NetEntity? ShuttleEntityUid { get; set; }
+ public InertiaDampeningMode Mode { get; set; }
+ }
+
+ [Serializable, NetSerializable]
+ public enum InertiaDampeningMode : byte
+ {
+ Off = 0,
+ Dampen = 1,
+ Anchor = 2,
+ Station = 3, // Reserved for station status, should not be used in requests.
+ Query = 255 // Reserved for requests - does not set the mode, only returns its state.
+ }
+}
diff --git a/Resources/Changelog/Changelog.yml b/Resources/Changelog/Changelog.yml
index b352d02cace..ce65edb19f0 100644
--- a/Resources/Changelog/Changelog.yml
+++ b/Resources/Changelog/Changelog.yml
@@ -6115,3 +6115,13 @@ Entries:
message: McCargo now comes with the McDrive Thru for food on the go.
id: 5177
time: '2024-08-07T07:20:01.0000000+00:00'
+- author: neuPanda
+ changes:
+ - type: Add
+ message: Cruise Control
+ - type: Add
+ message: Parking Breaks
+ - type: Fix
+ message: Fixed fun! (your Prada be driftin')
+ id: 5178
+ time: '2024-08-07T12:44:58.0000000+00:00'
diff --git a/Resources/Locale/en-US/_NF/shuttles/console.ftl b/Resources/Locale/en-US/_NF/shuttles/console.ftl
index c2d3c07bf8a..74fb9cc4e1d 100644
--- a/Resources/Locale/en-US/_NF/shuttles/console.ftl
+++ b/Resources/Locale/en-US/_NF/shuttles/console.ftl
@@ -1,3 +1,8 @@
shuttle-console-designation = Designation:
shuttle-console-designation-unknown = Unknown
shuttle-console-maximum-iff-distance = Maximum IFF Distance
+
+shuttle-console-iff-search = Search IFF
+shuttle-console-inertia-dampener-off = Cruise
+shuttle-console-inertia-dampener-dampen = Drive
+shuttle-console-inertia-dampener-anchor = Park
diff --git a/Resources/Locale/en-US/shuttles/console.ftl b/Resources/Locale/en-US/shuttles/console.ftl
index bdc3ef55659..ff14832149c 100644
--- a/Resources/Locale/en-US/shuttles/console.ftl
+++ b/Resources/Locale/en-US/shuttles/console.ftl
@@ -18,8 +18,6 @@ shuttle-console-unknown = Unknown
shuttle-console-iff-label = {$name} ({$distance}m)
shuttle-console-exclusion = Exclusion area
-shuttle-console-iff-search = Search IFF
-
# Buttons
shuttle-console-strafing = Strafing mode
shuttle-console-nav-settings = Settings
diff --git a/Resources/Prototypes/_NF/Shipyard/base.yml b/Resources/Prototypes/_NF/Shipyard/base.yml
index 88f4afbe9a1..20561f5155f 100644
--- a/Resources/Prototypes/_NF/Shipyard/base.yml
+++ b/Resources/Prototypes/_NF/Shipyard/base.yml
@@ -11,6 +11,7 @@
- BaseStationEmpImmune
- BaseStationSectorNews
- BaseStationSectorServices # Hosts all sector-wide services
+ - BaseStationDampening
noSpawn: true
components:
- type: Transform
@@ -22,6 +23,7 @@
- BaseStationJobsSpawning
- BaseStationCargo
- BaseStationSiliconLawFrontierShips
+ - BaseStationDampening
noSpawn: true
components:
- type: Transform
@@ -36,6 +38,7 @@
- BaseStationShuttles # Can spawn shuttles via shipyard consoles
- BaseStationAlertLevels # Has a comms console
- BaseStationSiliconLawFrontierStation # No funny borg laws
+ - BaseStationDampening
noSpawn: true
components:
- type: Transform
@@ -48,6 +51,7 @@
- BaseStationCargo
- BaseStationSiliconLawFrontierShips # TODO: change this with pirate borgs?
- BaseStationRecords
+ - BaseStationDampening
noSpawn: true
components:
- type: Transform
@@ -160,3 +164,9 @@
abstract: true
components:
- type: StationSectorServiceHost
+
+- type: entity
+ id: BaseStationDampening
+ abstract: true
+ components:
+ - type: StationDampening