mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
# Description This reverts most code changes done by https://github.com/Simple-Station/Einstein-Engines/pull/939 and re-implements them in a better way: - Players can now toggle under-furniture crawling with a keybind (shift-R by default) - Crawling that way is 50% slower for obvious balancing reasons - The respective cvar for it is now true by default and prevents players from beginning the "crawl under furniture" thing Also cleaned up a few methods I was seriously pissed off by. There is still a lot to clean up and fix, but I will leave it for a dedicated PR in the future. # Why (balancing) Let me lie on the bed instead of under it!!!!!!! <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/5f04c82a-b88b-4005-8052-a1a6f011bcc9 </p> </details> # Changelog 🆑 - add: You can now toggle crawling under furniture! The default keybind is Shift-R, you can change it in settings.
90 lines
3.5 KiB
C#
90 lines
3.5 KiB
C#
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, MoveEvent>(OnMovementInput);
|
|
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, MoveEvent args)
|
|
{
|
|
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);
|
|
}
|
|
}
|