Property animations test component. (#340)
This commit is contained in:
committed by
GitHub
parent
ed1271c30b
commit
6c97b63e59
@@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using Robust.Client.Animations;
|
||||||
|
using Robust.Client.GameObjects.Components.Animations;
|
||||||
|
using Robust.Client.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Shared.Animations;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
|
namespace Content.Client.GameObjects.Components
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class AnimationsTestComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "AnimationsTest";
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
var animations = Owner.GetComponent<AnimationPlayerComponent>();
|
||||||
|
animations.Play(new Animation
|
||||||
|
{
|
||||||
|
Length = TimeSpan.FromSeconds(20),
|
||||||
|
AnimationTracks =
|
||||||
|
{
|
||||||
|
new AnimationTrackComponentProperty
|
||||||
|
{
|
||||||
|
ComponentType = typeof(ITransformComponent),
|
||||||
|
Property = nameof(ITransformComponent.LocalRotation),
|
||||||
|
InterpolationMode = AnimationInterpolationMode.Linear,
|
||||||
|
KeyFrames =
|
||||||
|
{
|
||||||
|
new AnimationTrackProperty.KeyFrame(Angle.Zero, 0),
|
||||||
|
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(1440), 20)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new AnimationTrackComponentProperty
|
||||||
|
{
|
||||||
|
ComponentType = typeof(ISpriteComponent),
|
||||||
|
Property = "layer/0/texture",
|
||||||
|
KeyFrames =
|
||||||
|
{
|
||||||
|
new AnimationTrackProperty.KeyFrame("Objects/toolbox_r.png", 0),
|
||||||
|
new AnimationTrackProperty.KeyFrame("Objects/Toolbox_b.png", 5),
|
||||||
|
new AnimationTrackProperty.KeyFrame("Objects/Toolbox_y.png", 5),
|
||||||
|
new AnimationTrackProperty.KeyFrame("Objects/toolbox_r.png", 5),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "yes");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Resources/Prototypes/Entities/Effects/AnimationsTest.yml
Normal file
9
Resources/Prototypes/Entities/Effects/AnimationsTest.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
- type: entity
|
||||||
|
id: AnimationsTest
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
texture: Objects/Toolbox_b.png
|
||||||
|
offset: 2, 0
|
||||||
|
directional: false
|
||||||
|
- type: AnimationPlayer
|
||||||
|
- type: AnimationsTest
|
||||||
Reference in New Issue
Block a user