using Content.Shared.Shuttles.Components;
using Robust.Client.GameObjects;
namespace Content.Client.Shuttles;
///
/// Handles making a thruster visibly turn on/emit an exhaust plume according to its state.
///
public sealed class ThrusterSystem : VisualizerSystem
{
///
/// Updates whether or not the thruster is visibly active/thrusting.
///
protected override void OnAppearanceChange(EntityUid uid, ThrusterComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null
|| !AppearanceSystem.TryGetData(uid, ThrusterVisualState.State, out var state, args.Component))
return;
args.Sprite.LayerSetVisible(ThrusterVisualLayers.ThrustOn, state);
SetThrusting(
uid,
state && AppearanceSystem.TryGetData(uid, ThrusterVisualState.Thrusting, out var thrusting, args.Component) && thrusting,
args.Sprite
);
}
///
/// Sets whether or not the exhaust plume of the thruster is visible or not.
///
private static void SetThrusting(EntityUid _, bool value, SpriteComponent sprite)
{
if (sprite.LayerMapTryGet(ThrusterVisualLayers.Thrusting, out var thrustingLayer))
{
sprite.LayerSetVisible(thrustingLayer, value);
}
if (sprite.LayerMapTryGet(ThrusterVisualLayers.ThrustingUnshaded, out var unshadedLayer))
{
sprite.LayerSetVisible(unshadedLayer, value);
}
}
}
public enum ThrusterVisualLayers : byte
{
Base,
ThrustOn,
Thrusting,
ThrustingUnshaded,
}