Files
wwdpublic/Content.Server/Anomaly/Effects/AnomalyCoreSystem.cs
Nemanja 850e75a073 GORILLA Gauntlets (#23012)
* GORILLA gauntlets

* oh shit this too

(cherry picked from commit 9bd03824ac863cb4d87bfc984dcc163b84926649)
2024-01-22 18:47:45 +01:00

28 lines
874 B
C#

using Content.Server.Cargo.Systems;
using Content.Shared.Anomaly.Components;
using Robust.Shared.Timing;
namespace Content.Server.Anomaly.Effects;
/// <summary>
/// This component reduces the value of the entity during decay
/// </summary>
public sealed class AnomalyCoreSystem : EntitySystem
{
[Dependency] private readonly 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);
}
}