MaterialComponent cleanup (#13326)
This commit is contained in:
@@ -163,6 +163,16 @@ public sealed class PricingSystem : EntitySystem
|
||||
return price;
|
||||
}
|
||||
|
||||
public double GetMaterialPrice(MaterialComponent component)
|
||||
{
|
||||
double price = 0;
|
||||
foreach (var (id, quantity) in component.Materials)
|
||||
{
|
||||
price += _prototypeManager.Index<MaterialPrototype>(id).Price * quantity;
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appraises an entity, returning it's price.
|
||||
/// </summary>
|
||||
@@ -181,10 +191,11 @@ public sealed class PricingSystem : EntitySystem
|
||||
|
||||
if (TryComp<MaterialComponent>(uid, out var material) && !HasComp<StackPriceComponent>(uid))
|
||||
{
|
||||
var matPrice = GetMaterialPrice(material);
|
||||
if (TryComp<StackComponent>(uid, out var stack))
|
||||
ev.Price += stack.Count * material.Materials.Sum(x => x.Price * material._materials[x.ID]);
|
||||
else
|
||||
ev.Price += material.Materials.Sum(x => x.Price);
|
||||
matPrice *= stack.Count;
|
||||
|
||||
ev.Price += matPrice;
|
||||
}
|
||||
|
||||
if (TryComp<ContainerManagerComponent>(uid, out var containers))
|
||||
|
||||
Reference in New Issue
Block a user