Example #1
0
        private static void AddNewCoRoutine(CoRoutine coRoutine)
        {
            if (_CurrentExecutedCoRoutine != null && _CurrentExecutedCoRoutine.Value.CoSegment == coRoutine.CoSegment)
            {
                _CurrentExecutedCoRoutine.List !.AddAfter(_CurrentExecutedCoRoutine, coRoutine);
            }
            else
            {
                switch (coRoutine.CoSegment)
                {
                case CoSegment.Normal:
                {
                    _NormalCoRoutines.AddLast(coRoutine);
                    break;
                }

                case CoSegment.UnscaledNormal:
                {
                    _UnscaledNormalCoRoutines.AddLast(coRoutine);
                    break;
                }

                case CoSegment.Physics:
                {
                    _PhysicsCoRoutines.AddLast(coRoutine);
                    break;
                }
                }
            }
        }
Example #2
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);
        }