Fix emote animations

This commit is contained in:
Aviu00
2024-01-17 09:41:50 +03:00
parent ab754016e3
commit 10402ae26d
4 changed files with 33 additions and 29 deletions

View File

@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Shared.Animations; using Content.Shared.Animations;
using Robust.Client.Animations; using Robust.Client.Animations;
using Robust.Shared.Animations; using Robust.Shared.Animations;
@@ -16,7 +17,7 @@ public class EmoteAnimationSystem : EntitySystem
SubscribeLocalEvent<EmoteAnimationComponent, ComponentHandleState>(OnHandleState); SubscribeLocalEvent<EmoteAnimationComponent, ComponentHandleState>(OnHandleState);
// EmoteFlip animation // EmoteFlip animation
_emoteList.Add("EmoteFlip", (EntityUid uid) => _emoteList.Add("EmoteFlip", uid =>
{ {
var animationKey = "emoteAnimationKeyId"; var animationKey = "emoteAnimationKeyId";

View File

@@ -1,7 +1,7 @@
using System.Linq;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Content.Server.Actions; using Content.Server.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Animations; using Content.Shared.Animations;
using static Content.Shared.Animations.EmoteAnimationComponent; using static Content.Shared.Animations.EmoteAnimationComponent;
using Content.Server.Chat.Systems; using Content.Server.Chat.Systems;
@@ -35,20 +35,15 @@ public class EmoteAnimationSystem : EntitySystem
private void OnMapInint(EntityUid uid, EmoteAnimationComponent component, MapInitEvent args) private void OnMapInint(EntityUid uid, EmoteAnimationComponent component, MapInitEvent args)
{ {
foreach (var item in _proto.EnumeratePrototypes<InstantActionPrototype>()) foreach (var item in _proto.EnumeratePrototypes<EntityPrototype>())
{ {
InstantAction? action; if (item.ID.Length <= INSTANT_IDENTIFIER.Length ||
if (item.ID.Length > INSTANT_IDENTIFIER.Length && item.ID[..INSTANT_IDENTIFIER.Length] != INSTANT_IDENTIFIER)
item.ID[..INSTANT_IDENTIFIER.Length] == INSTANT_IDENTIFIER)
action = new InstantAction(item);
else
continue; continue;
if (action != null) EntityUid? action = null;
{ component.Actions.Add(action);
component.Actions.Add(action); _action.AddAction(uid, ref action, item.ID);
_action.AddAction(uid, action, null);
}
} }
} }

View File

@@ -1,5 +1,4 @@
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -8,7 +7,7 @@ namespace Content.Shared.Animations;
/// <summary> /// <summary>
/// Event for playing animations /// Event for playing animations
/// </summary> /// </summary>
public class EmoteActionEvent : InstantActionEvent public sealed partial class EmoteActionEvent : InstantActionEvent
{ {
[ViewVariables] [ViewVariables]
[DataField("emote", readOnly: true, required: true)] [DataField("emote", readOnly: true, required: true)]
@@ -17,12 +16,12 @@ public class EmoteActionEvent : InstantActionEvent
[RegisterComponent] [RegisterComponent]
[NetworkedComponent] [NetworkedComponent]
public class EmoteAnimationComponent : Component public sealed partial class EmoteAnimationComponent : Component
{ {
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public string AnimationId = "none"; public string AnimationId = "none";
public readonly List<InstantAction> Actions = new(); public readonly List<EntityUid?> Actions = new();
[Serializable, NetSerializable] [Serializable, NetSerializable]
public class EmoteAnimationComponentState : ComponentState public class EmoteAnimationComponentState : ComponentState

View File

@@ -1,29 +1,38 @@
# flip animation # flip animation
- type: instantAction - type: entity
id: EmoteActionFlip id: EmoteActionFlip
name: emote-flip-action-name name: emote-flip-action-name
description: emote-flip-action-description description: emote-flip-action-description
icon: Interface/Actions/blight.png nospawn: true
event: !type:EmoteActionEvent components:
emote: EmoteFlip - type: InstantAction
icon: Interface/Actions/blight.png
event: !type:EmoteActionEvent
emote: EmoteFlip
# jump animation # jump animation
- type: instantAction - type: entity
id: EmoteActionJump id: EmoteActionJump
name: emote-jump-action-name name: emote-jump-action-name
description: emote-jump-action-description description: emote-jump-action-description
icon: Interface/Actions/blight.png nospawn: true
event: !type:EmoteActionEvent components:
emote: EmoteJump - type: InstantAction
icon: Interface/Actions/blight.png
event: !type:EmoteActionEvent
emote: EmoteJump
# turn around in 4 directions animation # turn around in 4 directions animation
- type: instantAction - type: entity
id: EmoteActionTurn id: EmoteActionTurn
name: emote-turn-action-name name: emote-turn-action-name
description: emote-turn-action-description description: emote-turn-action-description
icon: Interface/Actions/blight.png nospawn: true
event: !type:EmoteActionEvent components:
emote: EmoteTurn - type: InstantAction
icon: Interface/Actions/blight.png
event: !type:EmoteActionEvent
emote: EmoteTurn
# Using EmoteAnimation from IC action chat # Using EmoteAnimation from IC action chat