From f1fb8313a833e7e5928e5890df59779c83fd8b4d Mon Sep 17 00:00:00 2001 From: Orion-416 Date: Wed, 11 Mar 2026 17:22:32 +0000 Subject: [PATCH 01/14] Port Shipyards (#1314) I needed this extremely badly. - [x] Move all of this out of the DeltaV folders. :cl: - add: Added Shipyards. --------- Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: Null <56081759+NullWanderer@users.noreply.github.com> Co-authored-by: Milon Co-authored-by: Plykiya <58439124+plykiya@users.noreply.github.com> Co-authored-by: plykiya Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Radezolid Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> --- .../Shipyard/ShipyardConsoleSystem.cs | 5 + .../Shipyard/UI/ShipyardBoundUserInterface.cs | 58 + .../Shipyard/UI/ShipyardConsoleMenu.xaml | 29 + .../Shipyard/UI/ShipyardConsoleMenu.xaml.cs | 109 + Content.Client/Shipyard/UI/VesselRow.xaml | 16 + Content.Client/Shipyard/UI/VesselRow.xaml.cs | 29 + .../Tests/DeltaV/ShipyardTest.cs | 90 + .../Shipyard/MapDeleterShuttleComponent.cs | 17 + .../Shipyard/MapDeleterShuttleSystem.cs | 25 + .../Shipyard/ShipyardConsoleSystem.cs | 101 + Content.Server/Shipyard/ShipyardSystem.cs | 96 + .../Prototypes/VesselCategoryPrototype.cs | 14 + .../Shipyard/Prototypes/VesselPrototype.cs | 48 + .../Shipyard/SharedShipyardConsoleSystem.cs | 51 + .../Shipyard/ShipyardConsoleComponent.cs | 31 + Content.Shared/Shipyard/ShipyardUi.cs | 36 + Content.Shared/_DV/CCVars/DCCVars.cs | 6 + .../deltav/shipyard/shipyard-console.ftl | 4 + Resources/Maps/_DV/Shuttles/barge.yml | 4372 +++++++++++++++++ Resources/Maps/_DV/Shuttles/helix.yml | 3131 ++++++++++++ Resources/Maps/_DV/Shuttles/ntcv-nomad.yml | 1151 +++++ Resources/Maps/_DV/Shuttles/ntsv-tote.yml | 1231 +++++ Resources/Maps/_DV/Shuttles/ntv-pulse.yml | 3622 ++++++++++++++ Resources/Maps/_DV/Shuttles/ntxr-saucer.yml | 2868 +++++++++++ Resources/Maps/_DV/Shuttles/prospector.yml | 1471 ++++++ Resources/Maps/_DV/Shuttles/pts.yml | 1180 +++++ .../DeltaV/Catalog/Shipyard/categories.yml | 35 + .../DeltaV/Catalog/Shipyard/civilian.yml | 76 + .../DeltaV/Catalog/Shipyard/experimental.yml | 10 + .../Devices/CircuitBoards/computer.yml | 10 + .../Structures/Doors/Airlocks/access.yml | 8 + .../Structures/Machines/computers.yml | 31 + Resources/Prototypes/_DV/tags.yml | 5 +- 33 files changed, 19965 insertions(+), 1 deletion(-) create mode 100644 Content.Client/Shipyard/ShipyardConsoleSystem.cs create mode 100644 Content.Client/Shipyard/UI/ShipyardBoundUserInterface.cs create mode 100644 Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml create mode 100644 Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml.cs create mode 100644 Content.Client/Shipyard/UI/VesselRow.xaml create mode 100644 Content.Client/Shipyard/UI/VesselRow.xaml.cs create mode 100644 Content.IntegrationTests/Tests/DeltaV/ShipyardTest.cs create mode 100644 Content.Server/Shipyard/MapDeleterShuttleComponent.cs create mode 100644 Content.Server/Shipyard/MapDeleterShuttleSystem.cs create mode 100644 Content.Server/Shipyard/ShipyardConsoleSystem.cs create mode 100644 Content.Server/Shipyard/ShipyardSystem.cs create mode 100644 Content.Shared/Shipyard/Prototypes/VesselCategoryPrototype.cs create mode 100644 Content.Shared/Shipyard/Prototypes/VesselPrototype.cs create mode 100644 Content.Shared/Shipyard/SharedShipyardConsoleSystem.cs create mode 100644 Content.Shared/Shipyard/ShipyardConsoleComponent.cs create mode 100644 Content.Shared/Shipyard/ShipyardUi.cs create mode 100644 Resources/Locale/en-US/deltav/shipyard/shipyard-console.ftl create mode 100644 Resources/Maps/_DV/Shuttles/barge.yml create mode 100644 Resources/Maps/_DV/Shuttles/helix.yml create mode 100644 Resources/Maps/_DV/Shuttles/ntcv-nomad.yml create mode 100644 Resources/Maps/_DV/Shuttles/ntsv-tote.yml create mode 100644 Resources/Maps/_DV/Shuttles/ntv-pulse.yml create mode 100644 Resources/Maps/_DV/Shuttles/ntxr-saucer.yml create mode 100644 Resources/Maps/_DV/Shuttles/prospector.yml create mode 100644 Resources/Maps/_DV/Shuttles/pts.yml create mode 100644 Resources/Prototypes/DeltaV/Catalog/Shipyard/categories.yml create mode 100644 Resources/Prototypes/DeltaV/Catalog/Shipyard/civilian.yml create mode 100644 Resources/Prototypes/DeltaV/Catalog/Shipyard/experimental.yml create mode 100644 Resources/Prototypes/DeltaV/Entities/Objects/Devices/CircuitBoards/computer.yml create mode 100644 Resources/Prototypes/_DV/Entities/Structures/Doors/Airlocks/access.yml create mode 100644 Resources/Prototypes/_DV/Entities/Structures/Machines/computers.yml diff --git a/Content.Client/Shipyard/ShipyardConsoleSystem.cs b/Content.Client/Shipyard/ShipyardConsoleSystem.cs new file mode 100644 index 00000000000..11847f8137d --- /dev/null +++ b/Content.Client/Shipyard/ShipyardConsoleSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared.Shipyard; + +namespace Content.Client.Shipyard; + +public sealed class ShipyardConsoleSystem : SharedShipyardConsoleSystem; diff --git a/Content.Client/Shipyard/UI/ShipyardBoundUserInterface.cs b/Content.Client/Shipyard/UI/ShipyardBoundUserInterface.cs new file mode 100644 index 00000000000..5efe063b3b0 --- /dev/null +++ b/Content.Client/Shipyard/UI/ShipyardBoundUserInterface.cs @@ -0,0 +1,58 @@ +using Content.Shared.Access.Systems; +using Content.Shared.Shipyard; +using Content.Shared.Whitelist; +using Robust.Client.Player; +using Robust.Shared.Prototypes; + +namespace Content.Client.Shipyard.UI; + +public sealed class ShipyardConsoleBoundUserInterface : BoundUserInterface +{ + [Dependency] private readonly IPrototypeManager _proto = default!; + [Dependency] private readonly IPlayerManager _player = default!; + + private readonly AccessReaderSystem _access; + private readonly EntityWhitelistSystem _whitelist; + + [ViewVariables] + private ShipyardConsoleMenu? _menu; + + public ShipyardConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + _access = EntMan.System(); + _whitelist = EntMan.System(); + } + + protected override void Open() + { + base.Open(); + + _menu = new ShipyardConsoleMenu(Owner, _proto, EntMan, _player, _access, _whitelist); + _menu.OpenCentered(); + _menu.OnClose += Close; + _menu.OnPurchased += Purchase; + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not ShipyardConsoleState cast) + return; + + _menu?.UpdateState(cast); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) + _menu?.Dispose(); + } + + private void Purchase(string id) + { + SendMessage(new ShipyardConsolePurchaseMessage(id)); + } +} diff --git a/Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml b/Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml new file mode 100644 index 00000000000..9eccd45b698 --- /dev/null +++ b/Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml @@ -0,0 +1,29 @@ + + + + diff --git a/Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml.cs b/Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml.cs new file mode 100644 index 00000000000..4559aa6762e --- /dev/null +++ b/Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml.cs @@ -0,0 +1,109 @@ +using Content.Client.UserInterface.Controls; +using Content.Shared.Access.Systems; +using Content.Shared.Shipyard; +using Content.Shared.Shipyard.Prototypes; +using Content.Shared.Whitelist; +using Robust.Client.AutoGenerated; +using Robust.Client.Player; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Prototypes; + +namespace Content.Client.Shipyard.UI; + +[GenerateTypedNameReferences] +public sealed partial class ShipyardConsoleMenu : FancyWindow +{ + private readonly AccessReaderSystem _access; + private readonly IPlayerManager _player; + + public event Action? OnPurchased; + + private readonly List _vessels = new(); + private readonly List _categories = new(); + + public Entity Console; + private string? _category; + + public ShipyardConsoleMenu(EntityUid console, IPrototypeManager proto, IEntityManager entMan, IPlayerManager player, AccessReaderSystem access, EntityWhitelistSystem whitelist) + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + Console = (console, entMan.GetComponent(console)); + _access = access; + _player = player; + + // don't include ships that aren't allowed by whitelist, server won't accept them anyway + foreach (var vessel in proto.EnumeratePrototypes()) + { + if (whitelist.IsWhitelistPassOrNull(vessel.Whitelist, console)) + _vessels.Add(vessel); + } + _vessels.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase)); + + // only list categories in said ships + foreach (var vessel in _vessels) + { + foreach (var category in vessel.Categories) + { + if (!_categories.Contains(category)) + _categories.Add(category); + } + } + + _categories.Sort(); + // inserting here and not adding at the start so it doesn't get affected by sort + _categories.Insert(0, Loc.GetString("cargo-console-menu-populate-categories-all-text")); + PopulateCategories(); + + SearchBar.OnTextChanged += _ => PopulateProducts(); + Categories.OnItemSelected += args => + { + _category = args.Id == 0 ? null : _categories[args.Id]; + Categories.SelectId(args.Id); + PopulateProducts(); + }; + } + + /// + /// Populates the list of products that will actually be shown, using the current filters. + /// + private void PopulateProducts() + { + Vessels.RemoveAllChildren(); + + var access = _player.LocalSession?.AttachedEntity is {} player + && _access.IsAllowed(player, Console); + + var search = SearchBar.Text.Trim().ToLowerInvariant(); + foreach (var vessel in _vessels) + { + if (search.Length != 0 && !vessel.Name.ToLowerInvariant().Contains(search)) + continue; + if (_category != null && !vessel.Categories.Contains(_category)) + continue; + + var vesselEntry = new VesselRow(vessel, access); + vesselEntry.OnPurchasePressed += () => OnPurchased?.Invoke(vessel.ID); + Vessels.AddChild(vesselEntry); + } + } + + /// + /// Populates the list categories that will actually be shown, using the current filters. + /// + private void PopulateCategories() + { + Categories.Clear(); + foreach (var category in _categories) + { + Categories.AddItem(category); + } + } + + public void UpdateState(ShipyardConsoleState state) + { + BankAccountLabel.Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", state.Balance.ToString())); + PopulateProducts(); + } +} diff --git a/Content.Client/Shipyard/UI/VesselRow.xaml b/Content.Client/Shipyard/UI/VesselRow.xaml new file mode 100644 index 00000000000..eac2d3a1bde --- /dev/null +++ b/Content.Client/Shipyard/UI/VesselRow.xaml @@ -0,0 +1,16 @@ + + +