Files
wwdpublic/Content.Client/_Goobstation/Vehicles/VehicleSystem.cs
Spatison 54086988e3 Mass clean up (#587)
* 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
2025-06-16 20:35:48 +03:00

63 lines
2.1 KiB
C#

using Content.Shared._White.Move;
using Content.Shared.Vehicles;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
namespace Content.Client.Vehicles;
public sealed class VehicleSystem : SharedVehicleSystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IEyeManager _eye = default!;
[Dependency] private readonly SpriteSystem _sprites = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<VehicleComponent, AppearanceChangeEvent>(OnAppearanceChange);
SubscribeLocalEvent<VehicleComponent, MoveEventProxy>(OnMove);
}
private void OnAppearanceChange(EntityUid uid, VehicleComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null || !_appearance.TryGetData<bool>(uid, VehicleState.Animated, out bool animated) || !TryComp<SpriteComponent>(uid, out var spriteComp))
return;
SpritePos(uid, comp);
spriteComp.LayerSetAutoAnimated(0, animated);
}
private void OnMove(EntityUid uid, VehicleComponent component, ref MoveEventProxy args) // WD EDIT
{
SpritePos(uid, component);
}
private void SpritePos(EntityUid uid, VehicleComponent comp)
{
if (!TryComp<SpriteComponent>(uid, out var spriteComp))
return;
if (!_appearance.TryGetData<bool>(uid, VehicleState.DrawOver, out bool depth))
return;
spriteComp.DrawDepth = (int)Content.Shared.DrawDepth.DrawDepth.Objects;
if (comp.RenderOver == VehicleRenderOver.None)
return;
var eye = _eye.CurrentEye;
Direction vehicleDir = (Transform(uid).LocalRotation + eye.Rotation).GetCardinalDir();
VehicleRenderOver renderOver = (VehicleRenderOver)(1 << (int)vehicleDir);
if ((comp.RenderOver & renderOver) == renderOver)
{
spriteComp.DrawDepth = (int)Content.Shared.DrawDepth.DrawDepth.OverMobs;
}
else
{
spriteComp.DrawDepth = (int)Content.Shared.DrawDepth.DrawDepth.Objects;
}
}
}