Fix damage flipflops (#13666)
This commit is contained in:
@@ -65,16 +65,22 @@ namespace Content.Client.Buckle
|
||||
|
||||
private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals))
|
||||
return;
|
||||
|
||||
if (!_appearanceSystem.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
|
||||
!_appearanceSystem.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
|
||||
!buckled ||
|
||||
args.Sprite == null)
|
||||
{
|
||||
_rotationVisualizerSystem.SetHorizontalAngle(uid, RotationVisualsComponent.DefaultRotation, rotVisuals);
|
||||
return;
|
||||
}
|
||||
|
||||
// Animate strapping yourself to something at a given angle
|
||||
_rotationVisualizerSystem.AnimateSpriteRotation(args.Sprite, Angle.FromDegrees(angle), 0.125f);
|
||||
_rotationVisualizerSystem.SetHorizontalAngle(uid, Angle.FromDegrees(angle), rotVisuals);
|
||||
// TODO: Dump this when buckle is better
|
||||
_rotationVisualizerSystem.AnimateSpriteRotation(uid, args.Sprite, rotVisuals.HorizontalRotation, 0.125f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,18 @@ namespace Content.Client.Rotation;
|
||||
|
||||
public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsComponent>
|
||||
{
|
||||
public void SetHorizontalAngle(EntityUid uid, Angle angle, RotationVisualsComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
if (component.HorizontalRotation.Equals(angle))
|
||||
return;
|
||||
|
||||
component.HorizontalRotation = angle;
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, RotationVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
base.OnAppearanceChange(uid, component, ref args);
|
||||
@@ -20,10 +32,10 @@ public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsC
|
||||
switch (state)
|
||||
{
|
||||
case RotationState.Vertical:
|
||||
AnimateSpriteRotation(args.Sprite, component.VerticalRotation, component.AnimationTime);
|
||||
AnimateSpriteRotation(uid, args.Sprite, component.VerticalRotation, component.AnimationTime);
|
||||
break;
|
||||
case RotationState.Horizontal:
|
||||
AnimateSpriteRotation(args.Sprite, component.HorizontalRotation, component.AnimationTime);
|
||||
AnimateSpriteRotation(uid, args.Sprite, component.HorizontalRotation, component.AnimationTime);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -31,14 +43,14 @@ public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsC
|
||||
/// <summary>
|
||||
/// Rotates a sprite between two animated keyframes given a certain time.
|
||||
/// </summary>
|
||||
public void AnimateSpriteRotation(SpriteComponent spriteComp, Angle rotation, float animationTime)
|
||||
public void AnimateSpriteRotation(EntityUid uid, SpriteComponent spriteComp, Angle rotation, float animationTime)
|
||||
{
|
||||
if (spriteComp.Rotation.Equals(rotation))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var animationComp = EnsureComp<AnimationPlayerComponent>(spriteComp.Owner);
|
||||
var animationComp = EnsureComp<AnimationPlayerComponent>(uid);
|
||||
const string animationKey = "rotate";
|
||||
// Stop the current rotate animation and then start a new one
|
||||
if (AnimationSystem.HasRunningAnimation(animationComp, animationKey))
|
||||
|
||||
@@ -3,11 +3,12 @@ namespace Content.Client.Rotation;
|
||||
[RegisterComponent]
|
||||
public sealed class RotationVisualsComponent : Component
|
||||
{
|
||||
public static readonly Angle DefaultRotation = Angle.FromDegrees(90);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Angle VerticalRotation = 0;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Angle HorizontalRotation = Angle.FromDegrees(90);
|
||||
[ViewVariables(VVAccess.ReadWrite)] public Angle HorizontalRotation = DefaultRotation;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float AnimationTime = 0.125f;
|
||||
|
||||
Reference in New Issue
Block a user