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;
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);
}
using Content.Shared.Chemistry;
+using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Rounding;
using Robust.Client.GameObjects;
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)
- {
- if (!Resolve(uid, ref component))
- return;
- if (component.HorizontalRotation.Equals(angle))
- return;
+ [Dependency] private readonly AppearanceSystem _appearance = default!;
+ [Dependency] private readonly AnimationPlayerSystem _animation = default!;
- component.HorizontalRotation = angle;
- Dirty(component);
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ 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)
{
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
}
};
- AnimationSystem.Play((uid, animationComp), animation, animationKey);
+ _animation.Play((uid, animationComp), animation, animationKey);
}
}
+++ /dev/null
-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;
-}
--- /dev/null
+using Content.Shared.Rotation;
+
+namespace Content.Server.Rotation;
+
+public sealed class RotationVisualsSystem : SharedRotationVisualsSystem
+{
+}
if (TryComp<AppearanceComponent>(buckleUid, out var appearance))
Appearance.SetData(buckleUid, BuckleVisuals.Buckled, true, appearance);
+ _rotationVisuals.SetHorizontalAngle(buckleUid, strapComp.Rotation);
+
ReAttach(buckleUid, strapUid, buckleComp, strapComp);
SetBuckledTo(buckleUid, strapUid, strapComp, buckleComp);
// TODO user is currently set to null because if it isn't the sound fails to play in some situations, fix that
if (TryComp(buckleUid, out AppearanceComponent? appearance))
Appearance.SetData(buckleUid, BuckleVisuals.Buckled, false, appearance);
+ _rotationVisuals.ResetHorizontalAngle(buckleUid);
if (TryComp<MobStateComponent>(buckleUid, out var mobState)
&& _mobState.IsIncapacitated(buckleUid, mobState)
using Content.Shared.DragDrop;
using Content.Shared.Foldable;
using Content.Shared.Interaction;
+using Content.Shared.Rotation;
using Content.Shared.Storage;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
public abstract partial class SharedBuckleSystem
{
+ [Dependency] private readonly SharedRotationVisualsSystem _rotationVisuals = default!;
+
private void InitializeStrap()
{
SubscribeLocalEvent<StrapComponent, ComponentStartup>(OnStrapStartup);
strapComp.OccupiedSize += buckleComp.Size;
- Appearance.SetData(buckleUid, StrapVisuals.RotationAngle, strapComp.Rotation);
-
Appearance.SetData(strapUid, StrapVisuals.State, true);
Dirty(strapUid, strapComp);
-using Content.Shared.Chemistry;
using Robust.Shared.Utility;
-namespace Content.Client.Chemistry.Visualizers
+namespace Content.Shared.Chemistry.Components
{
[RegisterComponent]
public sealed partial class SolutionContainerVisualsComponent : Component
public void UpdateAppearance(EntityUid uid, Solution solution,
AppearanceComponent? appearanceComponent = null)
{
- if (!EntityManager.EntityExists(uid)
- || !Resolve(uid, ref appearanceComponent, false))
+ if (!HasComp<SolutionContainerVisualsComponent>(uid) || !Resolve(uid, ref appearanceComponent, false))
return;
_appearance.SetData(uid, SolutionContainerVisuals.FillFraction, solution.FillFraction, appearanceComponent);
--- /dev/null
+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,
+}
+++ /dev/null
-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,
- }
-}
--- /dev/null
+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);
+ }
+}
if (!vehicle.AutoAnimate)
continue;
+ // Why is this updating appearance data every tick, instead of when it needs to be updated???
+
if (_mover.GetVelocityInput(mover).Sprinting == Vector2.Zero)
{
UpdateAutoAnimate(uid, false);