Fix rotation visuals desync & appearance state spam (#23016)
* Fix rotation visuals desync * :bucklemeup: * A
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Content.Client.Rotation;
|
||||
using Content.Shared.Buckle;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Rotation;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
@@ -56,17 +57,15 @@ internal sealed class BuckleSystem : SharedBuckleSystem
|
||||
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals))
|
||||
return;
|
||||
|
||||
if (!Appearance.TryGetData<int>(uid, StrapVisuals.RotationAngle, out var angle, args.Component) ||
|
||||
!Appearance.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
|
||||
if (!Appearance.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
|
||||
!buckled ||
|
||||
args.Sprite == null)
|
||||
{
|
||||
_rotationVisualizerSystem.SetHorizontalAngle(uid, rotVisuals.DefaultRotation, rotVisuals);
|
||||
_rotationVisualizerSystem.SetHorizontalAngle((uid, rotVisuals), rotVisuals.DefaultRotation);
|
||||
return;
|
||||
}
|
||||
|
||||
// Animate strapping yourself to something at a given angle
|
||||
_rotationVisualizerSystem.SetHorizontalAngle(uid, Angle.FromDegrees(angle), rotVisuals);
|
||||
// TODO: Dump this when buckle is better
|
||||
_rotationVisualizerSystem.AnimateSpriteRotation(uid, args.Sprite, rotVisuals.HorizontalRotation, 0.125f);
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
using Content.Shared.Chemistry;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Chemistry.Visualizers
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed partial class SolutionContainerVisualsComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public int MaxFillLevels = 0;
|
||||
[DataField]
|
||||
public string? FillBaseName = null;
|
||||
[DataField]
|
||||
public SolutionContainerLayers Layer = SolutionContainerLayers.Fill;
|
||||
[DataField]
|
||||
public SolutionContainerLayers BaseLayer = SolutionContainerLayers.Base;
|
||||
[DataField]
|
||||
public SolutionContainerLayers OverlayLayer = SolutionContainerLayers.Overlay;
|
||||
[DataField]
|
||||
public bool ChangeColor = true;
|
||||
[DataField]
|
||||
public string? EmptySpriteName = null;
|
||||
[DataField]
|
||||
public Color EmptySpriteColor = Color.White;
|
||||
[DataField]
|
||||
public bool Metamorphic = false;
|
||||
[DataField]
|
||||
public SpriteSpecifier? MetamorphicDefaultSprite;
|
||||
[DataField]
|
||||
public LocId MetamorphicNameFull = "transformable-container-component-glass";
|
||||
|
||||
/// <summary>
|
||||
/// Which solution of the SolutionContainerManagerComponent to represent.
|
||||
/// If not set, will work as default.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public string? SolutionName;
|
||||
|
||||
[DataField]
|
||||
public string InitialName = string.Empty;
|
||||
|
||||
[DataField]
|
||||
public string InitialDescription = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Rounding;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
@@ -5,29 +5,26 @@ using Robust.Shared.Animations;
|
||||
|
||||
namespace Content.Client.Rotation;
|
||||
|
||||
public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsComponent>
|
||||
public sealed class RotationVisualizerSystem : SharedRotationVisualsSystem
|
||||
{
|
||||
public void SetHorizontalAngle(EntityUid uid, Angle angle, RotationVisualsComponent? component = null)
|
||||
|
||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
base.Initialize();
|
||||
|
||||
if (component.HorizontalRotation.Equals(angle))
|
||||
return;
|
||||
|
||||
component.HorizontalRotation = angle;
|
||||
Dirty(component);
|
||||
SubscribeLocalEvent<RotationVisualsComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, RotationVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
private void OnAppearanceChange(EntityUid uid, RotationVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
base.OnAppearanceChange(uid, component, ref args);
|
||||
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
// If not defined, defaults to standing.
|
||||
AppearanceSystem.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component);
|
||||
_appearance.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
@@ -53,9 +50,9 @@ public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsC
|
||||
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))
|
||||
if (_animation.HasRunningAnimation(animationComp, animationKey))
|
||||
{
|
||||
AnimationSystem.Stop(animationComp, animationKey);
|
||||
_animation.Stop(animationComp, animationKey);
|
||||
}
|
||||
|
||||
var animation = new Animation
|
||||
@@ -77,6 +74,6 @@ public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsC
|
||||
}
|
||||
};
|
||||
|
||||
AnimationSystem.Play((uid, animationComp), animation, animationKey);
|
||||
_animation.Play((uid, animationComp), animation, animationKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace Content.Client.Rotation;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class RotationVisualsComponent : Component
|
||||
{
|
||||
[DataField("defaultRotation")]
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public Angle DefaultRotation = Angle.FromDegrees(90);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Angle VerticalRotation = 0;
|
||||
|
||||
[DataField("horizontalRotation")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Angle HorizontalRotation = Angle.FromDegrees(90);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float AnimationTime = 0.125f;
|
||||
}
|
||||
Reference in New Issue
Block a user