CatStation/Content.Client/Light/EntitySystems/LightFadeSystem.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

46 lines
1.5 KiB
C#

using Content.Client.Light.Components;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;
namespace Content.Client.Light.EntitySystems;
public sealed partial class LightFadeSystem : EntitySystem
{
[Dependency] private AnimationPlayerSystem _player = default!;
private const string FadeTrack = "light-fade";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LightFadeComponent, ComponentStartup>(OnFadeStartup);
}
private void OnFadeStartup(EntityUid uid, LightFadeComponent component, ComponentStartup args)
{
if (!TryComp<PointLightComponent>(uid, out var light))
return;
var animation = new Animation()
{
Length = TimeSpan.FromSeconds(component.Duration),
AnimationTracks =
{
new AnimationTrackComponentProperty()
{
Property = nameof(PointLightComponent.Energy),
ComponentType = typeof(PointLightComponent),
InterpolationMode = AnimationInterpolationMode.Cubic,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(light.Energy, 0f),
new AnimationTrackProperty.KeyFrame(0f, component.Duration)
}
}
}
};
_player.Play(uid, animation, FadeTrack);
}
}