Esempio n. 1
0
    public static ChainedTask DownloadMapDependencies(MapData map, bool loadMap = false, bool showMap = false, bool showControls = false, ChainedTask chain = null)
    {
        TaskWrapper task = null;

        task = map.GetDownloadDependenciesTask(() =>
        {
            if (task != null && !task.cancelled && !chain.cancelled)
            {
                mapDependenciesDownloaded?.Invoke(map);
            }
        });

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        if (loadMap)
        {
            LoadMap(map, showMap, showControls, chain);
        }

        QueueTask(chain);

        return(chain);
    }
Esempio n. 2
0
    public static ChainedTask DownloadPreview(MapData map, Action onPreviewDownloaded, ChainedTask chain = null)
    {
        TaskWrapper task = null;

        task = map.GetDownloadPreviewTask(() =>
        {
            if (task != null && !task.cancelled && !chain.cancelled)
            {
                onPreviewDownloaded?.Invoke();
            }
        });

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        QueueTask(chain);

        return(chain);
    }
Esempio n. 3
0
 private static void QueueTask(ChainedTask task)
 {
     if (!queuedTasks.Contains(task))
     {
         queuedTasks.Enqueue(task);
     }
 }
Esempio n. 4
0
 public void LoadMatch(bool twoDee)
 {
     setToTwoDee = twoDee;
     if (!availableOffline)
     {
         matchChainedTask = TaskMaker.DownloadMatch(this, twoDee, !twoDee, true, true);
     }
     else
     {
         matchChainedTask = TaskMaker.GenerateMatchInfo(this, twoDee, !twoDee, true, true);
     }
 }
Esempio n. 5
0
    public static ChainedTask DownloadManifest(Action onManifestDownloaded, ChainedTask chain = null)
    {
        TaskWrapper task = SteamController.steamInScene.GetDownloadManifestTask(onManifestDownloaded);

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        QueueTask(chain);

        return(chain);
    }
Esempio n. 6
0
    public static ChainedTask DownloadFromSteam(string[] files, ChainedTask chain = null)
    {
        TaskWrapper task = SteamController.steamInScene.DownloadFromSteam(files);

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        QueueTask(chain);

        return(chain);
    }
Esempio n. 7
0
    private static ChainedTask GetMapLoadTask(MatchInfo match, bool load2DMap, bool load3DMap, bool showMap, bool showControls, ChainedTask chain = null)
    {
        if (chain == null)
        {
            chain = new ChainedTask();
        }

        string mapName = match.GetMapName();

        Debug.Assert(!string.IsNullOrEmpty(mapName), "TaskMaker: Could not determine map name from match");
        if (!string.IsNullOrEmpty(mapName))
        {
            MapData map = MapData.FindOrCreateMap(mapName);
            if (load2DMap && !map.IsLoading2D)
            {
                if (!map.IsOverviewAvailable())
                {
                    DownloadMap2D(map, showMap, showControls, chain);
                }
                else
                {
                    InvokeMapReady2D(map, showMap, showControls, chain);
                }
            }
            else if (load3DMap && !map.IsLoading3D)
            {
                if (!map.IsMapAvailable())
                {
                    DownloadMap3D(map, SettingsController.autoResourcePerMap, SettingsController.autoResourcePerMap, true, showMap, showControls, chain);
                }
                else if (!map.IsBuilt)
                {
                    LoadMap(map, showMap, showControls, chain);
                }
                else
                {
                    InvokeMapReady3D(map, showMap, showControls, chain);
                }
            }
        }

        QueueTask(chain);

        return(chain);
    }
Esempio n. 8
0
    public static ChainedTask LoadMap(MapData map, bool showMap, bool showControls, ChainedTask chain = null)
    {
        TaskWrapper task = map.GetStartLoadMapTask();

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        InvokeMapReady3D(map, showMap, showControls, chain);

        QueueTask(chain);

        return(chain);
    }
Esempio n. 9
0
    public static ChainedTask DownloadMap2D(MapData map, bool showMap, bool showControls, ChainedTask chain = null)
    {
        TaskWrapper task = map.GetDownloadOverviewTask();

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        InvokeMapReady2D(map, showMap, showControls, chain);

        QueueTask(chain);

        return(chain);
    }
Esempio n. 10
0
    public static ChainedTask GenerateMatchInfo(MatchInfo match, bool load2DMap, bool load3DMap, bool showMap, bool showControls, ChainedTask chain = null)
    {
        TaskWrapper task = match.GetMakeMatchInfoTask();

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        GetMapLoadTask(match, load2DMap, load3DMap, showMap, showControls, chain);

        QueueTask(chain);

        return(chain);
    }
Esempio n. 11
0
    private static void RunNextTask()
    {
        var nextTaskWrapper = currentTask?.GetCurrentTask();

        if (nextTaskWrapper == null || currentTask.cancelled)
        {
            currentTask     = null;
            nextTaskWrapper = null;
            if (queuedTasks.Count > 0)
            {
                currentTask     = queuedTasks.Dequeue();
                nextTaskWrapper = currentTask?.GetCurrentTask();
            }
        }

        if (nextTaskWrapper != null)
        {
            TaskManagerController.QueueTask(nextTaskWrapper);
        }
    }
 public void Download()
 {
     CancelUpdateChecks();
     if (!IsLoading)
     {
         SettingsController.SaveSettings();
         if (SteamController.steamInScene.IsLoggedIn)
         {
             var paksToDownload = SettingsController.GetTrackedPaks();
             downloadTask = TaskMaker.DownloadFromSteam(paksToDownload);
         }
         else
         {
             SteamController.ShowErrorPopup("Download Error", "You must be logged in to download resources");
         }
     }
     else
     {
         downloadTask.Cancel();
         downloadTask = null;
     }
 }
Esempio n. 13
0
 public void LoadMap3D(bool showMap, bool showControls)
 {
     if (!IsMapAvailable())
     {
         if (SteamController.steamInScene.IsLoggedIn)
         {
             map3DChainTask = TaskMaker.DownloadMap3D(this, SettingsController.autoResourcePerMap, SettingsController.autoResourcePerMap, true, showMap, showControls);
         }
         else
         {
             SteamController.ShowErrorPopup("Download Error", "You must be logged in to download a map");
         }
     }
     else if (IsBuilt)
     {
         map3DChainTask = TaskMaker.InvokeMapReady3D(this, showMap, showControls);
     }
     else
     {
         map3DChainTask = TaskMaker.LoadMap(this, showMap, showControls);
     }
 }
Esempio n. 14
0
    public static ChainedTask InvokeMapReady3D(MapData map, bool showMap, bool showControls, ChainedTask chain = null)
    {
        TaskWrapper task = TaskManagerController.CreateTask((cts) =>
        {
            if (!chain.cancelled)
            {
                mapReady3D?.Invoke(map, showMap, showControls);
            }
        });

        if (chain == null)
        {
            chain = new ChainedTask(task);
        }
        else
        {
            chain.AddTask(task);
        }

        QueueTask(chain);

        return(chain);
    }
Esempio n. 15
0
    public static ChainedTask DownloadMatch(MatchInfo match, bool load2DMap, bool load3DMap, bool showMap, bool showControls, ChainedTask chain = null)
    {
        if (chain == null)
        {
            chain = new ChainedTask();
        }

        TaskWrapper task = match.GetDownloadTask((success) =>
        {
            if (!success)
            {
                chain.Cancel();
            }
        });

        chain.AddTask(task);

        GenerateMatchInfo(match, load2DMap, load3DMap, showMap, showControls, chain);

        QueueTask(chain);

        return(chain);
    }
Esempio n. 16
0
 /*public static bool IsQueued(ChainedTask task)
  * {
  *  return task != null && queuedTasks.Contains(task);
  * }*/
 public static bool HasChainedTask(ChainedTask chainedTask)
 {
     return(chainedTask != null && (queuedTasks.Contains(chainedTask) || chainedTask == currentTask));
 }