Skip to content

Commit

Permalink
Inertia dampeners (#1620)
Browse files Browse the repository at this point in the history
* Inertia dampeners Initial push
need to disable buttons
need to look into issue with max speed diagonal flying and changing directions

* adding new station component
hide the anchoring buttons on stations (exploit prevention)
apply station component to all POI's

* navscreen, StationComp->StationDampeningComp

* StationDampeningComp, "anchor" tense

* restore needed using statement

* Server-based dampening state

* fix entity in NfGetInertialDampeningMode

* past tense event, whitespace, comments

* ToggleStabilizer->SetInertiaDampening

* ShuttleSystem: check for shuttle deed

* Default dampening value: off->dampen

* Inertia dampeners Initial push
need to disable buttons
need to look into issue with max speed diagonal flying and changing directions

* adding new station component
hide the anchoring buttons on stations (exploit prevention)
apply station component to all POI's

* ShuttleSystem: initial query

* shuttle fix: ShuttleDeedComponent belongs to grid

* adding some logging

* Cleanup & bugfixes

* ShuttleConsole BUI: add Frontier comments

* console.ftl: dampening btns: "Cruise, Drive, Park"

---------

Co-authored-by: neuPanda <[email protected]>
Co-authored-by: Dvir <[email protected]>
Co-authored-by: Whatstone <[email protected]>
  • Loading branch information
4 people authored and sleepyyapril committed Dec 28, 2024
1 parent 51258ee commit 7818749
Show file tree
Hide file tree
Showing 16 changed files with 462 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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;
Expand All @@ -26,6 +26,7 @@ protected override void Open()
_window.RequestBeaconFTL += OnFTLBeaconRequest;
_window.DockRequest += OnDockRequest;
_window.UndockRequest += OnUndockRequest;
NfOpen(); // Frontier
}

private void OnUndockRequest(NetEntity entity)
Expand Down
45 changes: 44 additions & 1 deletion Content.Client/Shuttles/UI/NavScreen.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,48 @@
Text="{controls:Loc 'shuttle-console-dock-toggle'}"
TextAlign="Center"
ToggleMode="True"/>
<!-- Frontier - Inertia dampener controls-->
<controls:BoxContainer Name="DampenerModeButtons"
Orientation="Horizontal"
HorizontalAlignment="Stretch"
Margin="5">
<controls:Button Name="DampenerOff"
Text="{controls:Loc 'shuttle-console-inertia-dampener-off'}"
TextAlign="Center"
ToggleMode="True"
MinWidth="82"
MaxWidth="82"/>
<controls:Button Name="DampenerOn"
Text="{controls:Loc 'shuttle-console-inertia-dampener-dampen'}"
TextAlign="Center"
ToggleMode="True"
MinWidth="82"
MaxWidth="82"/>
<controls:Button Name="AnchorOn"
Text="{controls:Loc 'shuttle-console-inertia-dampener-anchor'}"
TextAlign="Center"
ToggleMode="True"
MinWidth="82"
MaxWidth="82"/>
</controls:BoxContainer>
<!-- End Frontier - Inertia dampener controls-->
<!-- Frontier - IFF search -->
<controls:BoxContainer Orientation="Vertical" HorizontalExpand="True" Name="IffSearchBox">
<controls:Label Text="{controls:Loc 'shuttle-console-iff-search'}"/>
<controls:LineEdit Name="IffSearchCriteria" Access="Public" HorizontalExpand="True"/>
</controls:BoxContainer>
<!-- End Frontier - IFF search -->

<!-- Frontier - Maximum IFF Distance -->
<controls:BoxContainer Orientation="Vertical" HorizontalExpand="True" Name="MaximumIFFDistanceBox">
<controls:Label Text="{controls:Loc 'shuttle-console-maximum-iff-distance'}"/>
<controls:SliderIntInput Name="MaximumIFFDistanceValue"
Access="Public"
MinValue="0"
MaxValue="3000"
Value="3000"
HorizontalExpand="True"/>
</controls:BoxContainer>
<!-- End Frontier - Maximum IFF Distance -->
</controls:BoxContainer>
</controls:BoxContainer>
</controls:BoxContainer>
3 changes: 3 additions & 0 deletions Content.Client/Shuttles/UI/NavScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public NavScreen()

DockToggle.OnToggled += OnDockTogglePressed;
DockToggle.Pressed = NavRadar.ShowDocks;

NfInitialize(); // Frontier Initialization for the NavScreen
}

public void SetShuttle(EntityUid? shuttle)
Expand All @@ -50,6 +52,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)
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public ShuttleConsoleWindow()
{
UndockRequest?.Invoke(entity);
};

NfInitialize(); // Frontier Initialization for the ShuttleConsoleWindow
}

private void ClearModes(ShuttleConsoleMode mode)
Expand Down
8 changes: 6 additions & 2 deletions Content.Client/Shuttles/UI/ShuttleNavControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -7,20 +8,20 @@
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;

[GenerateTypedNameReferences]
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;

Expand Down Expand Up @@ -48,6 +49,7 @@ public ShuttleNavControl() : base(64f, 256f, 256f)
RobustXamlLoader.Load(this);
_shuttles = EntManager.System<SharedShuttleSystem>();
_transform = EntManager.System<SharedTransformSystem>();
_station = EntManager.System<StationSystem>(); // Frontier
}

public void SetMatrix(EntityCoordinates? coordinates, Angle? angle)
Expand Down Expand Up @@ -110,6 +112,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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
});
}

}
}
83 changes: 83 additions & 0 deletions Content.Client/_NF/Shuttles/UI/NavScreen.xaml.cs
Original file line number Diff line number Diff line change
@@ -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<NetEntity?, InertiaDampeningMode>? 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<MetaDataComponent>(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
}

}
}
21 changes: 21 additions & 0 deletions Content.Client/_NF/Shuttles/UI/ShuttleConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -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<NetEntity?, InertiaDampeningMode>? OnInertiaDampeningModeChanged;

private void NfInitialize()
{
NavContainer.OnInertiaDampeningModeChanged += (entity, mode) =>
{
OnInertiaDampeningModeChanged?.Invoke(entity, mode);
};
}

}
}
Loading

0 comments on commit 7818749

Please sign in to comment.