<commit_before>using System;
using System.Diagnostics;

namespace CocosSharp
{
    public class CCSpawn : CCActionInterval
    {
        protected CCFiniteTimeAction m_pOne;
        protected CCFiniteTimeAction m_pTwo;


        #region Constructors

        protected CCSpawn(CCFiniteTimeAction action1, CCFiniteTimeAction action2) : base(Math.Max(action1.Duration, action2.Duration))
        {
            InitCCSpawn(action1, action2);
        }

        public CCSpawn(params CCFiniteTimeAction[] actions)
        {
            CCFiniteTimeAction prev = actions[0];
            CCFiniteTimeAction next = null;

            if (actions.Length == 1)
            {
                next = new CCExtraAction();
            }
            else
            {
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new CCSpawn(prev, actions[i]);
                }

                next = actions[actions.Length - 1];
            }

            // Can't call base(duration) because we need to determine max duration
            // Instead call base's init method here
            if(prev != null && next != null)
            {
                Duration = Math.Max(prev.Duration, next.Duration);
                InitCCSpawn(prev, next);
            }
        }

        protected CCSpawn(CCSpawn spawn) : base(spawn)
        {
            CCFiniteTimeAction param1 = new CCFiniteTimeAction(spawn.m_pOne);
            CCFiniteTimeAction param2 = new CCFiniteTimeAction(spawn.m_pTwo);

            InitCCSpawn(param1, param2);
        }

        private void InitCCSpawn(CCFiniteTimeAction action1, CCFiniteTimeAction action2)
        {
            Debug.Assert(action1 != null);
            Debug.Assert(action2 != null);

            float d1 = action1.Duration;
            float d2 = action2.Duration;

            m_pOne = action1;
            m_pTwo = action2;

            if (d1 > d2)
            {
                m_pTwo = new CCSequence(action2, new CCDelayTime(d1 - d2));
            }
            else if (d1 < d2)
            {
                m_pOne = new CCSequence(action1, new CCDelayTime(d2 - d1));
            }
        }

        #endregion Constructors


        public override object Copy(ICCCopyable zone)
        {
            return new CCSpawn(this);
        }

        protected internal override void StartWithTarget(CCNode target)
        {
            base.StartWithTarget(target);
            m_pOne.StartWithTarget(target);
            m_pTwo.StartWithTarget(target);
        }

        public override void Stop()
        {
            m_pOne.Stop();
            m_pTwo.Stop();
            base.Stop();
        }

        public override void Update(float time)
        {
            if (m_pOne != null)
            {
                m_pOne.Update(time);
            }

            if (m_pTwo != null)
            {
                m_pTwo.Update(time);
            }
        }

        public override CCFiniteTimeAction Reverse()
        {
            return new CCSpawn(m_pOne.Reverse(), m_pTwo.Reverse());
        }
    }
}<commit_msg>Separate Action State in CCSpawn.<commit_after>using System;
using System.Diagnostics;

namespace CocosSharp
{
    public class CCSpawn : CCActionInterval
    {
		public CCFiniteTimeAction ActionOne { get; protected set; }
		public CCFiniteTimeAction ActionTwo { get; protected set; }


        #region Constructors

        protected CCSpawn(CCFiniteTimeAction action1, CCFiniteTimeAction action2) : base(Math.Max(action1.Duration, action2.Duration))
        {
            InitCCSpawn(action1, action2);
        }

        public CCSpawn(params CCFiniteTimeAction[] actions)
        {
            CCFiniteTimeAction prev = actions[0];
            CCFiniteTimeAction next = null;

            if (actions.Length == 1)
            {
                next = new CCExtraAction();
            }
            else
            {
				// We create a nested set of CCSpawnActions out of all of the actions
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new CCSpawn(prev, actions[i]);
                }

                next = actions[actions.Length - 1];
            }

            // Can't call base(duration) because we need to determine max duration
            // Instead call base's init method here
            if(prev != null && next != null)
            {
                Duration = Math.Max(prev.Duration, next.Duration);
                InitCCSpawn(prev, next);
            }
        }

        private void InitCCSpawn(CCFiniteTimeAction action1, CCFiniteTimeAction action2)
        {
            Debug.Assert(action1 != null);
            Debug.Assert(action2 != null);

            float d1 = action1.Duration;
            float d2 = action2.Duration;

            ActionOne = action1;
            ActionTwo = action2;

            if (d1 > d2)
            {
                ActionTwo = new CCSequence(action2, new CCDelayTime(d1 - d2));
            }
            else if (d1 < d2)
            {
                ActionOne = new CCSequence(action1, new CCDelayTime(d2 - d1));
            }
        }

        #endregion Constructors

		protected internal override CCActionState StartAction (CCNode target)
		{
			return new CCSpawnState (this, target);

		}

		public override bool HasState {
			get {
				return true;
			}
		}

        public override CCFiniteTimeAction Reverse()
        {
            return new CCSpawn(ActionOne.Reverse(), ActionTwo.Reverse());
        }
    }

	public class CCSpawnState : CCActionIntervalState
	{

		protected CCFiniteTimeAction ActionOne { get; set; }
		private CCFiniteTimeActionState ActionStateOne { get; set; }
		protected CCFiniteTimeAction ActionTwo { get; set; }
		private CCFiniteTimeActionState ActionStateTwo { get; set; }

		public CCSpawnState (CCSpawn action, CCNode target)
			: base(action, target)
		{ 
			ActionOne = action.ActionOne;
			ActionTwo = action.ActionTwo;

			if (!ActionOne.HasState)
				ActionOne.StartWithTarget (target);
			else
				ActionStateOne = (CCFiniteTimeActionState)ActionOne.StartAction (target);

			if (!ActionTwo.HasState)
				ActionTwo.StartWithTarget (target);
			else
				ActionStateTwo = (CCFiniteTimeActionState)ActionTwo.StartAction (target);
		}

		public override void Stop()
		{
			if (ActionStateOne == null)
				ActionOne.Stop();
			else
				ActionStateOne.Stop();

			if (ActionStateTwo == null)
				ActionTwo.Stop ();
			else
				ActionStateTwo.Stop ();

			base.Stop();
		}

		public override void Update(float time)
		{
			if (ActionOne != null)
			{
				if (ActionStateOne == null)
					ActionOne.Update (time);
				else
					ActionStateOne.Update (time);
			}

			if (ActionTwo != null)
			{
				if (ActionStateTwo == null)
					ActionTwo.Update (time);
				else
					ActionStateTwo.Update (time);
			}
		}

	}

}
{'fraction_non_alphanumeric': 0.08737300435413643, 'fraction_numerical': 0.009579100145137881, 'mean_word_length': 1.732355273592387, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '5206188', 'n_tokens_mistral': 2162, 'n_tokens_neox': 1951, 'n_words': 455}