fix: частичный фикс эмоутов
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
using Content.Shared.White.Animations;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Animations;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Client.GameObjects;
|
||||
using static Content.Shared.Animations.EmoteAnimationComponent;
|
||||
namespace Content.Client.Animations;
|
||||
using static Content.Shared.White.Animations.EmoteAnimationComponent;
|
||||
|
||||
public class EmoteAnimationSystem : EntitySystem
|
||||
namespace Content.Client.White.Animations;
|
||||
|
||||
public sealed class EmoteAnimationSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AnimationPlayerSystem _animationSystem = default!;
|
||||
|
||||
private readonly Dictionary<string, Action<EntityUid>> _emoteList = new();
|
||||
|
||||
private const string AnimationKey = "emoteAnimationKeyId";
|
||||
private const string AnimationKeyTurn = "emoteAnimationKeyId_rotate";
|
||||
|
||||
//OnVerbsResponse?.Invoke(msg);
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -19,16 +25,13 @@ public class EmoteAnimationSystem : EntitySystem
|
||||
// EmoteFlip animation
|
||||
_emoteList.Add("EmoteFlip", uid =>
|
||||
{
|
||||
var animationKey = "emoteAnimationKeyId";
|
||||
|
||||
if (_animationSystem.HasRunningAnimation(uid, animationKey))
|
||||
if (_animationSystem.HasRunningAnimation(uid, AnimationKey))
|
||||
return;
|
||||
|
||||
var baseAngle = Angle.Zero;
|
||||
if (EntityManager.TryGetComponent(uid, out SpriteComponent? sprite))
|
||||
{
|
||||
if (sprite != null)
|
||||
baseAngle = sprite.Rotation;
|
||||
baseAngle = sprite.Rotation;
|
||||
}
|
||||
|
||||
var animation = new Animation
|
||||
@@ -43,7 +46,7 @@ public class EmoteAnimationSystem : EntitySystem
|
||||
InterpolationMode = AnimationInterpolationMode.Linear,
|
||||
KeyFrames =
|
||||
{
|
||||
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(baseAngle.Degrees), 0f),
|
||||
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(baseAngle.Degrees - 10), 0f),
|
||||
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(baseAngle.Degrees + 180), 0.25f),
|
||||
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(baseAngle.Degrees + 360), 0.25f),
|
||||
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(baseAngle.Degrees), 0f),
|
||||
@@ -52,14 +55,13 @@ public class EmoteAnimationSystem : EntitySystem
|
||||
}
|
||||
};
|
||||
|
||||
_animationSystem.Play(uid, animation, animationKey);
|
||||
_animationSystem.Play(uid, animation, AnimationKey);
|
||||
});
|
||||
// EmoteJump animation
|
||||
_emoteList.Add("EmoteJump", (EntityUid uid) =>
|
||||
{
|
||||
var animationKey = "emoteAnimationKeyId";
|
||||
|
||||
if (_animationSystem.HasRunningAnimation(uid, animationKey))
|
||||
// EmoteJump animation
|
||||
_emoteList.Add("EmoteJump", uid =>
|
||||
{
|
||||
if (_animationSystem.HasRunningAnimation(uid, AnimationKey))
|
||||
return;
|
||||
|
||||
var animation = new Animation
|
||||
@@ -82,19 +84,18 @@ public class EmoteAnimationSystem : EntitySystem
|
||||
}
|
||||
};
|
||||
|
||||
_animationSystem.Play(uid, animation, animationKey);
|
||||
_animationSystem.Play(uid, animation, AnimationKey);
|
||||
});
|
||||
// EmoteTurn animation
|
||||
_emoteList.Add("EmoteTurn", (EntityUid uid) =>
|
||||
{
|
||||
var animationKey = "emoteAnimationKeyId_rotate"; // it needs for only rotate anim
|
||||
|
||||
if (_animationSystem.HasRunningAnimation(uid, animationKey))
|
||||
// EmoteTurn animation
|
||||
_emoteList.Add("EmoteTurn", uid =>
|
||||
{
|
||||
if (_animationSystem.HasRunningAnimation(uid, AnimationKeyTurn))
|
||||
return;
|
||||
|
||||
var animation = new Animation
|
||||
{
|
||||
Length = TimeSpan.FromMilliseconds(600), // Пока пусть на 0.6 секунд. В идеале бы до 0.9 на 3 поворота
|
||||
Length = TimeSpan.FromMilliseconds(900),
|
||||
AnimationTracks =
|
||||
{
|
||||
new AnimationTrackComponentProperty
|
||||
@@ -118,7 +119,7 @@ public class EmoteAnimationSystem : EntitySystem
|
||||
}
|
||||
};
|
||||
|
||||
_animationSystem.Play(uid, animation, animationKey);
|
||||
_animationSystem.Play(uid, animation, AnimationKeyTurn);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -128,9 +129,9 @@ public class EmoteAnimationSystem : EntitySystem
|
||||
return;
|
||||
|
||||
component.AnimationId = state.AnimationId;
|
||||
if (_emoteList.ContainsKey(component.AnimationId))
|
||||
if (_emoteList.TryGetValue(component.AnimationId, out var value))
|
||||
{
|
||||
_emoteList[component.AnimationId].Invoke(uid);
|
||||
value.Invoke(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Animations;
|
||||
namespace Content.Server.White.Animations;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class DancingComponent : Component
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using Content.Server.White.Animations;
|
||||
using Content.Shared.Animations;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.White.Animations;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Animations;
|
||||
namespace Content.Server.White.Animations;
|
||||
|
||||
public sealed class DancingSystem : EntitySystem
|
||||
{
|
||||
@@ -13,7 +12,7 @@ public sealed class DancingSystem : EntitySystem
|
||||
[Dependency] private readonly EmoteAnimationSystem _emoteAnimation = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
|
||||
private readonly string[] _emoteList = {"EmoteFlip", "EmoteTurn"};
|
||||
private readonly string[] _emoteList = { "EmoteFlip", "EmoteTurn" };
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
||||
@@ -1,31 +1,17 @@
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Shared.Animations;
|
||||
using Content.Shared.Chat.Prototypes;
|
||||
using Content.Shared.White.Animations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Animations.EmoteAnimationComponent;
|
||||
using static Content.Shared.White.Animations.EmoteAnimationComponent;
|
||||
|
||||
namespace Content.Server.White.Animations;
|
||||
|
||||
public sealed class EmoteAnimationSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionsSystem _action = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
|
||||
/// <summary>
|
||||
/// We write 'EmoteAction' word before id name for instant action.
|
||||
/// Example: EmoteActionJump, EmoteActionFlip and etc.
|
||||
/// </summary>
|
||||
private const string InstantIdentifier = "EmoteAction";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<EmoteAnimationComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<EmoteAnimationComponent, MapInitEvent>(OnMapInint);
|
||||
SubscribeLocalEvent<EmoteAnimationComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<EmoteAnimationComponent, EmoteEvent>(OnEmote);
|
||||
SubscribeLocalEvent<EmoteAnimationComponent, EmoteActionEvent>(OnEmoteAction);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, EmoteAnimationComponent component, ref ComponentGetState args)
|
||||
@@ -33,28 +19,6 @@ public sealed class EmoteAnimationSystem : EntitySystem
|
||||
args.State = new EmoteAnimationComponentState(component.AnimationId);
|
||||
}
|
||||
|
||||
private void OnMapInint(EntityUid uid, EmoteAnimationComponent component, MapInitEvent args)
|
||||
{
|
||||
foreach (var item in _proto.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (item.ID.Length <= InstantIdentifier.Length ||
|
||||
item.ID[..InstantIdentifier.Length] != InstantIdentifier)
|
||||
continue;
|
||||
|
||||
EntityUid? action = null;
|
||||
component.Actions.Add(action);
|
||||
_action.AddAction(uid, ref action, item.ID);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, EmoteAnimationComponent component, ComponentShutdown args)
|
||||
{
|
||||
foreach (var item in component.Actions)
|
||||
{
|
||||
_action.RemoveAction(uid, item);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEmote(EntityUid uid, EmoteAnimationComponent component, ref EmoteEvent args)
|
||||
{
|
||||
if (args.Handled || !args.Emote.Category.HasFlag(EmoteCategory.Gesture))
|
||||
@@ -63,12 +27,6 @@ public sealed class EmoteAnimationSystem : EntitySystem
|
||||
PlayEmoteAnimation(uid, component, args.Emote.ID);
|
||||
}
|
||||
|
||||
private void OnEmoteAction(EntityUid uid, EmoteAnimationComponent component, EmoteActionEvent args)
|
||||
{
|
||||
PlayEmoteAnimation(uid, component, args.Emote);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
public void PlayEmoteAnimation(EntityUid uid, EmoteAnimationComponent component, string emoteId)
|
||||
{
|
||||
component.AnimationId = emoteId;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using Content.Server.Animations;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.White.Animations;
|
||||
using Content.Server.White.AspectsSystem.Aspects.Components;
|
||||
using Content.Server.White.AspectsSystem.Base;
|
||||
using Content.Shared.Animations;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.White.Animations;
|
||||
|
||||
namespace Content.Server.White.AspectsSystem.Aspects;
|
||||
|
||||
@@ -16,7 +16,11 @@ public sealed class DancingAspect : AspectSystem<DancingAspectComponent>
|
||||
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(HandleLateJoin);
|
||||
}
|
||||
|
||||
protected override void Started(EntityUid uid, DancingAspectComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
||||
protected override void Started(
|
||||
EntityUid uid,
|
||||
DancingAspectComponent component,
|
||||
GameRuleComponent gameRule,
|
||||
GameRuleStartedEvent args)
|
||||
{
|
||||
base.Started(uid, component, gameRule, args);
|
||||
var query = EntityQueryEnumerator<EmoteAnimationComponent, MobStateComponent>();
|
||||
|
||||
@@ -2,29 +2,25 @@ using Content.Shared.Actions;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Animations;
|
||||
namespace Content.Shared.White.Animations;
|
||||
|
||||
/// <summary>
|
||||
/// Event for playing animations
|
||||
/// </summary>
|
||||
public sealed partial class EmoteActionEvent : InstantActionEvent
|
||||
{
|
||||
[ViewVariables]
|
||||
[DataField("emote", readOnly: true, required: true)]
|
||||
[ViewVariables, DataField("emote", readOnly: true, required: true)]
|
||||
public string Emote = default!;
|
||||
};
|
||||
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class EmoteAnimationComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string AnimationId = "none";
|
||||
|
||||
public readonly List<EntityUid?> Actions = new();
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class EmoteAnimationComponentState : ComponentState
|
||||
public partial class EmoteAnimationComponentState : ComponentState
|
||||
{
|
||||
public string AnimationId { get; init; }
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
emote-flip-action-name = Сальто
|
||||
emote-flip-action-description = Сделать крутой акработический трюк!
|
||||
emote-jump-action-name = Подпрыгнуть
|
||||
emote-jump-action-description = Подпрыгни из-за радости или испуга от мыши.
|
||||
emote-turn-action-name = Танцевать
|
||||
emote-turn-action-description = You spin me right round baby...
|
||||
@@ -1,40 +1,3 @@
|
||||
# flip animation
|
||||
- type: entity
|
||||
id: EmoteActionFlip
|
||||
name: emote-flip-action-name
|
||||
description: emote-flip-action-description
|
||||
noSpawn: true
|
||||
components:
|
||||
- type: InstantAction
|
||||
icon: White/Actions/EmoteFlip.png
|
||||
event: !type:EmoteActionEvent
|
||||
emote: EmoteFlip
|
||||
|
||||
# jump animation
|
||||
- type: entity
|
||||
id: EmoteActionJump
|
||||
name: emote-jump-action-name
|
||||
description: emote-jump-action-description
|
||||
noSpawn: true
|
||||
components:
|
||||
- type: InstantAction
|
||||
icon: White/Actions/EmoteJump.png
|
||||
event: !type:EmoteActionEvent
|
||||
emote: EmoteJump
|
||||
|
||||
# turn around in 4 directions animation
|
||||
- type: entity
|
||||
id: EmoteActionTurn
|
||||
name: emote-turn-action-name
|
||||
description: emote-turn-action-description
|
||||
noSpawn: true
|
||||
components:
|
||||
- type: InstantAction
|
||||
icon: White/Actions/EmoteTurn.png
|
||||
event: !type:EmoteActionEvent
|
||||
emote: EmoteTurn
|
||||
|
||||
|
||||
# Using EmoteAnimation from IC action chat
|
||||
- type: emote
|
||||
id: EmoteFlip
|
||||
|
||||
Reference in New Issue
Block a user