mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
* mass clean up
(cherry picked from commit 12bb873b02c1ef50e20763542b030452cc0613da)
* Revert "Centrifuge buff (#393)"
This reverts commit 2a59a18230.
(cherry picked from commit 9ee495ab4bb365e1ccd3dc627ecb55114fea6944)
* Shoving merge conflict
* fix rich traitor
* fix test
* yml
* fix test
* fix test
* ohh
91 lines
3.6 KiB
C#
91 lines
3.6 KiB
C#
using Content.Shared._White.Move;
|
|
using Content.Shared.Buckle;
|
|
using Content.Shared.Rotation;
|
|
using Content.Shared.Standing;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.Standing;
|
|
|
|
public sealed class LayingDownSystem : SharedLayingDownSystem
|
|
{
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
|
[Dependency] private readonly StandingStateSystem _standing = default!;
|
|
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
|
|
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<LayingDownComponent, MoveEventProxy>(OnMovementInput); // WD EDIT
|
|
SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
// Update draw depth of laying down entities as necessary
|
|
var query = EntityQueryEnumerator<LayingDownComponent, StandingStateComponent, SpriteComponent>();
|
|
while (query.MoveNext(out var uid, out var layingDown, out var standing, out var sprite))
|
|
{
|
|
// Do not modify the entities draw depth if it's modified externally
|
|
if (sprite.DrawDepth != layingDown.NormalDrawDepth && sprite.DrawDepth != layingDown.CrawlingUnderDrawDepth)
|
|
continue;
|
|
|
|
sprite.DrawDepth = standing.CurrentState is StandingState.Lying && layingDown.IsCrawlingUnder
|
|
? layingDown.CrawlingUnderDrawDepth
|
|
: layingDown.NormalDrawDepth;
|
|
}
|
|
|
|
query.Dispose();
|
|
}
|
|
|
|
private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveEventProxy args) // WD EDIT
|
|
{
|
|
if (!_timing.IsFirstTimePredicted
|
|
|| !_standing.IsDown(uid)
|
|
|| _buckle.IsBuckled(uid)
|
|
|| _animation.HasRunningAnimation(uid, "rotate")
|
|
|| !TryComp<TransformComponent>(uid, out var transform)
|
|
|| !TryComp<SpriteComponent>(uid, out var sprite)
|
|
|| !TryComp<RotationVisualsComponent>(uid, out var rotationVisuals))
|
|
return;
|
|
|
|
var rotation = transform.LocalRotation + (_eyeManager.CurrentEye.Rotation - (transform.LocalRotation - transform.WorldRotation));
|
|
|
|
if (rotation.GetDir() is Direction.SouthEast or Direction.East or Direction.NorthEast or Direction.North)
|
|
{
|
|
rotationVisuals.HorizontalRotation = Angle.FromDegrees(270);
|
|
sprite.Rotation = Angle.FromDegrees(270);
|
|
return;
|
|
}
|
|
|
|
rotationVisuals.HorizontalRotation = Angle.FromDegrees(90);
|
|
sprite.Rotation = Angle.FromDegrees(90);
|
|
}
|
|
|
|
private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args)
|
|
{
|
|
if (!_timing.IsFirstTimePredicted)
|
|
return;
|
|
|
|
var uid = GetEntity(ev.User);
|
|
|
|
if (!TryComp<TransformComponent>(uid, out var transform) || !TryComp<RotationVisualsComponent>(uid, out var rotationVisuals))
|
|
return;
|
|
|
|
var rotation = transform.LocalRotation + (_eyeManager.CurrentEye.Rotation - (transform.LocalRotation - transform.WorldRotation));
|
|
|
|
if (rotation.GetDir() is Direction.SouthEast or Direction.East or Direction.NorthEast or Direction.North)
|
|
{
|
|
rotationVisuals.HorizontalRotation = Angle.FromDegrees(270);
|
|
return;
|
|
}
|
|
|
|
rotationVisuals.HorizontalRotation = Angle.FromDegrees(90);
|
|
}
|
|
}
|