- add: shared animation
This commit is contained in:
28
Content.Shared/_Amour/Animation/AnimationData.cs
Normal file
28
Content.Shared/_Amour/Animation/AnimationData.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._Amour.Animation;
|
||||
|
||||
[DataDefinition,Serializable,NetSerializable,Virtual]
|
||||
public partial class AnimationData
|
||||
{
|
||||
[DataField] public TimeSpan Length;
|
||||
[DataField] public List<AnimationTrackData> AnimationTracks;
|
||||
}
|
||||
|
||||
[DataDefinition, Serializable, NetSerializable]
|
||||
public sealed partial class AnimationTrackData
|
||||
{
|
||||
[DataField] public string ComponentType;
|
||||
[DataField] public string Property;
|
||||
[DataField] public AnimationInterpolationMode InterpolationMode;
|
||||
[DataField] public List<AnimationKeyData> KeyFrames;
|
||||
}
|
||||
|
||||
[DataDefinition, Serializable, NetSerializable]
|
||||
public sealed partial class AnimationKeyData
|
||||
{
|
||||
[DataField] public string Value;
|
||||
[DataField] public float KeyTime;
|
||||
}
|
||||
|
||||
32
Content.Shared/_Amour/Animation/AnimationMessages.cs
Normal file
32
Content.Shared/_Amour/Animation/AnimationMessages.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._Amour.Animation;
|
||||
|
||||
[Serializable,NetSerializable]
|
||||
public sealed class AnimationProtoStartMessage : EntityEventArgs
|
||||
{
|
||||
public NetEntity Owner;
|
||||
public string ProtoId;
|
||||
|
||||
public AnimationProtoStartMessage(NetEntity owner, string protoId)
|
||||
{
|
||||
Owner = owner;
|
||||
ProtoId = protoId;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable,NetSerializable]
|
||||
public sealed class AnimationStartMessage : EntityEventArgs
|
||||
{
|
||||
public NetEntity Owner;
|
||||
public AnimationData Data;
|
||||
public string Id;
|
||||
|
||||
public AnimationStartMessage(NetEntity owner, AnimationData data, string id)
|
||||
{
|
||||
Owner = owner;
|
||||
Data = data;
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
10
Content.Shared/_Amour/Animation/AnimationPrototype.cs
Normal file
10
Content.Shared/_Amour/Animation/AnimationPrototype.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._Amour.Animation;
|
||||
|
||||
[Prototype("animation"),Serializable,NetSerializable]
|
||||
public sealed partial class AnimationPrototype : AnimationData, IPrototype
|
||||
{
|
||||
[IdDataField] public string ID { get; private set; } = default!;
|
||||
}
|
||||
27
Content.Shared/_Amour/Animation/SharedAnimationSystem.cs
Normal file
27
Content.Shared/_Amour/Animation/SharedAnimationSystem.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Markdown.Value;
|
||||
|
||||
namespace Content.Shared._Amour.Animation;
|
||||
|
||||
public abstract class SharedAnimationSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ISerializationManager _serializationManager = default!;
|
||||
|
||||
public virtual void Play(EntityUid uid,ProtoId<AnimationPrototype> protoId)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Play(EntityUid uid,AnimationData data, string animationId = "funny")
|
||||
{
|
||||
}
|
||||
|
||||
public AnimationKeyData KeyFrame(object value, float keyTime)
|
||||
{
|
||||
return new AnimationKeyData()
|
||||
{
|
||||
KeyTime = keyTime,
|
||||
Value = _serializationManager.WriteValueAs<ValueDataNode>(value).Value
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user