Files
crystall-punk-14/Content.Shared/_CP14/Workbench/Requirements/SolutionResource.cs
Red 6570b1b4b6 Public market + Solutions requests (#1503)
* Add platform markup to trading platform prices

Introduces a PlatformMarkupProcent field to CP14TradingPlatformComponent and applies it to price calculations in both client and server logic. Adds a new public trading platform entity with a higher markup and updates related sprites and metadata.

* Add platform markup percent to selling platforms

Introduces a PlatformMarkupProcent field to CP14SellingPlatformComponent, allowing selling platforms to apply a markup or markdown to item prices. Updates server logic to use this value when calculating payouts and UI state. Adds a new public selling platform entity with a lower markup in the trade_platform.yml prototype.

* Add Brad Potions trading requests prototype

Introduces a new YAML prototype defining multiple cp14TradingRequest entries for the BradPotions faction, each specifying requirements for various potion effects with minimum purity and amount.

* Apply platform markup to selling prices and payouts

Updated the selling request control and platform window to factor in the platform's markup percentage when displaying prices. Adjusted the server-side payout logic to multiply the payout by the platform markup percentage, ensuring consistency between client display and server rewards.

* replace mapping to public platforms

* bug + remove eepy potions request

* Clarify purity requirement in workbench reagent text

Updated the reagent requirement string in both English and Russian locale files to indicate that the required purity is '{$purity}%+' instead of just '{$purity}%'. This clarifies that the purity must be at least the specified percentage.
2025-07-06 00:09:03 +03:00

116 lines
3.4 KiB
C#

using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.Workbench.Requirements;
public sealed partial class SolutionResource : CP14WorkbenchCraftRequirement
{
[DataField(required: true)]
public ProtoId<ReagentPrototype> Reagent = default!;
/// <summary>
/// How much impurity from other reagents is allowed?
/// </summary>
[DataField(required: true)]
public float Purity = 1f;
[DataField(required: true)]
public FixedPoint2 Amount = 1f;
[DataField]
public EntProtoId DummyEntityIcon = "CP14LiquidDropDummy";
public override bool CheckRequirement(EntityManager entManager,
IPrototypeManager protoManager,
HashSet<EntityUid> placedEntities)
{
var solutionSys = entManager.System<SharedSolutionContainerSystem>();
foreach (var ent in placedEntities)
{
if (!solutionSys.TryGetDrawableSolution(ent, out var soln, out var solution))
continue;
var volume = solution.Volume;
foreach (var (id, quantity) in solution.Contents)
{
if (id.Prototype != Reagent)
continue;
if (quantity < Amount)
continue;
//Purity check
if (quantity / volume < Purity)
continue;
return true;
}
}
return false;
}
public override void PostCraft(EntityManager entManager, IPrototypeManager protoManager, HashSet<EntityUid> placedEntities)
{
var solutionSys = entManager.System<SharedSolutionContainerSystem>();
foreach (var ent in placedEntities)
{
if (!solutionSys.TryGetDrawableSolution(ent, out var soln, out var solution))
continue;
var volume = solution.Volume;
if (volume < Amount)
continue;
foreach (var (id, quantity) in solution.Contents)
{
if (id.Prototype != Reagent)
continue;
//Purity check
if (quantity / volume < Purity)
continue;
solutionSys.Draw(ent, soln.Value, Amount);
return;
}
}
}
public override double GetPrice(EntityManager entManager, IPrototypeManager protoManager)
{
if (!protoManager.TryIndex(Reagent, out var indexedReagent))
return 0;
return indexedReagent.PricePerUnit * (double)Amount;
}
public override string GetRequirementTitle(IPrototypeManager protoManager)
{
if (!protoManager.TryIndex(Reagent, out var indexedReagent))
return string.Empty;
return Loc.GetString("cp14-workbench-reagent-req",
("reagent", indexedReagent.LocalizedName),
("count", Amount),
("purity", Purity * 100));
}
public override EntityPrototype? GetRequirementEntityView(IPrototypeManager protoManager)
{
if (!protoManager.TryIndex(DummyEntityIcon, out var indexedEnt))
return null;
return indexedEnt;
}
public override Color GetRequirementColor(IPrototypeManager protoManager)
{
if (!protoManager.TryIndex(Reagent, out var indexedReagent))
return Color.White;
return indexedReagent.SubstanceColor;
}
}