mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* 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
27 lines
865 B
C#
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);
|
|
}
|
|
}
|