Files
tbd-station-14/Content.Server/Armor/ArmorSystem.cs
slarticodefast fef4187995 Move PriceCalculationEvent and EstimatedPriceCalculationEvent to shared (#37782)
* moce PriceCalculationEvent to shared

* Update Content.Shared/Cargo/PriceCalculationEvent.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
2025-05-24 19:36:38 +02:00

35 lines
1.1 KiB
C#

using Content.Shared.Armor;
using Content.Shared.Cargo;
using Robust.Shared.Prototypes;
using Content.Shared.Damage.Prototypes;
namespace Content.Server.Armor;
/// <inheritdoc/>
public sealed class ArmorSystem : SharedArmorSystem
{
[Dependency] private readonly IPrototypeManager _protoManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ArmorComponent, PriceCalculationEvent>(GetArmorPrice);
}
private void GetArmorPrice(EntityUid uid, ArmorComponent component, ref PriceCalculationEvent args)
{
foreach (var modifier in component.Modifiers.Coefficients)
{
var damageType = _protoManager.Index<DamageTypePrototype>(modifier.Key);
args.Price += component.PriceMultiplier * damageType.ArmorPriceCoefficient * 100 * (1 - modifier.Value);
}
foreach (var modifier in component.Modifiers.FlatReduction)
{
var damageType = _protoManager.Index<DamageTypePrototype>(modifier.Key);
args.Price += component.PriceMultiplier * damageType.ArmorPriceFlat * modifier.Value;
}
}
}