<commit_before>using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.Sprites;
using SpriterDotNet;
using XmasHell.Spriter;

namespace XmasHell.Entities.Bosses.XmasSnowflake
{
    class XmasSnowflakeBehaviour2 : AbstractBossBehaviour
    {
        private bool _initialized;
        private SpriterFile _branch1File;
        private SpriterFile _branch2File;

        private List<XmasSnowflakeBranch> _branches;

        public XmasSnowflakeBehaviour2(Boss boss) : base(boss)
        {
        }

        public override void Start()
        {
            base.Start();

            _initialized = false;

            Boss.MoveTo(new Vector2(GameConfig.VirtualResolution.X / 2f, GameConfig.VirtualResolution.Y / 5f), 0.5f, true);

            Boss.CurrentAnimator.Play("Idle");
            Boss.CurrentAnimator.AnimationFinished += AnimationFinishedHandler;

            int folderId = 0;
            _branch1File = SpriterUtils.GetSpriterFile("branch1.png", Boss.CurrentAnimator, out folderId);
            _branch2File = SpriterUtils.GetSpriterFile("branch2.png", Boss.CurrentAnimator, out folderId);

            _branches = new List<XmasSnowflakeBranch>(8);
        }

        public override void Stop()
        {
            base.Stop();

            foreach (var branch in _branches)
            {
                branch.Dispose();
            }
        }

        private void AnimationFinishedHandler(string animationName)
        {
            switch (animationName)
            {
                case "Attack1":
                    ReplaceBranches();
                    Boss.CurrentAnimator.Play("WithoutBranches");
                    _initialized = true;
                    break;
                case "RespawnBranches":
                    _initialized = false;
                    break;
            }
        }

        private void ReplaceBranches()
        {
            // Start by retrieving the position of all branches from Spriter object
            var spriteData = Boss.CurrentAnimator.FrameData.SpriteData;

            var branch1Sprites = spriteData.FindAll(so => so.FileId == _branch1File.Id);
            var branch2Sprites = spriteData.FindAll(so => so.FileId == _branch2File.Id);
<commit_msg>Fix an issue with the second behaviour of the Xmas Snowflake.<commit_after>using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.Sprites;
using SpriterDotNet;
using XmasHell.Spriter;

namespace XmasHell.Entities.Bosses.XmasSnowflake
{
    class XmasSnowflakeBehaviour2 : AbstractBossBehaviour
    {
        private bool _initialized;
        private SpriterFile _branch1File;
        private SpriterFile _branch2File;

        private List<XmasSnowflakeBranch> _branches;

        public XmasSnowflakeBehaviour2(Boss boss) : base(boss)
        {
        }

        public override void Start()
        {
            base.Start();

            _initialized = false;

            Boss.MoveTo(new Vector2(GameConfig.VirtualResolution.X / 2f, GameConfig.VirtualResolution.Y / 5f), 0.5f, true);

            Boss.CurrentAnimator.Play("Idle");
            Boss.CurrentAnimator.AnimationFinished += AnimationFinishedHandler;

            int folderId = 0;
            _branch1File = SpriterUtils.GetSpriterFile("branch1.png", Boss.CurrentAnimator, out folderId);
            _branch2File = SpriterUtils.GetSpriterFile("branch2.png", Boss.CurrentAnimator, out folderId);

            _branches = new List<XmasSnowflakeBranch>(8);
        }

        public override void Stop()
        {
            base.Stop();

            if (_branches != null)
            {
                foreach (var branch in _branches)
                    branch.Dispose();

                _branches.Clear();
            }

            Boss.CurrentAnimator.AnimationFinished -= AnimationFinishedHandler;
        }

        private void AnimationFinishedHandler(string animationName)
        {
            switch (animationName)
            {
                case "Attack1":
                    ReplaceBranches();
                    Boss.CurrentAnimator.Play("WithoutBranches");
                    _initialized = true;
                    break;
                case "RespawnBranches":
                    _initialized = false;
                    break;
            }
        }

        private void ReplaceBranches()
        {
            // Start by retrieving the position of all branches from Spriter object
            var spriteData = Boss.CurrentAnimator.FrameData.SpriteData;

            var branch1Sprites = spriteData.FindAll(so => so.FileId == _branch1File.Id);
            var branch2Sprites = spriteData.FindAll(so => so.FileId == _branch2File.Id);

{'fraction_non_alphanumeric': 0.07941787941787942, 'fraction_numerical': 0.008316008316008316, 'mean_word_length': 1.9515337423312884, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 11, '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': '1697959', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1264, 'n_words': 260}