2020-07-24 14:51:18 +02:00
|
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Pointing.Components;
|
2020-07-24 14:51:18 +02:00
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Client.Animations;
|
|
|
|
|
|
using Robust.Client.GameObjects;
|
|
|
|
|
|
using Robust.Shared.Animations;
|
2021-11-22 23:22:59 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 11:55:25 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2020-07-24 14:51:18 +02:00
|
|
|
|
using Robust.Shared.Maths;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Pointing
|
2020-07-24 14:51:18 +02:00
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class RoguePointingArrowVisualizer : AppearanceVisualizer
|
2020-07-24 14:51:18 +02:00
|
|
|
|
{
|
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnChangeData(component);
|
|
|
|
|
|
|
|
|
|
|
|
if (component.TryGetData<double>(RoguePointingArrowVisuals.Rotation, out var degrees))
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRotation(component, Angle.FromDegrees(degrees));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetRotation(AppearanceComponent component, Angle rotation)
|
|
|
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
|
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
2020-07-24 14:51:18 +02:00
|
|
|
|
|
2021-12-03 15:53:09 +01:00
|
|
|
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(sprite.Owner, out AnimationPlayerComponent? animation))
|
2020-07-24 14:51:18 +02:00
|
|
|
|
{
|
|
|
|
|
|
sprite.Rotation = rotation;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (animation.HasRunningAnimation("rotate"))
|
|
|
|
|
|
{
|
|
|
|
|
|
animation.Stop("rotate");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
animation.Play(new Animation
|
|
|
|
|
|
{
|
|
|
|
|
|
Length = TimeSpan.FromSeconds(0.125),
|
|
|
|
|
|
AnimationTracks =
|
|
|
|
|
|
{
|
|
|
|
|
|
new AnimationTrackComponentProperty
|
|
|
|
|
|
{
|
|
|
|
|
|
ComponentType = typeof(ISpriteComponent),
|
|
|
|
|
|
Property = nameof(ISpriteComponent.Rotation),
|
|
|
|
|
|
InterpolationMode = AnimationInterpolationMode.Linear,
|
|
|
|
|
|
KeyFrames =
|
|
|
|
|
|
{
|
|
|
|
|
|
new AnimationTrackProperty.KeyFrame(sprite.Rotation, 0),
|
|
|
|
|
|
new AnimationTrackProperty.KeyFrame(rotation, 0.125f)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}, "rotate");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|