diff --git a/Content.Client/Vehicle/VehicleSystem.cs b/Content.Client/Vehicle/VehicleSystem.cs
index 61784fb8eb..0c85152a11 100644
--- a/Content.Client/Vehicle/VehicleSystem.cs
+++ b/Content.Client/Vehicle/VehicleSystem.cs
@@ -1,32 +1,34 @@
-using Robust.Client.GameObjects;
using Content.Shared.Vehicle;
+using Robust.Client.Graphics;
+using Robust.Client.GameObjects;
namespace Content.Client.Vehicle
{
- ///
- /// Controls client-side visuals for
- /// vehicles
- ///
- public sealed class VehicleSystem : VisualizerSystem
+ public sealed class VehicleSystem : EntitySystem
{
- protected override void OnAppearanceChange(EntityUid uid, VehicleVisualsComponent component, ref AppearanceChangeEvent args)
+ [Dependency] private readonly IEyeManager _eyeManager = default!;
+
+ public override void Initialize()
{
- /// First check is for the sprite itself
- if (TryComp(uid, out SpriteComponent? sprite)
- && args.Component.TryGetData(VehicleVisuals.DrawDepth, out int drawDepth) && sprite != null)
- {
- sprite.DrawDepth = drawDepth;
- }
- /// Set vehicle layer to animated or not (i.e. are the wheels turning or not)
- if (args.Component.TryGetData(VehicleVisuals.AutoAnimate, out bool autoAnimate))
- {
- sprite?.LayerSetAutoAnimated(VehicleVisualLayers.AutoAnimate, autoAnimate);
- }
+ base.Initialize();
+ SubscribeNetworkEvent(OnBuckle);
}
+
+ private void OnBuckle(BuckledToVehicleEvent args)
+ {
+ // Use the vehicle's eye if we get buckled
+ if (args.Buckling)
+ {
+ if (!TryComp(args.Vehicle, out var vehicleEye) || vehicleEye.Eye == null)
+ return;
+ _eyeManager.CurrentEye = vehicleEye.Eye;
+ return;
+ }
+ // Reset if we get unbuckled.
+ if (!TryComp(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;
+ }
+
}
}
-public enum VehicleVisualLayers : byte
-{
- /// Layer for the vehicle's wheels
- AutoAnimate,
-}
diff --git a/Content.Client/Vehicle/VehicleVisualsSystem.cs b/Content.Client/Vehicle/VehicleVisualsSystem.cs
new file mode 100644
index 0000000000..f47afc04cc
--- /dev/null
+++ b/Content.Client/Vehicle/VehicleVisualsSystem.cs
@@ -0,0 +1,32 @@
+using Robust.Client.GameObjects;
+using Content.Shared.Vehicle;
+
+namespace Content.Client.Vehicle
+{
+ ///
+ /// Controls client-side visuals for
+ /// vehicles
+ ///
+ public sealed class VehicleVisualsSystem : VisualizerSystem
+ {
+ protected override void OnAppearanceChange(EntityUid uid, VehicleVisualsComponent component, ref AppearanceChangeEvent args)
+ {
+ /// First check is for the sprite itself
+ if (TryComp(uid, out SpriteComponent? sprite)
+ && args.Component.TryGetData(VehicleVisuals.DrawDepth, out int drawDepth) && sprite != null)
+ {
+ sprite.DrawDepth = drawDepth;
+ }
+ /// Set vehicle layer to animated or not (i.e. are the wheels turning or not)
+ if (args.Component.TryGetData(VehicleVisuals.AutoAnimate, out bool autoAnimate))
+ {
+ sprite?.LayerSetAutoAnimated(VehicleVisualLayers.AutoAnimate, autoAnimate);
+ }
+ }
+ }
+}
+public enum VehicleVisualLayers : byte
+{
+ /// Layer for the vehicle's wheels
+ AutoAnimate,
+}
diff --git a/Content.Server/Vehicle/VehicleSystem.cs b/Content.Server/Vehicle/VehicleSystem.cs
index 2da1e73ca5..3ffebcdcba 100644
--- a/Content.Server/Vehicle/VehicleSystem.cs
+++ b/Content.Server/Vehicle/VehicleSystem.cs
@@ -10,8 +10,10 @@ using Content.Server.Light.Components;
using Content.Server.Buckle.Components;
using Content.Server.Hands.Systems;
using Content.Shared.Tag;
+using Content.Server.Mind.Components;
using Robust.Shared.Random;
using Robust.Shared.Containers;
+using Robust.Shared.Player;
namespace Content.Server.Vehicle
{
@@ -24,7 +26,6 @@ namespace Content.Server.Vehicle
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly RiderSystem _riderSystem = default!;
-
public override void Initialize()
{
base.Initialize();
@@ -68,6 +69,10 @@ namespace Content.Server.Vehicle
///
private void OnBuckleChange(EntityUid uid, VehicleComponent component, BuckleChangeEvent args)
{
+ // Send an event that our vehicle buckle changed
+ if (TryComp(args.BuckledEntity, out var mind) && mind.Mind != null && mind.Mind.TryGetSession(out var session))
+ RaiseNetworkEvent(new BuckledToVehicleEvent(uid, args.BuckledEntity, args.Buckling), Filter.SinglePlayer(session));
+
if (args.Buckling)
{
// Add a virtual item to rider's hand, unbuckle if we can't.
@@ -200,16 +205,16 @@ namespace Content.Server.Vehicle
{
return xform.LocalRotation.Degrees switch
{
- < 135f => 10,
+ < 135f => 5,
<= 225f => 2,
- _ => 10
+ _ => 5
};
}
return xform.LocalRotation.Degrees switch
{
- < 45f => 10,
+ < 45f => 5,
<= 315f => 2,
- _ => 10
+ _ => 5
};
}
diff --git a/Content.Shared/Vehicle/SharedVehicleSystem.cs b/Content.Shared/Vehicle/SharedVehicleSystem.cs
index d223f819f9..a7699f52a0 100644
--- a/Content.Shared/Vehicle/SharedVehicleSystem.cs
+++ b/Content.Shared/Vehicle/SharedVehicleSystem.cs
@@ -48,4 +48,26 @@ namespace Content.Shared.Vehicle
/// Raised when someone honks a vehicle horn
///
public sealed class HonkActionEvent : InstantActionEvent { }
+
+ ///
+ /// Raised on the rider when someone is buckled to a vehicle.
+ ///
+ [Serializable, NetSerializable]
+ public sealed class BuckledToVehicleEvent : EntityEventArgs
+ {
+ public EntityUid Vehicle;
+
+ public EntityUid Rider;
+
+ ///
+ /// Whether they were buckled or unbuckled
+ ///
+ public bool Buckling;
+ public BuckledToVehicleEvent(EntityUid vehicle, EntityUid rider, bool buckling)
+ {
+ Vehicle = vehicle;
+ Rider = rider;
+ Buckling = buckling;
+ }
+ }
}
diff --git a/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml b/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml
index 0da2ce6ab0..2103aa1ff9 100644
--- a/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml
+++ b/Resources/Prototypes/Entities/Objects/Vehicles/buckleable.yml
@@ -17,6 +17,7 @@
- type: MovementSpeedModifier
baseWalkSpeed : 7
baseSprintSpeed : 7
+ - type: Eye
- type: Tag
- type: Pullable
- type: Physics