Vehicles (#7336)
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Vehicle.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
{
|
||||
@@ -42,6 +41,11 @@ namespace Content.Client.Buckle
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_entMan.TryGetComponent(Owner, out RiderComponent? rider))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_buckled && buckle.DrawDepth.HasValue)
|
||||
{
|
||||
_originalDrawDepth ??= ownerSprite.DrawDepth;
|
||||
|
||||
32
Content.Client/Vehicle/VehicleSystem.cs
Normal file
32
Content.Client/Vehicle/VehicleSystem.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Content.Shared.Vehicle;
|
||||
|
||||
namespace Content.Client.Vehicle
|
||||
{
|
||||
/// <summary>
|
||||
/// Controls client-side visuals for
|
||||
/// vehicles
|
||||
/// </summary>
|
||||
public sealed class VehicleSystem : VisualizerSystem<VehicleVisualsComponent>
|
||||
{
|
||||
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,
|
||||
}
|
||||
10
Content.Client/Vehicle/VehicleVisualsComponent.cs
Normal file
10
Content.Client/Vehicle/VehicleVisualsComponent.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Content.Client.Vehicle;
|
||||
|
||||
/// <summary>
|
||||
/// Controls visuals for vehicles
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class VehicleVisualsComponent : Component
|
||||
{
|
||||
public int DrawDepth = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user