2020-08-24 06:32:18 -04:00
|
|
|
using System;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.Animations;
|
|
|
|
|
using Robust.Client.GameObjects;
|
|
|
|
|
using Robust.Shared.Animations;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Light
|
2020-08-24 06:32:18 -04:00
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class LanternVisualizer : AppearanceVisualizer
|
2020-08-24 06:32:18 -04:00
|
|
|
{
|
2020-11-27 11:00:49 +01:00
|
|
|
private readonly Animation _radiatingLightAnimation = new()
|
2020-08-24 06:32:18 -04:00
|
|
|
{
|
|
|
|
|
Length = TimeSpan.FromSeconds(5),
|
|
|
|
|
AnimationTracks =
|
|
|
|
|
{
|
|
|
|
|
new AnimationTrackComponentProperty
|
|
|
|
|
{
|
|
|
|
|
ComponentType = typeof(PointLightComponent),
|
|
|
|
|
InterpolationMode = AnimationInterpolationMode.Linear,
|
|
|
|
|
Property = nameof(PointLightComponent.Radius),
|
|
|
|
|
KeyFrames =
|
|
|
|
|
{
|
|
|
|
|
new AnimationTrackProperty.KeyFrame(3.0f, 0),
|
|
|
|
|
new AnimationTrackProperty.KeyFrame(2.0f, 1.5f),
|
|
|
|
|
new AnimationTrackProperty.KeyFrame(3.0f, 3f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
{
|
|
|
|
|
base.OnChangeData(component);
|
|
|
|
|
|
2021-10-21 12:45:46 +11:00
|
|
|
if (!component.Initialized)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-08-24 06:32:18 -04:00
|
|
|
PlayAnimation(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlayAnimation(AppearanceComponent component)
|
|
|
|
|
{
|
|
|
|
|
component.Owner.EnsureComponent(out AnimationPlayerComponent animationPlayer);
|
|
|
|
|
if (animationPlayer.HasRunningAnimation("radiatingLight")) return;
|
|
|
|
|
animationPlayer.Play(_radiatingLightAnimation, "radiatingLight");
|
|
|
|
|
animationPlayer.AnimationCompleted += s => animationPlayer.Play(_radiatingLightAnimation, s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|