Fix rotation visuals desync & appearance state spam (#23016)
* Fix rotation visuals desync * :bucklemeup: * A
This commit is contained in:
43
Content.Shared/Rotation/RotationVisualsComponent.cs
Normal file
43
Content.Shared/Rotation/RotationVisualsComponent.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Rotation;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class RotationVisualsComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Default value of <see cref="HorizontalRotation"/>
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public Angle DefaultRotation = Angle.FromDegrees(90);
|
||||
|
||||
[DataField]
|
||||
public Angle VerticalRotation = 0;
|
||||
|
||||
[DataField, AutoNetworkedField]
|
||||
public Angle HorizontalRotation = Angle.FromDegrees(90);
|
||||
|
||||
[DataField]
|
||||
public float AnimationTime = 0.125f;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum RotationVisuals
|
||||
{
|
||||
RotationState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum RotationState
|
||||
{
|
||||
/// <summary>
|
||||
/// Standing up. This is the default value.
|
||||
/// </summary>
|
||||
Vertical = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Laying down
|
||||
/// </summary>
|
||||
Horizontal,
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Rotation
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum RotationVisuals
|
||||
{
|
||||
RotationState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum RotationState
|
||||
{
|
||||
/// <summary>
|
||||
/// Standing up. This is the default value.
|
||||
/// </summary>
|
||||
Vertical = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Laying down
|
||||
/// </summary>
|
||||
Horizontal,
|
||||
}
|
||||
}
|
||||
29
Content.Shared/Rotation/SharedRotationVisualsSystem.cs
Normal file
29
Content.Shared/Rotation/SharedRotationVisualsSystem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace Content.Shared.Rotation;
|
||||
|
||||
public abstract class SharedRotationVisualsSystem : EntitySystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the rotation an entity will have when it is "horizontal"
|
||||
/// </summary>
|
||||
public void SetHorizontalAngle(Entity<RotationVisualsComponent?> ent, Angle angle)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp, false))
|
||||
return;
|
||||
|
||||
if (ent.Comp.HorizontalRotation.Equals(angle))
|
||||
return;
|
||||
|
||||
ent.Comp.HorizontalRotation = angle;
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resets the rotation an entity will have when it is "horizontal" back to it's default value.
|
||||
/// </summary>
|
||||
public void ResetHorizontalAngle(Entity<RotationVisualsComponent?> ent)
|
||||
{
|
||||
if (Resolve(ent, ref ent.Comp, false))
|
||||
SetHorizontalAngle(ent, ent.Comp.DefaultRotation);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user