Ejemplo n.º 1
0
    private void CancellableStartLoadMap(CancellationToken cancelToken, Action onCompleted = null)
    {
        loadedMap?.UnloadMap();
        loadedMap = this;

        //status = "Loading Map";

        CreateMapObjectIfNotExist();

        if (map != null)
        {
            SteamController.LogToConsole("\nLoading " + map.mapName);
            try
            {
                map.ParseFile(cancelToken, null, null);
            }
            catch (Exception e)
            {
                Debug.LogError("MapData: Error while loading map " + e.ToString());
            }

            if (!cancelToken.IsCancellationRequested)
            {
                MakeGameObject(onCompleted);
            }
            else
            {
                UnloadMap();
            }
        }
    }
Ejemplo n.º 2
0
    public BSPMap LoadMap(string vpkLoc, string mapLoc, bool combineMeshesWithSameTextures = true, float faceLoadPercent = 1, float modelLoadPercent = 1, bool flatTextures = false, int maxTextureSize = 2048)
    {
        BSPMap.vpkLoc = vpkLoc;
        BSPMap map = new BSPMap(mapLoc);

        BSPMap.combineMeshesWithSameTexture = combineMeshesWithSameTextures;
        BSPMap.FaceLoadPercent        = faceLoadPercent;
        BSPMap.ModelLoadPercent       = modelLoadPercent;
        SourceTexture.averageTextures = flatTextures;
        SourceTexture.maxTextureSize  = maxTextureSize;

        map.ParseFile(System.Threading.CancellationToken.None);
        map.MakeGameObject(null, (go) => { go.transform.SetParent(transform, false); go.SetActive(true); });

        return(map);
    }
    public BSPMap LoadMap(string vpkLoc, string mapLoc, bool combineMeshesWithSameTextures = true, float faceLoadPercent = 1, float modelLoadPercent = 1, bool flatTextures = false, int maxTextureSize = 2048)
    {
        BSPMap.vpkLoc = vpkLoc;
        BSPMap map = new BSPMap(mapLoc);

        BSPMap.combineMeshesWithSameTexture = combineMeshesWithSameTextures;
        BSPMap.FaceLoadPercent        = faceLoadPercent;
        BSPMap.ModelLoadPercent       = modelLoadPercent;
        SourceTexture.averageTextures = flatTextures;
        SourceTexture.maxTextureSize  = maxTextureSize;

        loadingTask = UnityHelpers.TaskManagerController.RunActionAsync("Parsing Map", (cancelToken) => { map.ParseFile(cancelToken, null, () =>
            {
                if (!loadingTask.cancelled)
                {
                    UnityHelpers.TaskManagerController.RunAction(() => { map.MakeGameObject(null, (go) => { go.SetActive(true); }); });
                }
            }); });

        return(map);
    }