Price of food depends on its nutritional capacity (#11752)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> fixes https://github.com/space-wizards/space-station-14/issues/11464
This commit is contained in:
@@ -2,9 +2,11 @@
|
|||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
using Content.Server.Body.Systems;
|
using Content.Server.Body.Systems;
|
||||||
using Content.Server.Cargo.Components;
|
using Content.Server.Cargo.Components;
|
||||||
|
using Content.Server.Chemistry.Components.SolutionManager;
|
||||||
using Content.Server.Stack;
|
using Content.Server.Stack;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
|
using Content.Shared.Chemistry.Reagent;
|
||||||
using Content.Shared.Materials;
|
using Content.Shared.Materials;
|
||||||
using Content.Shared.MobState.Components;
|
using Content.Shared.MobState.Components;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
@@ -22,6 +24,7 @@ public sealed class PricingSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IConsoleHost _consoleHost = default!;
|
[Dependency] private readonly IConsoleHost _consoleHost = default!;
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
[Dependency] private readonly BodySystem _bodySystem = default!;
|
[Dependency] private readonly BodySystem _bodySystem = default!;
|
||||||
|
|
||||||
@@ -31,6 +34,7 @@ public sealed class PricingSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<StaticPriceComponent, PriceCalculationEvent>(CalculateStaticPrice);
|
SubscribeLocalEvent<StaticPriceComponent, PriceCalculationEvent>(CalculateStaticPrice);
|
||||||
SubscribeLocalEvent<StackPriceComponent, PriceCalculationEvent>(CalculateStackPrice);
|
SubscribeLocalEvent<StackPriceComponent, PriceCalculationEvent>(CalculateStackPrice);
|
||||||
SubscribeLocalEvent<MobPriceComponent, PriceCalculationEvent>(CalculateMobPrice);
|
SubscribeLocalEvent<MobPriceComponent, PriceCalculationEvent>(CalculateMobPrice);
|
||||||
|
SubscribeLocalEvent<SolutionContainerManagerComponent, PriceCalculationEvent>(CalculateSolutionPrice);
|
||||||
|
|
||||||
_consoleHost.RegisterCommand("appraisegrid",
|
_consoleHost.RegisterCommand("appraisegrid",
|
||||||
"Calculates the total value of the given grids.",
|
"Calculates the total value of the given grids.",
|
||||||
@@ -108,6 +112,22 @@ public sealed class PricingSystem : EntitySystem
|
|||||||
args.Price += stack.Count * component.Price;
|
args.Price += stack.Count * component.Price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CalculateSolutionPrice(EntityUid uid, SolutionContainerManagerComponent component, ref PriceCalculationEvent args)
|
||||||
|
{
|
||||||
|
var price = 0f;
|
||||||
|
|
||||||
|
foreach (var solution in component.Solutions.Values)
|
||||||
|
{
|
||||||
|
foreach (var reagent in solution.Contents)
|
||||||
|
{
|
||||||
|
if (!_prototypeManager.TryIndex<ReagentPrototype>(reagent.ReagentId, out var reagentProto))
|
||||||
|
continue;
|
||||||
|
price += (float) reagent.Quantity * reagentProto.PricePerUnit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args.Price += price;
|
||||||
|
}
|
||||||
|
|
||||||
private void CalculateStaticPrice(EntityUid uid, StaticPriceComponent component, ref PriceCalculationEvent args)
|
private void CalculateStaticPrice(EntityUid uid, StaticPriceComponent component, ref PriceCalculationEvent args)
|
||||||
{
|
{
|
||||||
args.Price += component.Price;
|
args.Price += component.Price;
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ namespace Content.Shared.Chemistry.Reagent
|
|||||||
[DataField("plantMetabolism", serverOnly: true)]
|
[DataField("plantMetabolism", serverOnly: true)]
|
||||||
public readonly List<ReagentEffect> PlantMetabolisms = new(0);
|
public readonly List<ReagentEffect> PlantMetabolisms = new(0);
|
||||||
|
|
||||||
|
[DataField("pricePerUnit")]
|
||||||
|
public float PricePerUnit { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If the substance color is too dark we user a lighter version to make the text color readable when the user examines a solution.
|
/// If the substance color is too dark we user a lighter version to make the text color readable when the user examines a solution.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
- type: Sprite
|
- type: Sprite
|
||||||
netsync: false
|
netsync: false
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
price: 50
|
price: 0
|
||||||
|
|
||||||
# This base type is used to cover all of the "obvious" things that should be doable to open-package food.
|
# This base type is used to cover all of the "obvious" things that should be doable to open-package food.
|
||||||
# Practically this means injection.
|
# Practically this means injection.
|
||||||
|
|||||||
@@ -389,6 +389,8 @@
|
|||||||
- Trash
|
- Trash
|
||||||
- type: Recyclable
|
- type: Recyclable
|
||||||
- type: SpaceGarbage
|
- type: SpaceGarbage
|
||||||
|
- type: StaticPrice
|
||||||
|
price: 0
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
noSpawn: true
|
noSpawn: true
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
amount: 1
|
amount: 1
|
||||||
- !type:PlantAdjustHealth
|
- !type:PlantAdjustHealth
|
||||||
amount: 0.5
|
amount: 0.5
|
||||||
|
pricePerUnit: 2
|
||||||
|
|
||||||
- type: reagent
|
- type: reagent
|
||||||
id: Vitamin
|
id: Vitamin
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
- !type:ModifyBleedAmount
|
- !type:ModifyBleedAmount
|
||||||
amount: -0.25
|
amount: -0.25
|
||||||
- !type:SatiateHunger #Numbers are balanced with this in mind + it helps limit how much healing you can get from food
|
- !type:SatiateHunger #Numbers are balanced with this in mind + it helps limit how much healing you can get from food
|
||||||
|
pricePerUnit: 2.5
|
||||||
|
|
||||||
- type: reagent
|
- type: reagent
|
||||||
id: Protein
|
id: Protein
|
||||||
@@ -57,4 +59,5 @@
|
|||||||
- !type:ModifyBloodLevel
|
- !type:ModifyBloodLevel
|
||||||
amount: 1 # weaker than iron but pretty good all things considered
|
amount: 1 # weaker than iron but pretty good all things considered
|
||||||
- !type:SatiateHunger
|
- !type:SatiateHunger
|
||||||
|
pricePerUnit: 3
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user