* commit

* commit

* commit
This commit is contained in:
Spatison
2024-07-14 16:26:12 +03:00
committed by GitHub
parent f60271327d
commit 9b2247bcc7
8 changed files with 72 additions and 61 deletions

View File

@@ -56,10 +56,7 @@ internal sealed class BuckleSystem : SharedBuckleSystem
if (!Appearance.TryGetData<bool>(uid, BuckleVisuals.Buckled, out var buckled, args.Component) ||
!buckled ||
args.Sprite == null)
{
_rotationVisualizerSystem.SetHorizontalAngle((uid, rotVisuals), rotVisuals.DefaultRotation);
return;
}
// Animate strapping yourself to something at a given angle
// TODO: Dump this when buckle is better

View File

@@ -1,41 +0,0 @@
using Content.Shared.Rotation;
using Robust.Client.GameObjects;
namespace Content.Client._White.Rotation;
public sealed class RotationVisualizerSystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
SubscribeLocalEvent<RotationVisualsComponent, MoveEvent>(OnMove);
}
private void OnMove(EntityUid uid, RotationVisualsComponent component, ref MoveEvent args)
{
if (!TryComp<SpriteComponent>(uid, out var sprite) ||
!TryComp<AppearanceComponent>(uid, out var appearance))
return;
_appearance.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, appearance);
var rotation = _transform.GetWorldRotation(uid);
if (rotation.GetDir() is Direction.East or Direction.North or Direction.NorthEast or Direction.SouthEast)
{
if (state == RotationState.Horizontal &&
sprite.Rotation == component.DefaultRotation)
{
sprite.Rotation = Angle.FromDegrees(270);
}
return;
}
if (state == RotationState.Horizontal &&
sprite.Rotation == Angle.FromDegrees(270))
{
sprite.Rotation = component.DefaultRotation;
}
}
}

View File

@@ -0,0 +1,46 @@
using Content.Shared.Rotation;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
namespace Content.Client._White.Rotation;
public sealed class RotationVisualizerWhiteSystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
public override void Initialize()
{
SubscribeLocalEvent<RotationVisualsComponent, MoveEvent>(OnMove);
}
private void OnMove(EntityUid uid, RotationVisualsComponent component, ref MoveEvent args)
{
if (!TryComp<SpriteComponent>(uid, out var sprite) ||
!TryComp<AppearanceComponent>(uid, out var appearance) ||
!TryComp<TransformComponent>(uid, out var transform) ||
component.DefaultRotation == 0)
return;
_appearance.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, appearance);
var rotation = transform.LocalRotation + _eyeManager.CurrentEye.Rotation;
if (rotation.GetDir() is Direction.East or Direction.North or Direction.NorthEast or Direction.SouthEast)
{
if (state != RotationState.Horizontal ||
sprite.Rotation != component.DefaultRotation)
return;
component.HorizontalRotation = Angle.FromDegrees(270);
sprite.Rotation = Angle.FromDegrees(270);
return;
}
if (state != RotationState.Horizontal ||
sprite.Rotation != Angle.FromDegrees(270))
return;
component.HorizontalRotation = component.DefaultRotation;
sprite.Rotation = component.DefaultRotation;
}
}