<commit_before>﻿using System;
using Content.Shared.GameObjects.Components;
using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;

namespace Content.Client.GameObjects.Components.Atmos
{
    [UsedImplicitly]
    public class VaporVisualizer : AppearanceVisualizer
    {
        private const string AnimationKey = "flick_animation";
        private Animation VaporFlick;

        public override void LoadData(YamlMappingNode node)
        {
            base.LoadData(node);

            var delay = 0.25f;
            var state = "chempuff";

            if (node.TryGetNode("animation_time", out var delayNode))
            {
                delay = delayNode.AsFloat();
            }

            if (node.TryGetNode("animation_state", out var stateNode))
            {
                state = stateNode.AsString();
            }

            VaporFlick = new Animation {Length = TimeSpan.FromSeconds(delay)};
            {
                var flick = new AnimationTrackSpriteFlick();
                VaporFlick.AnimationTracks.Add(flick);
                flick.LayerKey = VaporVisualLayers.Base;
                flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame(state, 0f));
            }
        }

        public override void OnChangeData(AppearanceComponent component)
        {
            base.OnChangeData(component);

            if (component.Deleted)
            {
                return;
            }

            if (component.TryGetData<double>(VaporVisuals.Rotation, out var radians))
            {
                SetRotation(component, new Angle(radians));
            }

            if (component.TryGetData<Color>(VaporVisuals.Color, out var color))
            {
                SetColor(component, color);
            }

            if (component.TryGetData<bool>(VaporVisuals.State, out var state))
            {<commit_msg>Fix VaporVisualizer throwing due to bad type casts.<commit_after>﻿using System;
using Content.Shared.GameObjects.Components;
using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;

namespace Content.Client.GameObjects.Components.Atmos
{
    [UsedImplicitly]
    public class VaporVisualizer : AppearanceVisualizer
    {
        private const string AnimationKey = "flick_animation";
        private Animation VaporFlick;

        public override void LoadData(YamlMappingNode node)
        {
            base.LoadData(node);

            var delay = 0.25f;
            var state = "chempuff";

            if (node.TryGetNode("animation_time", out var delayNode))
            {
                delay = delayNode.AsFloat();
            }

            if (node.TryGetNode("animation_state", out var stateNode))
            {
                state = stateNode.AsString();
            }

            VaporFlick = new Animation {Length = TimeSpan.FromSeconds(delay)};
            {
                var flick = new AnimationTrackSpriteFlick();
                VaporFlick.AnimationTracks.Add(flick);
                flick.LayerKey = VaporVisualLayers.Base;
                flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame(state, 0f));
            }
        }

        public override void OnChangeData(AppearanceComponent component)
        {
            base.OnChangeData(component);

            if (component.Deleted)
            {
                return;
            }

            if (component.TryGetData<Angle>(VaporVisuals.Rotation, out var radians))
            {
                SetRotation(component, radians);
            }

            if (component.TryGetData<Color>(VaporVisuals.Color, out var color))
            {
                SetColor(component, color);
            }

            if (component.TryGetData<bool>(VaporVisuals.State, out var state))
            {
{'fraction_non_alphanumeric': 0.08503740648379052, 'fraction_numerical': 0.00199501246882793, 'mean_word_length': 1.9406158357771262, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2402848', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1040, 'n_words': 208}