Files
OldThink/Content.Client/Vehicle/VehicleSystem.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2022-04-23 21:05:02 -04:00
using Content.Shared.Vehicle;
using Robust.Client.Graphics;
using Robust.Client.GameObjects;
2022-04-23 21:05:02 -04:00
namespace Content.Client.Vehicle
{
public sealed class VehicleSystem : EntitySystem
2022-04-23 21:05:02 -04:00
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
public override void Initialize()
2022-04-23 21:05:02 -04:00
{
base.Initialize();
SubscribeNetworkEvent<BuckledToVehicleEvent>(OnBuckle);
}
private void OnBuckle(BuckledToVehicleEvent args)
{
// Use the vehicle's eye if we get buckled
if (args.Buckling)
2022-04-23 21:05:02 -04:00
{
if (!TryComp<EyeComponent>(args.Vehicle, out var vehicleEye) || vehicleEye.Eye == null)
return;
_eyeManager.CurrentEye = vehicleEye.Eye;
return;
2022-04-23 21:05:02 -04:00
}
// Reset if we get unbuckled.
if (!TryComp<EyeComponent>(args.Rider, out var component) || component.Eye == null)
return; // This probably will never happen but in this strange new world we probably want to maintain our old vision
_eyeManager.CurrentEye = component.Eye;
2022-04-23 21:05:02 -04:00
}
2022-04-23 21:05:02 -04:00
}
}