Ejemplo n.º 1
0
        /// <summary> Kill all CoRoutines form all segments and clear RoRoutineController for fresh start. </summary>
        public static void Reset()
        {
            _CurrentEngineTickSegment = CoSegment.Normal;
            _CurrentExecutedCoRoutine = null;

            for (LinkedListNode <CoRoutine> node = _NormalCoRoutines.First; node != null;)
            {
                node.Value.UnRegister();
                node = node.Next;
            }

            for (LinkedListNode <CoRoutine> node = _UnscaledNormalCoRoutines.First; node != null;)
            {
                node.Value.UnRegister();
                node = node.Next;
            }

            for (LinkedListNode <CoRoutine> node = _PhysicsCoRoutines.First; node != null;)
            {
                node.Value.UnRegister();
                node = node.Next;
            }

            _NormalCoRoutines.Clear();
            _UnscaledNormalCoRoutines.Clear();
            _PhysicsCoRoutines.Clear();
        }
Ejemplo n.º 2
0
        internal CoRoutine(IEnumerator <ICoData> enumerator, uint coId, CoSegment coSegment, CoTag coTag, uint coMask)
        {
            CoSegment      = coSegment;
            CoTag          = coTag;
            CoMask         = coMask;
            _SecondsToWait = 0f;
            _CoId          = coId;
            _Enumerator    = enumerator;
            _CoState       = CoState.Running;

            Register();
        }
Ejemplo n.º 3
0
        /// <summary> Creates new CoRoutine and perform first execution if the CoSegment is the same as current one.  </summary>
        public static ICoHandle RunCoRoutine(IEnumerator <ICoData> newCoRoutine, CoSegment coSegment = CoSegment.Normal, CoTag coTag = default, uint coMask = 0)
        {
            CoRoutine coRoutine = new CoRoutine(newCoRoutine, GetNextCoId, coSegment, coTag, coMask);

            AddNewCoRoutine(coRoutine);

            if (_CurrentEngineTickSegment == coSegment || (_CurrentExecutedCoRoutine != null && _CurrentExecutedCoRoutine.Value.CoSegment == coSegment))
            {
                coRoutine.MoveCoRoutine(_DeltaTime);
                coRoutine.InnerCreatedAndMoved = true;
            }

            return(coRoutine);
        }
Ejemplo n.º 4
0
 /// <summary> This method needs to be called before every engine tick segment.
 /// For example before Normal engine tick this method should be called, then engine
 /// Normal tick, then Update method from this class. </summary>
 public static void SetNextCoState(CoSegment nextSegment, float deltaTime)
 {
     _DeltaTime = deltaTime;
     _CurrentEngineTickSegment = nextSegment;
 }
Ejemplo n.º 5
0
        /// <summary> Yield return this to make CoRoutine wait until the other CoRoutine is alive. </summary>
        public static ICoData WaitUntilDone(IEnumerator <ICoData> newCoRoutine, CoSegment coSegment = CoSegment.Normal, CoTag coTag = default, uint coMask = 0)
        {
            ICoHandle coRoutine = RunCoRoutine(newCoRoutine, coSegment, coTag, coMask);

            return(new CoDataWaitUntilDone(coRoutine));
        }