Files
RobustToolbox/Robust.Client/Animations/AnimationTrackComponentProperty.cs
T
Pieter-Jan BriersandGitHub 5d5b897a9b Property animations track (#867)
* WiP property animations system

* Use better lerp for Angle property animations.

* Fix handling of offset in sprite component.

* Allow animating some sprite layer properties.

* Allow animating some Transform properties.

Obviously not advisable for server entities, but great for client side entities!

* Improve animation property interpolation handling.

Added a "previous" mode.
Made values that cannot be sanely interpolated fall back to this mode.

* Improve some animation docs.
2019-09-17 22:57:12 +02:00

30 lines
857 B
C#

using System;
using JetBrains.Annotations;
using Robust.Shared.Animations;
using Robust.Shared.Interfaces.GameObjects;
namespace Robust.Client.Animations
{
[UsedImplicitly]
public sealed class AnimationTrackComponentProperty : AnimationTrackProperty
{
public Type ComponentType { get; set; }
public string Property { get; set; }
protected override void ApplyProperty(object context, object value)
{
var entity = (IEntity) context;
var component = entity.GetComponent(ComponentType);
if (component is IAnimationProperties properties)
{
properties.SetAnimatableProperty(Property, value);
}
else
{
AnimationHelper.SetAnimatableProperty(component, Property, value);
}
}
}
}