CatStation/Content.Server/Anomaly/Effects/AnomalyCoreSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

27 lines
865 B
C#

using Content.Shared.Anomaly.Components;
using Content.Shared.Cargo;
using Robust.Shared.Timing;
namespace Content.Server.Anomaly.Effects;
/// <summary>
/// This component reduces the value of the entity during decay
/// </summary>
public sealed partial class AnomalyCoreSystem : EntitySystem
{
[Dependency] private IGameTiming _gameTiming = default!;
public override void Initialize()
{
SubscribeLocalEvent<AnomalyCoreComponent, PriceCalculationEvent>(OnGetPrice);
}
private void OnGetPrice(Entity<AnomalyCoreComponent> core, ref PriceCalculationEvent args)
{
var timeLeft = core.Comp.DecayMoment - _gameTiming.CurTime;
var lerp = timeLeft.TotalSeconds / core.Comp.TimeToDecay;
lerp = Math.Clamp(lerp, 0, 1);
args.Price = MathHelper.Lerp(core.Comp.EndPrice, core.Comp.StartPrice, lerp);
}
}