Beispiel #1
0
        void AddTask(ITask task, EnumGameTaskPriority priority)
        {
            if (task.IsParallel())
            {
                queued_parallel_tasks.Enqueue(task);
                return;
            }

            switch (priority)
            {
            case EnumGameTaskPriority.Default:
            {
                tasks.Add(task);
            }
            break;

            case EnumGameTaskPriority.High:
            {
                tasks.Insert(0, task);
            }
            break;

            case EnumGameTaskPriority.Interrupt:
            {
                if (current_task != null && current_task.GetPriority() != EnumGameTaskPriority.Interrupt)
                {
                    StopCurrent();
                }
                tasks.Insert(0, task);
            }
            break;
            }
        }
Beispiel #2
0
 public GameTaskAsync(Func <UniTask> task_action, EnumGameTaskPriority priority, CancellationTokenSource cts, bool is_parallel)
 {
     this.task_action   = task_action;
     this.task_priority = priority;
     this.cts           = cts;
     this.is_parallel   = is_parallel;
 }
Beispiel #3
0
 public static GameTaskAsync Create(
     Func <UniTask> task_action,
     EnumGameTaskPriority priority = EnumGameTaskPriority.Default,
     CancellationTokenSource cts   = default(CancellationTokenSource),
     bool is_parallel = false)
 {
     return(new GameTaskAsync(task_action, priority, cts, is_parallel));
 }
Beispiel #4
0
        public void ScheduleSyncTask(
            Action task_action,
            Action <bool> on_finished,
            EnumGameTaskPriority task_priority = EnumGameTaskPriority.Default)
        {
            if (task_action == null)
            {
                return;
            }

            var task = GameTaskSync.Create(task_action, task_priority);

            task.Subscribe(on_finished);
            AddTask(task, task_priority);
        }
Beispiel #5
0
        public void ScheduleAsyncTask(
            Func <UniTask> task_action,
            Action <bool> on_finished,
            EnumGameTaskPriority task_priority = EnumGameTaskPriority.Default,
            CancellationTokenSource cts        = default(CancellationTokenSource),
            bool is_parallel = false)
        {
            if (task_action == null)
            {
                return;
            }

            var task = GameTaskAsync.Create(task_action, task_priority, cts, is_parallel);

            task.Subscribe(on_finished);
            AddTask(task, task_priority);
        }
Beispiel #6
0
 public GameTaskSync(Action task_action, EnumGameTaskPriority priority)
 {
     this.task_action   = task_action;
     this.task_priority = priority;
 }
Beispiel #7
0
 public static GameTaskSync Create(Action task_action, EnumGameTaskPriority priority = EnumGameTaskPriority.Default)
 {
     return(new GameTaskSync(task_action, priority));
 }