mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 22:18:52 +03:00
* эмалированная репа * локалка, ветка и коммит * Компилить тяжело и неуютно * Зато уютно набегать * и тихо капает ОЗУ * и гит растрёпанный, как блядь
64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using System.Numerics;
|
|
using Content.Shared._White;
|
|
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)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|