using Content.Server.Cargo.Components;
using Content.Server.Cargo.Systems;
using Content.Shared.Cargo.Prototypes;
+using Content.Shared.Stacks;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
if (entManager.TryGetComponent<StaticPriceComponent>(ent, out var staticpricecomp))
{
Assert.That(staticpricecomp.Price, Is.EqualTo(0),
- $"The prototype {proto} have a StackPriceComponent and StaticPriceComponent whose values are not compatible with each other.");
+ $"The prototype {proto} has a StackPriceComponent and StaticPriceComponent whose values are not compatible with each other.");
}
}
+
+ if (entManager.HasComponent<StackComponent>(ent))
+ {
+ if (entManager.TryGetComponent<StaticPriceComponent>(ent, out var staticpricecomp))
+ {
+ Assert.That(staticpricecomp.Price, Is.EqualTo(0),
+ $"The prototype {proto} has a StackComponent and StaticPriceComponent whose values are not compatible with each other.");
+ }
+ }
+
entManager.DeleteEntity(ent);
}
mapManager.DeleteMap(mapId);
});
await pairTracker.CleanReturnAsync();
}
+
+ [Test]
+ public async Task StackPrice()
+ {
+ const string StackProto = @"
+- type: entity
+ id: A
+
+- type: stack
+ id: StackProto
+ spawn: A
+
+- type: entity
+ id: StackEnt
+ components:
+ - type: StackPrice
+ price: 20
+ - type: Stack
+ stackType: StackProto
+ count: 5
+";
+
+ await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = StackProto});
+ var server = pairTracker.Pair.Server;
+
+ var entManager = server.ResolveDependency<IEntityManager>();
+ var priceSystem = entManager.System<PricingSystem>();
+
+ var ent = entManager.SpawnEntity("StackEnt", MapCoordinates.Nullspace);
+ var price = priceSystem.GetPrice(ent);
+ Assert.That(price, Is.EqualTo(100.0));
+
+ await pairTracker.CleanReturnAsync();
+ }
}
var price = ev.Price;
price += GetMaterialsPrice(prototype);
price += GetSolutionsPrice(prototype);
+ // Can't use static price with stackprice
+ var oldPrice = price;
price += GetStackPrice(prototype);
- price += GetStaticPrice(prototype);
+
+ if (oldPrice.Equals(price))
+ {
+ price += GetStaticPrice(prototype);
+ }
// TODO: Proper container support.
// DO NOT FORGET TO UPDATE ESTIMATED PRICING
price += GetMaterialsPrice(uid);
price += GetSolutionsPrice(uid);
+
+ // Can't use static price with stackprice
+ var oldPrice = price;
price += GetStackPrice(uid);
- price += GetStaticPrice(uid);
+
+ if (oldPrice.Equals(price))
+ {
+ price += GetStaticPrice(uid);
+ }
if (TryComp<ContainerManagerComponent>(uid, out var containers))
{