Example #1
0
 public void RunTasks()
 {
     for (BackTask t = First; t is not null; t = t.Next)
     {
         t.Action?.Invoke(t);
     }
 }
Example #2
0
 public void RemoveAll()
 {
     for (BackTask t = First; t is not null; t = t.Next)
     {
         t.Dispose();
     }
     First = null;
     Count = 0;
 }
Example #3
0
 public void RemoveAllWithTag(object tag)
 {
     for (BackTask t = First; t is not null; t = t.Next)
     {
         if (t.Tag == tag)
         {
             Remove(t);
         }
     }
 }
Example #4
0
 public void RunTasksWithoutTag(object tag)
 {
     for (BackTask t = First; t is not null; t = t.Next)
     {
         if (t.Tag != tag)
         {
             t.Action?.Invoke(t);
         }
     }
 }
Example #5
0
 public bool TryGetTaskWithTag(object tag, out BackTask task)
 {
     for (BackTask t = First; t is not null; t = t.Next)
     {
         if (t.Tag == tag)
         {
             task = t;
             return(true);
         }
     }
     task = default;
     return(false);
 }
Example #6
0
 public bool TryGetTask(BackTaskAction action, out BackTask task)
 {
     for (BackTask t = First; t is not null; t = t.Next)
     {
         if (t.Action == action)
         {
             task = t;
             return(true);
         }
     }
     task = default;
     return(false);
 }
Example #7
0
        private static void Task_FadeBattleBGMToOverworldBGM(BackTask task)
        {
            var data = (TaskData_Fade)task.Data;

            if (!data.Handle.IsFading)
            {
                SoundMixer.StopChannel(_battleBGM.Channel);
                _battleBGM = null;
                if (_overworldBGM is not null)
                {
                    // Create overworld bgm fade
                    _overworldBGM.Channel.BeginFade(1_000, 0f, 1f);
                    _overworldBGM.Channel.IsPaused = false;
                }
                _tasks.Remove(task);
            }
        }
Example #8
0
        private static void Task_FadeOverworldBGMAndStartNewSong(BackTask task)
        {
            var data = (TaskData_FadeSongToSong)task.Data;

            if (!data.Handle.IsFading)
            {
                SoundMixer.StopChannel(_overworldBGM.Channel);
                if (data.Song == Song.None)
                {
                    _overworldBGM = null;
                }
                else
                {
                    _overworldBGM         = SongToSound(data.Song);
                    _overworldBGM.Channel = new SoundChannel(_overworldBGM.Wav);
                    SoundMixer.AddChannel(_overworldBGM.Channel);
                }
                _tasks.Remove(task);
            }
        }
Example #9
0
        public void Add(BackTask task)
        {
            if (First is null)
            {
                First = task;
                Count = 1;
                return;
            }
            BackTask t = First;

            while (true)
            {
                if (t.Priority > task.Priority)
                {
                    // Found a task with a higher priority, so insert the new one before it
                    if (t != First)
                    {
                        BackTask prev = t.Prev;
                        task.Prev = prev;
                        prev.Next = task;
                    }
                    t.Prev    = task;
                    task.Next = t;
                    Count++;
                    return;
                }
                // Iterate to next task if there is one
                BackTask next = t.Next;
                if (next is null)
                {
                    // The new task is the highest priority or tied for it, so it gets placed at the last position
                    t.Next    = task;
                    task.Prev = t;
                    Count++;
                    return;
                }
                t = next;
            }
        }
Example #10
0
 public void Remove(BackTask task)
 {
     if (task == First)
     {
         BackTask next = task.Next;
         if (next is not null)
         {
             next.Prev = null;
         }
         First = next;
     }
     else
     {
         BackTask prev = task.Prev;
         BackTask next = task.Next;
         if (next is not null)
         {
             next.Prev = prev;
         }
         prev.Next = next;
     }
     task.Dispose();
     Count--;
 }