Cargo economy balance (#11123)

Co-authored-by: Visne <39844191+Visne@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2022-09-15 11:53:17 +10:00
committed by GitHub
parent f4c38d74e1
commit ad7a851e27
113 changed files with 615 additions and 58 deletions

View File

@@ -9,6 +9,7 @@ using Content.Shared.MobState.Components;
using Robust.Shared.Console;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Server.Cargo.Systems;
@@ -111,6 +112,33 @@ public sealed class PricingSystem : EntitySystem
args.Price += component.Price;
}
/// <summary>
/// Get a rough price for an entityprototype. Does not consider contained entities.
/// </summary>
public double GetEstimatedPrice(EntityPrototype prototype, IComponentFactory? factory = null)
{
IoCManager.Resolve(ref factory);
var price = 0.0;
if (prototype.Components.TryGetValue(factory.GetComponentName(typeof(StaticPriceComponent)),
out var staticPriceProto))
{
var staticComp = (StaticPriceComponent) staticPriceProto.Component;
price += staticComp.Price;
}
if (prototype.Components.TryGetValue(factory.GetComponentName(typeof(StackPriceComponent)), out var stackpriceProto) &&
prototype.Components.TryGetValue(factory.GetComponentName(typeof(StackComponent)), out var stackProto))
{
var stackPrice = (StackPriceComponent) stackpriceProto.Component;
var stack = (StackComponent) stackProto.Component;
price += stack.Count * stackPrice.Price;
}
return price;
}
/// <summary>
/// Appraises an entity, returning it's price.
/// </summary>
@@ -123,7 +151,7 @@ public sealed class PricingSystem : EntitySystem
public double GetPrice(EntityUid uid)
{
var ev = new PriceCalculationEvent();
RaiseLocalEvent(uid, ref ev, true);
RaiseLocalEvent(uid, ref ev);
//TODO: Add an OpaqueToAppraisal component or similar for blocking the recursive descent into containers, or preventing material pricing.