diff --git a/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs b/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs index d691f9acef3..64fc975b98c 100644 --- a/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs +++ b/Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs @@ -1,7 +1,9 @@ using System.Linq; using Content.Client.Message; +using Content.Shared.DeltaV.Salvage.Systems; // DeltaV using Content.Shared.Salvage; using Content.Shared.Salvage.Magnet; +using Robust.Client.Player; // DeltaV using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; @@ -10,12 +12,16 @@ namespace Content.Client.Salvage.UI; public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface { [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IPlayerManager _player = default!; // DeltaV + + private readonly MiningPointsSystem _points; // DeltaV private OfferingWindow? _window; public SalvageMagnetBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { IoCManager.InjectDependencies(this); + _points = _entManager.System(); // DeltaV } protected override void Open() @@ -61,6 +67,21 @@ protected override void UpdateState(BoundUserInterfaceState state) }); }; + // Begin DeltaV Additions: Mining points cost for wrecks + if (offer.Cost > 0) + { + if (_player.LocalSession?.AttachedEntity is not {} user || !_points.UserHasPoints(user, offer.Cost)) + option.Disabled = true; + + var label = new Label + { + Text = Loc.GetString("salvage-magnet-mining-points-cost", ("points", offer.Cost)), + HorizontalAlignment = Control.HAlignment.Center + }; + option.AddContent(label); + } + // End DeltaV Additions + switch (offer) { case AsteroidOffering asteroid: diff --git a/Content.Server/Salvage/SalvageSystem.Magnet.cs b/Content.Server/Salvage/SalvageSystem.Magnet.cs index 81db78fb201..4ae1a06d176 100644 --- a/Content.Server/Salvage/SalvageSystem.Magnet.cs +++ b/Content.Server/Salvage/SalvageSystem.Magnet.cs @@ -45,7 +45,7 @@ private void OnMagnetClaim(EntityUid uid, SalvageMagnetComponent component, ref return; } - TakeMagnetOffer((station.Value, dataComp), args.Index, (uid, component)); + TakeMagnetOffer((station.Value, dataComp), args.Index, (uid, component), args.Actor); // DeltaV: pass the user entity } private void OnMagnetStartup(EntityUid uid, SalvageMagnetComponent component, ComponentStartup args) @@ -250,11 +250,15 @@ private void UpdateMagnetUIs(Entity data) } } - private async Task TakeMagnetOffer(Entity data, int index, Entity magnet) + private async Task TakeMagnetOffer(Entity data, int index, Entity magnet, EntityUid user) // DeltaV: add user param { var seed = data.Comp.Offered[index]; var offering = GetSalvageOffering(seed); + // Begin DeltaV Addition: make wrecks cost mining points to pull + if (offering.Cost > 0 && !(_points.TryFindIdCard(user) is {} idCard && _points.RemovePoints(idCard, offering.Cost))) + return; + // End DeltaV Addition var salvMap = _mapSystem.CreateMap(); var salvMapXform = Transform(salvMap); diff --git a/Content.Server/Salvage/SalvageSystem.cs b/Content.Server/Salvage/SalvageSystem.cs index eb5719c892f..7610b05d7da 100644 --- a/Content.Server/Salvage/SalvageSystem.cs +++ b/Content.Server/Salvage/SalvageSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Construction; using Content.Server.GameTicking; using Content.Server.Radio.EntitySystems; +using Content.Shared.DeltaV.Salvage.Systems; // DeltaV using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Popups; @@ -52,6 +53,7 @@ public sealed partial class SalvageSystem : SharedSalvageSystem [Dependency] private readonly LabelSystem _labelSystem = default!; [Dependency] private readonly MapLoaderSystem _map = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; + [Dependency] private readonly MiningPointsSystem _points = default!; // DeltaV [Dependency] private readonly RadioSystem _radioSystem = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; diff --git a/Resources/Locale/en-US/deltav/salvage/salvage-magnet.ftl b/Resources/Locale/en-US/deltav/salvage/salvage-magnet.ftl index d2d7ad97289..ed67706ee08 100644 --- a/Resources/Locale/en-US/deltav/salvage/salvage-magnet.ftl +++ b/Resources/Locale/en-US/deltav/salvage/salvage-magnet.ftl @@ -1 +1,3 @@ salvage-map-wreck-size-unknown = [color=purple]Unidentified[/color] + +salvage-magnet-mining-points-cost = Cost: {$points} Mining Points