Thrusters (shuttle go nyoom) (#5352)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Shuttles;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Shuttles
|
||||
|
||||
67
Content.Client/Shuttles/ThrusterVisualizer.cs
Normal file
67
Content.Client/Shuttles/ThrusterVisualizer.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Shuttles
|
||||
{
|
||||
public sealed class ThrusterVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out SpriteComponent? spriteComponent)) return;
|
||||
|
||||
component.TryGetData(ThrusterVisualState.State, out bool state);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case true:
|
||||
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustOn, true);
|
||||
|
||||
if (component.TryGetData(ThrusterVisualState.Thrusting, out bool thrusting) && thrusting)
|
||||
{
|
||||
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.Thrusting, out _))
|
||||
{
|
||||
spriteComponent.LayerSetVisible(ThrusterVisualLayers.Thrusting, true);
|
||||
}
|
||||
|
||||
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.ThrustingUnshaded, out _))
|
||||
{
|
||||
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustingUnshaded, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DisableThrusting(component, spriteComponent);
|
||||
}
|
||||
|
||||
break;
|
||||
case false:
|
||||
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustOn, false);
|
||||
DisableThrusting(component, spriteComponent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableThrusting(AppearanceComponent component, SpriteComponent spriteComponent)
|
||||
{
|
||||
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.Thrusting, out _))
|
||||
{
|
||||
spriteComponent.LayerSetVisible(ThrusterVisualLayers.Thrusting, false);
|
||||
}
|
||||
|
||||
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.ThrustingUnshaded, out _))
|
||||
{
|
||||
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustingUnshaded, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ThrusterVisualLayers : byte
|
||||
{
|
||||
Base,
|
||||
ThrustOn,
|
||||
Thrusting,
|
||||
ThrustingUnshaded,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user