diff --git a/.github/workflows/build-test-debug.yml b/.github/workflows/build-test-debug.yml index c929fce6b9..d8128c0369 100644 --- a/.github/workflows/build-test-debug.yml +++ b/.github/workflows/build-test-debug.yml @@ -62,3 +62,8 @@ jobs: - name: Run Content.Tests run: dotnet test --no-build Content.Tests/Content.Tests.csproj -- NUnit.ConsoleOut=0 + - name: Run Content.IntegrationTests + shell: pwsh + run: | + $env:DOTNET_gcServer=1 + dotnet test --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -- NUnit.ConsoleOut=0 diff --git a/.github/workflows/conflict-labeler.yml b/.github/workflows/conflict-labeler.yml index 0bf32de8eb..d7e1e58caf 100644 --- a/.github/workflows/conflict-labeler.yml +++ b/.github/workflows/conflict-labeler.yml @@ -9,10 +9,9 @@ on: jobs: Label: runs-on: ubuntu-latest - if: github.event.pull_request.draft == false steps: - name: Check for Merge Conflicts - uses: eps1lon/actions-label-merge-conflict@513a24fc7dca40990863be2935e059e650728400 + uses: ike709/actions-label-merge-conflict@9eefdd17e10566023c46d2dc6dc04fcb8ec76142 with: dirtyLabel: "Merge Conflict" repoToken: "${{ secrets.GITHUB_TOKEN }}" diff --git a/Content.Client/AI/ClientPathfindingDebugSystem.cs b/Content.Client/AI/ClientPathfindingDebugSystem.cs index e7f59e95bb..2c42189087 100644 --- a/Content.Client/AI/ClientPathfindingDebugSystem.cs +++ b/Content.Client/AI/ClientPathfindingDebugSystem.cs @@ -294,7 +294,7 @@ namespace Content.Client.AI private void DrawCachedRegions(DrawingHandleScreen screenHandle, Box2 viewport) { var transform = _entities.GetComponentOrNull(_playerManager.LocalPlayer?.ControlledEntity); - if (transform == null || !CachedRegions.TryGetValue(transform.GridEntityId, out var entityRegions)) + if (transform == null || transform.GridUid == null || !CachedRegions.TryGetValue(transform.GridUid.Value, out var entityRegions)) { return; } @@ -312,7 +312,7 @@ namespace Content.Client.AI screenTile.X + 15.0f, screenTile.Y + 15.0f); - screenHandle.DrawRect(box, _cachedRegionColors[transform.GridEntityId][region]); + screenHandle.DrawRect(box, _cachedRegionColors[transform.GridUid.Value][region]); } } } @@ -344,7 +344,8 @@ namespace Content.Client.AI { var attachedEntity = _playerManager.LocalPlayer?.ControlledEntity; if (!_entities.TryGetComponent(attachedEntity, out TransformComponent? transform) || - !Regions.TryGetValue(transform.GridEntityId, out var entityRegions)) + transform.GridUid == null || + !Regions.TryGetValue(transform.GridUid.Value, out var entityRegions)) { return; } @@ -364,7 +365,7 @@ namespace Content.Client.AI screenTile.X + 15.0f, screenTile.Y + 15.0f); - screenHandle.DrawRect(box, _regionColors[_entities.GetComponent(attachedEntity.Value).GridEntityId][chunk][region]); + screenHandle.DrawRect(box, _regionColors[transform.GridUid.Value][chunk][region]); } } } diff --git a/Content.Client/AME/AMEControllerVisualizerSystem.cs b/Content.Client/AME/AMEControllerVisualizerSystem.cs new file mode 100644 index 0000000000..f16b22cf62 --- /dev/null +++ b/Content.Client/AME/AMEControllerVisualizerSystem.cs @@ -0,0 +1,61 @@ +using Content.Client.AME.Components; +using Robust.Client.GameObjects; +using static Content.Shared.AME.SharedAMEControllerComponent; + +namespace Content.Client.AME; + +public sealed class AMEControllerVisualizerSystem : VisualizerSystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnComponentInit); + } + + private void OnComponentInit(EntityUid uid, AMEControllerVisualsComponent component, ComponentInit args) + { + if(TryComp(uid, out var sprite)) + { + sprite.LayerMapSet(AMEControllerVisualLayers.Display, sprite.AddLayerState("control_on")); + sprite.LayerSetVisible(AMEControllerVisualLayers.Display, false); + } + } + + protected override void OnAppearanceChange(EntityUid uid, AMEControllerVisualsComponent component, ref AppearanceChangeEvent args) + { + base.OnAppearanceChange(uid, component, ref args); + + if(args.Sprite != null + && args.Component.TryGetData(AMEControllerVisuals.DisplayState, out var state)) + { + switch(state) + { + case "on": + args.Sprite.LayerSetState(AMEControllerVisualLayers.Display, "control_on"); + args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, true); + break; + case "critical": + args.Sprite.LayerSetState(AMEControllerVisualLayers.Display, "control_critical"); + args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, true); + break; + case "fuck": + args.Sprite.LayerSetState(AMEControllerVisualLayers.Display, "control_fuck"); + args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, true); + break; + case "off": + args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, false); + break; + default: + args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, false); + break; + } + } + } +} + +public enum AMEControllerVisualLayers : byte +{ + Display +} + diff --git a/Content.Client/AME/AMEShieldingVisualizerSystem.cs b/Content.Client/AME/AMEShieldingVisualizerSystem.cs new file mode 100644 index 0000000000..9659f5ed55 --- /dev/null +++ b/Content.Client/AME/AMEShieldingVisualizerSystem.cs @@ -0,0 +1,70 @@ +using Content.Client.AME.Components; +using Robust.Client.GameObjects; +using static Content.Shared.AME.SharedAMEShieldComponent; + +namespace Content.Client.AME; + +public sealed class AMEShieldingVisualizerSystem : VisualizerSystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnComponentInit); + } + + private void OnComponentInit(EntityUid uid, AMEShieldingVisualsComponent component, ComponentInit args) + { + if(TryComp(uid, out var sprite)) + { + sprite.LayerMapSet(AMEShieldingVisualsLayer.Core, sprite.AddLayerState("core")); + sprite.LayerSetVisible(AMEShieldingVisualsLayer.Core, false); + sprite.LayerMapSet(AMEShieldingVisualsLayer.CoreState, sprite.AddLayerState("core_weak")); + sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, false); + } + } + + protected override void OnAppearanceChange(EntityUid uid, AMEShieldingVisualsComponent component, ref AppearanceChangeEvent args) + { + if(args.Sprite == null) + return; + + if(args.Component.TryGetData(AMEShieldVisuals.Core, out var core)) + { + if (core == "isCore") + { + args.Sprite.LayerSetState(AMEShieldingVisualsLayer.Core, "core"); + args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.Core, true); + + } + else + { + args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.Core, false); + } + } + + if(args.Component.TryGetData(AMEShieldVisuals.CoreState, out var coreState)) + { + switch(coreState) + { + case "weak": + args.Sprite.LayerSetState(AMEShieldingVisualsLayer.CoreState, "core_weak"); + args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, true); + break; + case "strong": + args.Sprite.LayerSetState(AMEShieldingVisualsLayer.CoreState, "core_strong"); + args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, true); + break; + case "off": + args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, false); + break; + } + } + } +} + +public enum AMEShieldingVisualsLayer : byte +{ + Core, + CoreState, +} diff --git a/Content.Client/AME/Components/AMEControllerVisualsComponent.cs b/Content.Client/AME/Components/AMEControllerVisualsComponent.cs new file mode 100644 index 0000000000..282ddb3576 --- /dev/null +++ b/Content.Client/AME/Components/AMEControllerVisualsComponent.cs @@ -0,0 +1,9 @@ +using System.ComponentModel.DataAnnotations; +using Robust.Shared.GameObjects; + +namespace Content.Client.AME.Components; + +[RegisterComponent] +public sealed class AMEControllerVisualsComponent : Component +{ +} diff --git a/Content.Client/AME/Components/AMEShieldingVisualsComponent.cs b/Content.Client/AME/Components/AMEShieldingVisualsComponent.cs new file mode 100644 index 0000000000..4254d809f3 --- /dev/null +++ b/Content.Client/AME/Components/AMEShieldingVisualsComponent.cs @@ -0,0 +1,9 @@ +using System.ComponentModel.DataAnnotations; +using Robust.Shared.GameObjects; + +namespace Content.Client.AME.Components; + +[RegisterComponent] +public sealed class AMEShieldingVisualsComponent : Component +{ +} diff --git a/Content.Client/AME/Visualizers/AMEControllerVisualizer.cs b/Content.Client/AME/Visualizers/AMEControllerVisualizer.cs deleted file mode 100644 index 27526e1e64..0000000000 --- a/Content.Client/AME/Visualizers/AMEControllerVisualizer.cs +++ /dev/null @@ -1,56 +0,0 @@ -using JetBrains.Annotations; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using static Content.Shared.AME.SharedAMEControllerComponent; - -namespace Content.Client.AME.Visualizers -{ - [UsedImplicitly] - public sealed class AMEControllerVisualizer : AppearanceVisualizer - { - public override void InitializeEntity(EntityUid entity) - { - base.InitializeEntity(entity); - var sprite = IoCManager.Resolve().GetComponent(entity); - - sprite.LayerMapSet(Layers.Display, sprite.AddLayerState("control_on")); - sprite.LayerSetVisible(Layers.Display, false); - } - - public override void OnChangeData(AppearanceComponent component) - { - base.OnChangeData(component); - var sprite = IoCManager.Resolve().GetComponent(component.Owner); - if (component.TryGetData(AMEControllerVisuals.DisplayState, out var state)) - { - switch (state) - { - case "on": - sprite.LayerSetState(Layers.Display, "control_on"); - sprite.LayerSetVisible(Layers.Display, true); - break; - case "critical": - sprite.LayerSetState(Layers.Display, "control_critical"); - sprite.LayerSetVisible(Layers.Display, true); - break; - case "fuck": - sprite.LayerSetState(Layers.Display, "control_fuck"); - sprite.LayerSetVisible(Layers.Display, true); - break; - case "off": - sprite.LayerSetVisible(Layers.Display, false); - break; - default: - sprite.LayerSetVisible(Layers.Display, false); - break; - } - } - } - - enum Layers : byte - { - Display, - } - } -} diff --git a/Content.Client/AME/Visualizers/AMEVisualizer.cs b/Content.Client/AME/Visualizers/AMEVisualizer.cs deleted file mode 100644 index dabbccba20..0000000000 --- a/Content.Client/AME/Visualizers/AMEVisualizer.cs +++ /dev/null @@ -1,62 +0,0 @@ -using JetBrains.Annotations; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using static Content.Shared.AME.SharedAMEShieldComponent; - -namespace Content.Client.AME.Visualizers -{ - [UsedImplicitly] - public sealed class AMEVisualizer : AppearanceVisualizer - { - public override void InitializeEntity(EntityUid entity) - { - base.InitializeEntity(entity); - var sprite = IoCManager.Resolve().GetComponent(entity); - sprite.LayerMapSet(Layers.Core, sprite.AddLayerState("core")); - sprite.LayerSetVisible(Layers.Core, false); - sprite.LayerMapSet(Layers.CoreState, sprite.AddLayerState("core_weak")); - sprite.LayerSetVisible(Layers.CoreState, false); - } - - public override void OnChangeData(AppearanceComponent component) - { - base.OnChangeData(component); - var sprite = IoCManager.Resolve().GetComponent(component.Owner); - if (component.TryGetData(AMEShieldVisuals.Core, out var core)) - { - if (core == "isCore") - { - sprite.LayerSetState(Layers.Core, "core"); - sprite.LayerSetVisible(Layers.Core, true); - } - else - { - sprite.LayerSetVisible(Layers.Core, false); - } - } - - if (component.TryGetData(AMEShieldVisuals.CoreState, out var coreState)) - switch (coreState) - { - case "weak": - sprite.LayerSetState(Layers.CoreState, "core_weak"); - sprite.LayerSetVisible(Layers.CoreState, true); - break; - case "strong": - sprite.LayerSetState(Layers.CoreState, "core_strong"); - sprite.LayerSetVisible(Layers.CoreState, true); - break; - case "off": - sprite.LayerSetVisible(Layers.CoreState, false); - break; - } - } - } - - enum Layers : byte - { - Core, - CoreState, - } -} diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs index d4f69e14e4..644ef8af35 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs @@ -24,7 +24,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab foreach (var grid in _data) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridUid; GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs index d8333eefb9..92c079f6b4 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs @@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab foreach (var grid in _gridData) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridUid; GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs index f9577ea763..35a0ea99db 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs @@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab foreach (var grid in _gridData) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridUid; GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs index 69f3ed362c..6ff73c979b 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs @@ -24,7 +24,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab foreach (var grid in _data) { var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridEntityId; + var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridUid; GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}"); } diff --git a/Content.Client/Atmos/UI/GasAnalyzerMenu.cs b/Content.Client/Atmos/UI/GasAnalyzerMenu.cs index 8549165383..acb58d706b 100644 --- a/Content.Client/Atmos/UI/GasAnalyzerMenu.cs +++ b/Content.Client/Atmos/UI/GasAnalyzerMenu.cs @@ -145,7 +145,7 @@ namespace Content.Client.Atmos.UI PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#525252ff") } }); CloseButton.OnPressed += _ => Close(); - SetSize = (300, 200); + SetSize = (300, 420); } diff --git a/Content.Client/Audio/BackgroundAudioSystem.cs b/Content.Client/Audio/BackgroundAudioSystem.cs index e1890b5698..c09a684236 100644 --- a/Content.Client/Audio/BackgroundAudioSystem.cs +++ b/Content.Client/Audio/BackgroundAudioSystem.cs @@ -89,7 +89,7 @@ namespace Content.Client.Audio { if(_playMan.LocalPlayer is null || _playMan.LocalPlayer.ControlledEntity != message.Entity) return; if (!TryComp(message.Entity, out var xform) || - !_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return; + !_mapManager.TryGetGrid(xform.GridUid, out var grid)) return; var tileDef = (ContentTileDefinition) _tileDefMan[grid.GetTileRef(xform.Coordinates).Tile.TypeId]; diff --git a/Content.Client/Buckle/BuckleComponent.cs b/Content.Client/Buckle/BuckleComponent.cs index f791a6f082..be9370f43c 100644 --- a/Content.Client/Buckle/BuckleComponent.cs +++ b/Content.Client/Buckle/BuckleComponent.cs @@ -41,7 +41,7 @@ namespace Content.Client.Buckle return; } - if (!_entMan.TryGetComponent(Owner, out RiderComponent? rider)) + if (LastEntityBuckledTo != null && _entMan.HasComponent(LastEntityBuckledTo)) { return; } diff --git a/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs b/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs similarity index 55% rename from Content.Client/Cargo/CargoConsoleBoundUserInterface.cs rename to Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs index ac03a59fe9..1d9f4a4cf5 100644 --- a/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs +++ b/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs @@ -1,45 +1,46 @@ -using Content.Client.Cargo.Components; using Content.Client.Cargo.UI; +using Content.Shared.Access.Systems; using Content.Shared.Cargo; +using Content.Shared.Cargo.BUI; using Content.Shared.Cargo.Components; +using Content.Shared.Cargo.Events; +using Content.Shared.Cargo.Prototypes; using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.ViewVariables; -using static Content.Shared.Cargo.Components.SharedCargoConsoleComponent; +using Robust.Client.Player; +using Robust.Shared.Prototypes; using static Robust.Client.UserInterface.Controls.BaseButton; -namespace Content.Client.Cargo +namespace Content.Client.Cargo.BUI { - public sealed class CargoConsoleBoundUserInterface : BoundUserInterface + public sealed class CargoOrderConsoleBoundUserInterface : BoundUserInterface { [ViewVariables] private CargoConsoleMenu? _menu; + /// + /// This is the separate popup window for individual orders. + /// [ViewVariables] private CargoConsoleOrderMenu? _orderMenu; [ViewVariables] - public CargoOrderDatabaseComponent? Orders { get; private set; } - - [ViewVariables] - public bool RequestOnly { get; private set; } - - [ViewVariables] - public int BankId { get; private set; } - - [ViewVariables] - public string? BankName { get; private set; } + public string? AccountName { get; private set; } [ViewVariables] public int BankBalance { get; private set; } [ViewVariables] - public (int CurrentCapacity, int MaxCapacity) ShuttleCapacity { get; private set; } + public int OrderCapacity { get; private set; } + [ViewVariables] + public int OrderCount { get; private set; } + + /// + /// Currently selected product + /// private CargoProductPrototype? _product; - public CargoConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) + public CargoOrderConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { } @@ -47,30 +48,29 @@ namespace Content.Client.Cargo { base.Open(); - var entMan = IoCManager.Resolve(); - if (!entMan.TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return; + var entityManager = IoCManager.Resolve(); + var sysManager = entityManager.EntitySysManager; + var spriteSystem = sysManager.GetEntitySystem(); + _menu = new CargoConsoleMenu(IoCManager.Resolve(), spriteSystem); + var localPlayer = IoCManager.Resolve()?.LocalPlayer?.ControlledEntity; - Orders = orders; + string orderRequester; + + if (entityManager.TryGetComponent(localPlayer, out var metadata)) + orderRequester = metadata.EntityName; + else + orderRequester = string.Empty; - _menu = new CargoConsoleMenu(this); _orderMenu = new CargoConsoleOrderMenu(); _menu.OnClose += Close; - _menu.Populate(); - - Orders.OnDatabaseUpdated += _menu.PopulateOrders; - - _menu.CallShuttleButton.OnPressed += (_) => - { - SendMessage(new CargoConsoleShuttleMessage()); - }; _menu.OnItemSelected += (args) => { if (args.Button.Parent is not CargoProductRow row) return; _product = row.Product; - _orderMenu.Requester.Text = ""; + _orderMenu.Requester.Text = orderRequester; _orderMenu.Reason.Text = ""; _orderMenu.Amount.Value = 1; _orderMenu.OpenCentered(); @@ -86,7 +86,15 @@ namespace Content.Client.Cargo }; _menu.OpenCentered(); + } + private void Populate(List orders) + { + if (_menu == null) return; + + _menu.PopulateProducts(); + _menu.PopulateCategories(); + _menu.PopulateOrders(orders); } protected override void UpdateState(BoundUserInterfaceState state) @@ -95,17 +103,16 @@ namespace Content.Client.Cargo if (state is not CargoConsoleInterfaceState cState) return; - if (RequestOnly != cState.RequestOnly) - { - RequestOnly = cState.RequestOnly; - _menu?.UpdateRequestOnly(); - } - BankId = cState.BankId; - BankName = cState.BankName; - BankBalance = cState.BankBalance; - ShuttleCapacity = cState.ShuttleCapacity; - _menu?.UpdateCargoCapacity(); - _menu?.UpdateBankData(); + + OrderCapacity = cState.Capacity; + OrderCount = cState.Count; + BankBalance = cState.Balance; + + AccountName = cState.Name; + + Populate(cState.Orders); + _menu?.UpdateCargoCapacity(OrderCount, OrderCapacity); + _menu?.UpdateBankData(AccountName, BankBalance); } protected override void Dispose(bool disposing) @@ -114,11 +121,6 @@ namespace Content.Client.Cargo if (!disposing) return; - if (Orders != null && _menu != null) - { - Orders.OnDatabaseUpdated -= _menu.PopulateOrders; - } - _menu?.Dispose(); _orderMenu?.Dispose(); } @@ -126,7 +128,7 @@ namespace Content.Client.Cargo private bool AddOrder() { int orderAmt = _orderMenu?.Amount.Value ?? 0; - if (orderAmt < 1 || orderAmt > ShuttleCapacity.MaxCapacity) + if (orderAmt < 1 || orderAmt > OrderCapacity) { return false; } @@ -153,11 +155,12 @@ namespace Content.Client.Cargo if (args.Button.Parent?.Parent is not CargoOrderRow row || row.Order == null) return; - if (ShuttleCapacity.CurrentCapacity == ShuttleCapacity.MaxCapacity) + if (OrderCount >= OrderCapacity) return; SendMessage(new CargoConsoleApproveOrderMessage(row.Order.OrderNumber)); - _menu?.UpdateCargoCapacity(); + // Most of the UI isn't predicted anyway so. + // _menu?.UpdateCargoCapacity(OrderCount + row.Order.Amount, OrderCapacity); } } } diff --git a/Content.Client/Cargo/BUI/CargoShuttleConsoleBoundUserInterface.cs b/Content.Client/Cargo/BUI/CargoShuttleConsoleBoundUserInterface.cs new file mode 100644 index 0000000000..6dd3df5f6e --- /dev/null +++ b/Content.Client/Cargo/BUI/CargoShuttleConsoleBoundUserInterface.cs @@ -0,0 +1,57 @@ +using Content.Client.Cargo.UI; +using Content.Shared.Cargo.BUI; +using Content.Shared.Cargo.Events; +using Robust.Client.GameObjects; +using Robust.Shared.Prototypes; +using Robust.Shared.Timing; + +namespace Content.Client.Cargo.BUI; + +public sealed class CargoShuttleConsoleBoundUserInterface : BoundUserInterface +{ + private CargoShuttleMenu? _menu; + + public CargoShuttleConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) {} + + protected override void Open() + { + base.Open(); + _menu = new CargoShuttleMenu(IoCManager.Resolve(), IoCManager.Resolve(), EntitySystem.Get()); + + _menu.ShuttleCallRequested += OnShuttleCall; + _menu.ShuttleRecallRequested += OnShuttleRecall; + _menu.OnClose += Close; + + _menu.OpenCentered(); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + { + _menu?.Dispose(); + } + } + + private void OnShuttleRecall() + { + SendMessage(new CargoRecallShuttleMessage()); + } + + private void OnShuttleCall() + { + SendMessage(new CargoCallShuttleMessage()); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + if (state is not CargoShuttleConsoleBoundUserInterfaceState cargoState) return; + _menu?.SetAccountName(cargoState.AccountName); + _menu?.SetShuttleName(cargoState.ShuttleName); + _menu?.SetShuttleETA(cargoState.ShuttleETA); + _menu?.SetOrders(cargoState.Orders); + _menu?.SetCanRecall(cargoState.CanRecall); + } +} diff --git a/Content.Client/Cargo/Components/CargoOrderDatabaseComponent.cs b/Content.Client/Cargo/Components/CargoOrderDatabaseComponent.cs deleted file mode 100644 index 5279e6dc0e..0000000000 --- a/Content.Client/Cargo/Components/CargoOrderDatabaseComponent.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using Content.Shared.Cargo; -using Content.Shared.Cargo.Components; -using Robust.Shared.GameObjects; - -namespace Content.Client.Cargo.Components -{ - [RegisterComponent] - public sealed class CargoOrderDatabaseComponent : SharedCargoOrderDatabaseComponent - { - private readonly List _orders = new(); - - public IReadOnlyList Orders => _orders; - /// - /// Event called when the database is updated. - /// - public event Action? OnDatabaseUpdated; - - // TODO add account selector menu - - /// - /// Removes all orders from the database. - /// - public void Clear() - { - _orders.Clear(); - } - - /// - /// Adds an order to the database. - /// - /// The order to be added. - public void AddOrder(CargoOrderData order) - { - if (!_orders.Contains(order)) - _orders.Add(order); - } - - public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) - { - base.HandleComponentState(curState, nextState); - if (curState is not CargoOrderDatabaseState state) - return; - Clear(); - if (state.Orders == null) - return; - foreach (var order in state.Orders) - { - AddOrder(order); - } - - OnDatabaseUpdated?.Invoke(); - } - } -} diff --git a/Content.Client/Cargo/CargoSystem.Telepad.cs b/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs similarity index 98% rename from Content.Client/Cargo/CargoSystem.Telepad.cs rename to Content.Client/Cargo/Systems/CargoSystem.Telepad.cs index 6074d637ac..4d73caacb2 100644 --- a/Content.Client/Cargo/CargoSystem.Telepad.cs +++ b/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs @@ -3,7 +3,7 @@ using Robust.Client.Animations; using Robust.Client.GameObjects; using Robust.Client.Graphics; -namespace Content.Client.Cargo; +namespace Content.Client.Cargo.Systems; public sealed partial class CargoSystem { diff --git a/Content.Client/Cargo/CargoSystem.cs b/Content.Client/Cargo/Systems/CargoSystem.cs similarity index 88% rename from Content.Client/Cargo/CargoSystem.cs rename to Content.Client/Cargo/Systems/CargoSystem.cs index ce26dc7ecf..3ffb0636d0 100644 --- a/Content.Client/Cargo/CargoSystem.cs +++ b/Content.Client/Cargo/Systems/CargoSystem.cs @@ -1,7 +1,7 @@ using Content.Shared.Cargo; using Robust.Client.GameObjects; -namespace Content.Client.Cargo; +namespace Content.Client.Cargo.Systems; public sealed partial class CargoSystem : SharedCargoSystem { diff --git a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml index 9b92e43091..5262f43d6b 100644 --- a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml +++ b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml @@ -1,7 +1,8 @@ - + - - - -