mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Make every EntitySystem partial * Oobs thats for a diff PR * Also oops on that one * Test systems * git are we fr * Update file templates * cleanup empty classes while we are here * forgor --------- Co-authored-by: AJCM-git <ajcm_mail@disroot.org>
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using Content.Shared.Vapor;
|
|
using Robust.Client.Animations;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Chemistry.Visualizers;
|
|
|
|
/// <summary>
|
|
/// Handles vapor playing the 'being sprayed' animation if necessary.
|
|
/// </summary>
|
|
public sealed partial class VaporVisualizerSystem : VisualizerSystem<VaporVisualsComponent>
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<VaporVisualsComponent, ComponentInit>(OnComponentInit);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructs the 'being sprayed' animation for the vapor entity.
|
|
/// </summary>
|
|
private void OnComponentInit(EntityUid uid, VaporVisualsComponent comp, ComponentInit args)
|
|
{
|
|
comp.VaporFlick = new Animation()
|
|
{
|
|
Length = TimeSpan.FromSeconds(comp.AnimationTime),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick()
|
|
{
|
|
LayerKey = VaporVisualLayers.Base,
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackSpriteFlick.KeyFrame(comp.AnimationState, 0f)
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
if (AppearanceSystem.TryGetData<bool>(uid, VaporVisuals.State, out var state) &&
|
|
state &&
|
|
TryComp<AnimationPlayerComponent>(uid, out var animPlayer) &&
|
|
!AnimationSystem.HasRunningAnimation(uid, animPlayer, VaporVisualsComponent.AnimationKey))
|
|
{
|
|
AnimationSystem.Play((uid, animPlayer), comp.VaporFlick, VaporVisualsComponent.AnimationKey);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ensures that the vapor entity plays its 'being sprayed' animation if necessary.
|
|
/// </summary>
|
|
protected override void OnAppearanceChange(EntityUid uid, VaporVisualsComponent comp, ref AppearanceChangeEvent args)
|
|
{
|
|
if (AppearanceSystem.TryGetData<Color>(uid, VaporVisuals.Color, out var color, args.Component) && args.Sprite != null)
|
|
{
|
|
SpriteSystem.SetColor((uid, args.Sprite), color);
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum VaporVisualLayers : byte
|
|
{
|
|
Base
|
|
}
|