From 10402ae26d952acce795895b4dc3180c3809e01c Mon Sep 17 00:00:00 2001 From: Aviu00 Date: Wed, 17 Jan 2024 09:41:50 +0300 Subject: [PATCH] Fix emote animations --- .../White/Animations/EmoteAnimationSystem.cs | 3 +- .../White/Animations/EmoteAnimationSystem.cs | 19 ++++------- .../Animations/EmoteAnimationComponent.cs | 7 ++-- Resources/Prototypes/White/Actions/emotes.yml | 33 ++++++++++++------- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Content.Client/White/Animations/EmoteAnimationSystem.cs b/Content.Client/White/Animations/EmoteAnimationSystem.cs index 0e48a54a46..e7f0aa7fd9 100644 --- a/Content.Client/White/Animations/EmoteAnimationSystem.cs +++ b/Content.Client/White/Animations/EmoteAnimationSystem.cs @@ -1,3 +1,4 @@ +using System.Numerics; using Content.Shared.Animations; using Robust.Client.Animations; using Robust.Shared.Animations; @@ -16,7 +17,7 @@ public class EmoteAnimationSystem : EntitySystem SubscribeLocalEvent(OnHandleState); // EmoteFlip animation - _emoteList.Add("EmoteFlip", (EntityUid uid) => + _emoteList.Add("EmoteFlip", uid => { var animationKey = "emoteAnimationKeyId"; diff --git a/Content.Server/White/Animations/EmoteAnimationSystem.cs b/Content.Server/White/Animations/EmoteAnimationSystem.cs index 99998cc065..b8683c8b5b 100644 --- a/Content.Server/White/Animations/EmoteAnimationSystem.cs +++ b/Content.Server/White/Animations/EmoteAnimationSystem.cs @@ -1,7 +1,7 @@ +using System.Linq; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Content.Server.Actions; -using Content.Shared.Actions.ActionTypes; using Content.Shared.Animations; using static Content.Shared.Animations.EmoteAnimationComponent; using Content.Server.Chat.Systems; @@ -35,20 +35,15 @@ public class EmoteAnimationSystem : EntitySystem private void OnMapInint(EntityUid uid, EmoteAnimationComponent component, MapInitEvent args) { - foreach (var item in _proto.EnumeratePrototypes()) + foreach (var item in _proto.EnumeratePrototypes()) { - InstantAction? action; - if (item.ID.Length > INSTANT_IDENTIFIER.Length && - item.ID[..INSTANT_IDENTIFIER.Length] == INSTANT_IDENTIFIER) - action = new InstantAction(item); - else + if (item.ID.Length <= INSTANT_IDENTIFIER.Length || + item.ID[..INSTANT_IDENTIFIER.Length] != INSTANT_IDENTIFIER) continue; - if (action != null) - { - component.Actions.Add(action); - _action.AddAction(uid, action, null); - } + EntityUid? action = null; + component.Actions.Add(action); + _action.AddAction(uid, ref action, item.ID); } } diff --git a/Content.Shared/White/Animations/EmoteAnimationComponent.cs b/Content.Shared/White/Animations/EmoteAnimationComponent.cs index fde8fa8245..4e6e18de49 100644 --- a/Content.Shared/White/Animations/EmoteAnimationComponent.cs +++ b/Content.Shared/White/Animations/EmoteAnimationComponent.cs @@ -1,5 +1,4 @@ using Content.Shared.Actions; -using Content.Shared.Actions.ActionTypes; using Robust.Shared.GameStates; using Robust.Shared.Serialization; @@ -8,7 +7,7 @@ namespace Content.Shared.Animations; /// /// Event for playing animations /// -public class EmoteActionEvent : InstantActionEvent +public sealed partial class EmoteActionEvent : InstantActionEvent { [ViewVariables] [DataField("emote", readOnly: true, required: true)] @@ -17,12 +16,12 @@ public class EmoteActionEvent : InstantActionEvent [RegisterComponent] [NetworkedComponent] -public class EmoteAnimationComponent : Component +public sealed partial class EmoteAnimationComponent : Component { [ViewVariables(VVAccess.ReadWrite)] public string AnimationId = "none"; - public readonly List Actions = new(); + public readonly List Actions = new(); [Serializable, NetSerializable] public class EmoteAnimationComponentState : ComponentState diff --git a/Resources/Prototypes/White/Actions/emotes.yml b/Resources/Prototypes/White/Actions/emotes.yml index 500bb7f94f..c190c9c284 100644 --- a/Resources/Prototypes/White/Actions/emotes.yml +++ b/Resources/Prototypes/White/Actions/emotes.yml @@ -1,29 +1,38 @@ # flip animation -- type: instantAction +- type: entity id: EmoteActionFlip name: emote-flip-action-name description: emote-flip-action-description - icon: Interface/Actions/blight.png - event: !type:EmoteActionEvent - emote: EmoteFlip + nospawn: true + components: + - type: InstantAction + icon: Interface/Actions/blight.png + event: !type:EmoteActionEvent + emote: EmoteFlip # jump animation -- type: instantAction +- type: entity id: EmoteActionJump name: emote-jump-action-name description: emote-jump-action-description - icon: Interface/Actions/blight.png - event: !type:EmoteActionEvent - emote: EmoteJump + nospawn: true + components: + - type: InstantAction + icon: Interface/Actions/blight.png + event: !type:EmoteActionEvent + emote: EmoteJump # turn around in 4 directions animation -- type: instantAction +- type: entity id: EmoteActionTurn name: emote-turn-action-name description: emote-turn-action-description - icon: Interface/Actions/blight.png - event: !type:EmoteActionEvent - emote: EmoteTurn + nospawn: true + components: + - type: InstantAction + icon: Interface/Actions/blight.png + event: !type:EmoteActionEvent + emote: EmoteTurn # Using EmoteAnimation from IC action chat