* Cleanup warnings in ClickableSystem * Cleanup warnings in FultonSystem * Cleanup warning in HolidaySystem * Cleanup warning in DoAfterOverlay * Cleanup warning in EntityHealthBarOverlay * Cleanup warning in SmokeVisualizerSystem * Cleanup warning in VaporVisualizerSystem * Cleanup warning in ColorFlashEffectSystem * Cleanup warnings in StealthSystem * Cleanup warnings in TrayScannerSystem * Cleanup warnings in InventoryUIController * Cleanup warnings in HideMechanismsCommand * Cleanup warning in ShowMechanismsCommand * Cleanup warnings in EntityPickupAnimationSystem * Cleanup warnings in PointingSystem * Cleanup warning in StickyVisualizerSystem * Cleanup warnings in TabletopSystem * Cleanup warnings in PillSystem * Cleanup warnings in DiceSystem * Cleanup warnings in ProjectileSystem
64 lines
2.1 KiB
C#
64 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 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
|
|
}
|