From 8a141635a0aea67668035304d65dd080ff93386b Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Tue, 17 Dec 2024 05:43:27 +0000 Subject: [PATCH 1/3] add UserHasPoints helper method --- .../DeltaV/Salvage/Systems/MiningPointsSystem.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Content.Shared/DeltaV/Salvage/Systems/MiningPointsSystem.cs b/Content.Shared/DeltaV/Salvage/Systems/MiningPointsSystem.cs index 33dca3ee019..e3e5c0655ec 100644 --- a/Content.Shared/DeltaV/Salvage/Systems/MiningPointsSystem.cs +++ b/Content.Shared/DeltaV/Salvage/Systems/MiningPointsSystem.cs @@ -61,6 +61,17 @@ private void OnClaimMiningPoints(Entity ent, ref Lat return (idCard, comp); } + /// + /// Returns true if the user has at least some number of points on their ID card. + /// + public bool UserHasPoints(EntityUid user, uint points) + { + if (TryFindIdCard(user)?.Comp is not {} comp) + return false; + + return comp.Points >= points; + } + /// /// Removes points from a holder, returning true if it succeeded. /// From 0f49d67ea914ccfa3afb24f0e60835af4ec02452 Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Tue, 17 Dec 2024 05:43:40 +0000 Subject: [PATCH 2/3] add cost to wreck pulls --- Content.Shared/Salvage/Magnet/AsteroidOffering.cs | 2 ++ Content.Shared/Salvage/Magnet/DebrisOffering.cs | 2 ++ Content.Shared/Salvage/Magnet/ISalvageMagnetOffering.cs | 7 +++++-- Content.Shared/Salvage/Magnet/SalvageOffering.cs | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Salvage/Magnet/AsteroidOffering.cs b/Content.Shared/Salvage/Magnet/AsteroidOffering.cs index 38da94afee2..42592d8a015 100644 --- a/Content.Shared/Salvage/Magnet/AsteroidOffering.cs +++ b/Content.Shared/Salvage/Magnet/AsteroidOffering.cs @@ -15,4 +15,6 @@ public record struct AsteroidOffering : ISalvageMagnetOffering /// Calculated marker layers for the asteroid. /// public Dictionary MarkerLayers; + + uint ISalvageMagnetOffering.Cost => 0; // DeltaV } diff --git a/Content.Shared/Salvage/Magnet/DebrisOffering.cs b/Content.Shared/Salvage/Magnet/DebrisOffering.cs index 953b9dcad9f..7f88c085977 100644 --- a/Content.Shared/Salvage/Magnet/DebrisOffering.cs +++ b/Content.Shared/Salvage/Magnet/DebrisOffering.cs @@ -6,4 +6,6 @@ namespace Content.Shared.Salvage.Magnet; public record struct DebrisOffering : ISalvageMagnetOffering { public string Id; + + uint ISalvageMagnetOffering.Cost => 0; // DeltaV: Debris is a very good source of materials for the station, so no cost } diff --git a/Content.Shared/Salvage/Magnet/ISalvageMagnetOffering.cs b/Content.Shared/Salvage/Magnet/ISalvageMagnetOffering.cs index 7d002fe679e..8aae2981fdb 100644 --- a/Content.Shared/Salvage/Magnet/ISalvageMagnetOffering.cs +++ b/Content.Shared/Salvage/Magnet/ISalvageMagnetOffering.cs @@ -2,5 +2,8 @@ namespace Content.Shared.Salvage.Magnet; public interface ISalvageMagnetOffering { - -} \ No newline at end of file + /// + /// DeltaV: How many mining points this offering costs to accept. + /// + public uint Cost { get; } +} diff --git a/Content.Shared/Salvage/Magnet/SalvageOffering.cs b/Content.Shared/Salvage/Magnet/SalvageOffering.cs index c49f1ff4022..a30328a6fa6 100644 --- a/Content.Shared/Salvage/Magnet/SalvageOffering.cs +++ b/Content.Shared/Salvage/Magnet/SalvageOffering.cs @@ -6,4 +6,6 @@ namespace Content.Shared.Salvage.Magnet; public record struct SalvageOffering : ISalvageMagnetOffering { public SalvageMapPrototype SalvageMap; + + uint ISalvageMagnetOffering.Cost => 1000; // DeltaV: Station gets next to no benefit from you pulling wrecks, force you to mine first. } From 92f3f13c3b173a5692cdca6062211a8cb8156030 Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Tue, 17 Dec 2024 05:43:48 +0000 Subject: [PATCH 3/3] implement wreck pull cost --- .../UI/SalvageMagnetBoundUserInterface.cs | 21 +++++++++++++++++++ .../Salvage/SalvageSystem.Magnet.cs | 8 +++++-- Content.Server/Salvage/SalvageSystem.cs | 2 ++ .../en-US/deltav/salvage/salvage-magnet.ftl | 2 ++ 4 files changed, 31 insertions(+), 2 deletions(-) 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