public void setDisplayInfo(ref LobbyDisplayInfo info)
            {
                uint num  = info.NumPlayersForDisplay - 1;
                uint num2 = info.FeaturesMask & 0x1F;

                flags = ((flags & ~num2) | (info.Flags & num2));
                if (((int)info.FeaturesMask & int.MinValue) != 0)
                {
                    playersCurrent = num;
                }
                if ((info.FeaturesMask & 0x40000000) != 0)
                {
                    playersMax = info.MaxPlayers;
                }
                if ((info.FeaturesMask & 0x20000000) != 0)
                {
                    levelID = info.LevelID;
                }
                if ((info.FeaturesMask & 0x10000000) != 0)
                {
                    levelType = info.LevelType;
                }
                if ((info.FeaturesMask & 0x8000000) != 0)
                {
                    lobbyTitle = info.LobbyTitle;
                }
            }
        public override void OnGotFocus()
        {
            base.OnGotFocus();
            restartButton.SetActive(NetGame.isServer);
            inviteButton.SetActive(NetGame.isServer && NetGame.instance.transport.CanSendInvite());
            if (!ExitText)
            {
                Debug.LogWarning("EXIT BUTTON reference not set in editor");
                return;
            }
            if (NetGame.isServer)
            {
                ExitText.SetText(ScriptLocalization.Get("MENU/PAUSE/EXIT TO LOBBY"));
            }
            else
            {
                ExitText.SetText(ScriptLocalization.Get("MENU/PAUSE/EXIT TO MAIN MENU"));
            }
            informationBox.gameObject.SetActive(value: true);
            NetGame.instance.transport.RegisterForLobbyData(OnLobbyDataUpdate);
            lobbyRefreshTimer = 0f;
            WorkshopItemSource currentLevelType = Game.instance.currentLevelType;

            if (currentLevelType == WorkshopItemSource.BuiltIn || currentLevelType == WorkshopItemSource.EditorPick)
            {
                workshopLevelButton.gameObject.SetActive(value: false);
                return;
            }
            workshopLevelButton.gameObject.SetActive(value: true);
            NetGame.instance.transport.RegisterForGameOverlayActivation(OnGameOverlayActivation);
        }
Beispiel #3
0
 public void LevelLoadedServer(ulong level, WorkshopItemSource levelType, uint hash)
 {
     lock (stateLock)
     {
         if (state == AppSate.ServerLoadLevel)
         {
             Dialogs.HideProgress();
             MenuCameraEffects.FadeOut(1f);
             if (hash == 0 || hash == 57005)
             {
                 NetGame.instance.StopServer();
                 ExitGame();
                 EnterMenu();
                 UnityEngine.Debug.LogError("LevelNotNetReady");
                 Dialogs.CreateServerFailed("LevelNotNetReady", delegate
                 {
                     MenuSystem.instance.ShowMenu <MainMenu>();
                 });
             }
             else
             {
                 state = AppSate.ServerPlayLevel;
                 NetGame.instance.ServerLoadLevel(level, levelType, start: true, (hash != 0) ? hash : 57005u);
             }
         }
     }
 }
Beispiel #4
0
 public void LaunchCustomLevel(string path, WorkshopItemSource levelType, int checkpoint, int subObjectives)
 {
     StartCoroutine(LaunchGame(path, 0uL, levelType, checkpoint, subObjectives, delegate
     {
         MenuCameraEffects.FadeOut(1f);
         state = AppSate.PlayLevel;
     }));
 }
Beispiel #5
0
 public void LaunchSinglePlayer(ulong level, WorkshopItemSource levelType, int checkpoint, int subObjectives)
 {
     startedCheckpoint = checkpoint;
     LaunchGame(level, levelType, checkpoint, subObjectives, delegate
     {
         MenuCameraEffects.FadeOut(1f);
         state = AppSate.PlayLevel;
     });
 }
Beispiel #6
0
 private void Clear(WorkshopItemSource source)
 {
     foreach (ModelPartRepository value in modelRepos.Values)
     {
         value.Clear(source);
     }
     levelRepo.Clear(source);
     presetRepo.Clear(source);
 }
Beispiel #7
0
    public void Clear(WorkshopItemSource source)
    {
        List <T> list = bySource[source];

        for (int i = 0; i < list.Count; i++)
        {
            Remove(list[i]);
        }
        list.Clear();
    }
Beispiel #8
0
 public void InitBlank()
 {
     FeaturesMask         = 0u;
     NumPlayersForDisplay = 0u;
     MaxPlayers           = 0u;
     LevelID    = 0uL;
     LevelType  = WorkshopItemSource.BuiltIn;
     LobbyTitle = string.Empty;
     Flags      = 0u;
 }
Beispiel #9
0
    public bool IsWorkshopLevel()
    {
        WorkshopItemSource workshopItemSource = currentLevelType;

        if (workshopItemSource == WorkshopItemSource.Subscription || workshopItemSource == WorkshopItemSource.LocalWorkshop)
        {
            return(true);
        }
        return(false);
    }
Beispiel #10
0
 protected void RemoveItem(WorkshopItemSource source, WorkshopItemMetadata item)
 {
     if (item != null)
     {
         Remove((T)item);
         foreach (List <T> value in bySource.Values)
         {
             value.Remove((T)item);
         }
     }
 }
Beispiel #11
0
 public void ChangeLobbyLevel(ulong level, WorkshopItemSource levelType)
 {
     lock (stateLock)
     {
         if (state == AppSate.ServerLobby)
         {
             NetGame.instance.ServerLoadLevel(level, levelType, start: false, 0u);
             if (MenuSystem.instance.activeMenu is MultiplayerLobbyMenu)
             {
                 (MenuSystem.instance.activeMenu as MultiplayerLobbyMenu).RebindLevel();
             }
         }
     }
 }
Beispiel #12
0
 public void StartGameServer(ulong level, WorkshopItemSource levelType)
 {
     startedCheckpoint = 0;
     lock (stateLock)
     {
         if (state == AppSate.ServerLobby)
         {
             ExitLobby(startingGame: true);
             NetGame.instance.ServerLoadLevel(level, levelType, start: true, 0u);
             LaunchGame(level, levelType, 0, 0, delegate
             {
                 LevelLoadedServer(level, levelType, Game.currentLevel.netHash);
             });
         }
     }
 }
Beispiel #13
0
 private void LaunchGame(ulong level, WorkshopItemSource levelType, int checkpoint, int subObjectives, Action onComplete)
 {
     StopPlaytimeForItem(previousLobbyID);
     previousLobbyID = 0uL;
     MenuSystem.instance.HideMenus();
     CheatCodes.cheatMode = false;
     if (levelType == WorkshopItemSource.BuiltIn && level == 0 && checkpoint == 0)
     {
         Game.instance.singleRun = true;
     }
     SuspendDeltasForLoad();
     StartCoroutine(LaunchGame(null, level, levelType, checkpoint, subObjectives, delegate
     {
         onComplete();
     }));
 }
Beispiel #14
0
    public void AddItem(WorkshopItemSource source, WorkshopItemMetadata item)
    {
        item.levelType = source;
        T item2 = GetItem(item.folder);

        if (item2 != null)
        {
            int index = IndexOf(item2);
            base[index]             = (T)item;
            index                   = bySource[source].IndexOf(item2);
            bySource[source][index] = (T)item;
        }
        else
        {
            bySource[source].Add((T)item);
            Add((T)item);
        }
    }
    public void GetLevel(ulong levelId, WorkshopItemSource levelType, Action <WorkshopLevelMetadata> onRead)
    {
        if (OnSteamUGCQueryCompletedCallResult != null)
        {
            OnSteamUGCQueryCompletedCallResult.Cancel();
            OnSteamUGCQueryCompletedCallResult = null;
        }
        if (OnUGCDownloadCallResult != null)
        {
            OnUGCDownloadCallResult.Cancel();
            OnUGCDownloadCallResult = null;
        }
        switch (levelType)
        {
        case WorkshopItemSource.BuiltIn:
            onRead(GetItem("builtin:" + levelId.ToString()));
            return;

        case WorkshopItemSource.EditorPick:
            onRead(GetItem("editorpick:" + levelId.ToString()));
            return;
        }
        WorkshopLevelMetadata item = GetItem("ws:" + levelId.ToString() + "/");

        if (item != null)
        {
            onRead(item);
            return;
        }
        this.onRead = onRead;
        UGCQueryHandle_t handle = SteamUGC.CreateQueryUGCDetailsRequest(new PublishedFileId_t[1]
        {
            new PublishedFileId_t(levelId)
        }, 1u);

        OnSteamUGCQueryCompletedCallResult = CallResult <SteamUGCQueryCompleted_t> .Create(OnSteamUGCQueryCompleted);

        SteamAPICall_t hAPICall = SteamUGC.SendQueryUGCRequest(handle);

        OnSteamUGCQueryCompletedCallResult.Set(hAPICall);
    }
Beispiel #16
0
    private void ReadFolder(WorkshopItemSource source, string folder)
    {
        WorkshopItemMetadata workshopItemMetadata = WorkshopItemMetadata.Load(folder);

        if (workshopItemMetadata == null)
        {
            return;
        }
        switch (workshopItemMetadata.itemType)
        {
        case WorkshopItemType.Level:
            break;

        case WorkshopItemType.Levels:
            if (source == WorkshopItemSource.Subscription || source == WorkshopItemSource.LocalWorkshop)
            {
                levelRepo.AddItem(source, workshopItemMetadata);
            }
            break;

        case WorkshopItemType.Lobbies:
            if (source == WorkshopItemSource.SubscriptionLobbies || source == WorkshopItemSource.LocalWorkshop)
            {
                levelRepo.AddItem(source, workshopItemMetadata);
            }
            break;

        case WorkshopItemType.RagdollPreset:
            presetRepo.AddItem(source, workshopItemMetadata);
            break;

        default:
            modelRepos[workshopItemMetadata.itemType].AddItem(source, workshopItemMetadata);
            break;
        }
    }
Beispiel #17
0
    public void EnterCheckpoint(int checkpoint, int subObjectives)
    {
        if (state != GameState.PlayingLevel)
        {
            return;
        }
        bool flag = false;

        if (currentCheckpointNumber < checkpoint)
        {
            flag = true;
        }
        else if (currentLevel.nonLinearCheckpoints && currentCheckpointNumber != checkpoint)
        {
            flag = true;
        }
        else if (currentCheckpointNumber == checkpoint && subObjectives != 0)
        {
            flag = true;
        }
        if (!flag)
        {
            return;
        }
        Debug.Log("Passed " + checkpoint + ", subobjectives: " + subObjectives);
        int num  = currentCheckpointNumber;
        int num2 = currentCheckpointSubObjectives;

        if (currentCheckpointNumber != checkpoint)
        {
            currentCheckpointSubObjectives = 0;
        }
        if (subObjectives != 0)
        {
            currentCheckpointSubObjectives |= 1 << subObjectives - 1;
        }
        currentCheckpointNumber = checkpoint;
        if (workshopLevel == null && currentLevelNumber != -1)
        {
            if (NetGame.isLocal)
            {
                WorkshopItemSource workshopItemSource = currentLevelType;
                if (workshopItemSource == WorkshopItemSource.EditorPick)
                {
                    GameSave.PassCheckpointEditorPick((uint)currentLevelNumber, checkpoint, currentCheckpointSubObjectives);
                }
                else
                {
                    GameSave.PassCheckpointCampaign((uint)currentLevelNumber, checkpoint, currentCheckpointSubObjectives);
                }
            }
            if (num != currentCheckpointNumber || num2 != currentCheckpointSubObjectives)
            {
                SubtitleManager.instance.SetProgress(ScriptLocalization.TUTORIAL.SAVING, 1f, 1f);
            }
        }
        else
        {
            if (NetGame.isLocal)
            {
                GameSave.PassCheckpointWorkshop(workshopLevel.hash, checkpoint);
            }
            SubtitleManager.instance.SetProgress(ScriptLocalization.TUTORIAL.SAVING, 1f, 1f);
        }
        if (NetGame.isServer)
        {
            NetSceneManager.EnterCheckpoint(checkpoint, subObjectives);
        }
    }
    public void Rebind()
    {
        bool flag = displayMode == LevelSelectMenuMode.SubscribedWorkshop;

        UpdateTitle();
        DisableLevelContinue();
        bool flag2 = false;

        flag2             = SteamUser.BLoggedOn();
        InLevelSelectMenu = (displayMode != 0 && displayMode != LevelSelectMenuMode.LocalWorkshop);
        showCustomButton.SetActive(value: false);
        showSubscribedButton.SetActive(value: false);
        subscribedSubtitle.SetActive(value: false);
        customSubtitle.SetActive(value: false);
        ShowLocalLevelButton.SetActive(value: false);
        InvalidLevelInfoPanel.SetActive(value: false);
        noSubscribedPrompt.SetActive(value: false);
        offlinePanel.SetActive(value: false);
        noLocalPrompt.SetActive(value: false);
        List <WorkshopLevelMetadata> list = null;

        switch (displayMode)
        {
        case LevelSelectMenuMode.Campaign:
            WorkshopRepository.instance.LoadBuiltinLevels(isMultiplayer && IsLobbyMode());
            list = WorkshopRepository.instance.levelRepo.BySource(IsLobbyMode() ? WorkshopItemSource.BuiltInLobbies : WorkshopItemSource.BuiltIn);
            break;

        case LevelSelectMenuMode.EditorPicks:
            WorkshopRepository.instance.LoadEditorPickLevels();
            list = WorkshopRepository.instance.levelRepo.BySource(WorkshopItemSource.EditorPick);
            break;

        case LevelSelectMenuMode.SubscribedWorkshop:
            if (flag2)
            {
                WorkshopRepository.instance.ReloadSubscriptions();
                list = WorkshopRepository.instance.levelRepo.BySource(WorkshopItemSource.Subscription);
            }
            break;

        case LevelSelectMenuMode.LocalWorkshop:
            WorkshopRepository.instance.ReloadLocalLevels();
            list = WorkshopRepository.instance.levelRepo.BySource(WorkshopItemSource.LocalWorkshop);
            break;

        case LevelSelectMenuMode.BuiltInLobbies:
            WorkshopRepository.instance.LoadBuiltinLevels(requestLobbies: true);
            list = WorkshopRepository.instance.levelRepo.BySource(WorkshopItemSource.BuiltInLobbies);
            break;

        case LevelSelectMenuMode.WorkshopLobbies:
            if (flag2)
            {
                WorkshopRepository.instance.ReloadSubscriptions(isLobby: true);
                list = WorkshopRepository.instance.levelRepo.BySource(WorkshopItemSource.SubscriptionLobbies);
            }
            break;
        }
        if (list == null)
        {
            list = new List <WorkshopLevelMetadata>();
        }
        if (!CouldShowFindMore())
        {
            FindMoreButton.SetActive(value: false);
        }
        customFolder.text = CustomDataPath;
        if (list.Count == 0)
        {
            this.list.Bind(list);
            itemListImage.color = itemListError;
            if (!flag2)
            {
                offlinePanel.SetActive(value: true);
            }
            else if (IsLobbyMode())
            {
                noSubscribedPrompt.SetActive(value: true);
            }
            else if (displayMode == LevelSelectMenuMode.SubscribedWorkshop)
            {
                noSubscribedPrompt.SetActive(value: true);
            }
            else
            {
                noLocalPrompt.SetActive(value: true);
            }
            EventSystem.current.SetSelectedGameObject(BackButton.gameObject);
            levelImage.SetActive(value: false);
            LevelDescriptionPanel.SetActive(value: false);
        }
        else
        {
            itemListImage.color = itemListNormal;
            levelInfoPanel.SetActive(value: true);
            levelImage.SetActive(!flag);
            LevelDescriptionPanel.SetActive(flag);
            this.list.Bind(list);
            int num = 0;
            if (!string.IsNullOrEmpty(selectedPath))
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (FolderMatch(list[i].folder, selectedPath))
                    {
                        num = i;
                        break;
                    }
                }
            }
            GameSave.GetLastSave(out int levelNumber, out int _, out int _, out float _);
            WorkshopItemSource lastCheckpointLevelType = GameSave.GetLastCheckpointLevelType();
            bool flag3 = false;
            switch (lastCheckpointLevelType)
            {
            case WorkshopItemSource.BuiltIn:
                flag3 = (displayMode == LevelSelectMenuMode.Campaign);
                break;

            case WorkshopItemSource.EditorPick:
                flag3 = (displayMode == LevelSelectMenuMode.EditorPicks);
                break;

            default:
                flag3 = false;
                break;
            }
            if (flag3)
            {
                if (levelNumber < this.list.GetNumberItems - 1)
                {
                    this.list.FocusItem(levelNumber);
                }
                else
                {
                    this.list.FocusItem(0);
                }
            }
            else
            {
                this.list.FocusItem(0);
            }
        }
        topPanel.Invalidate();
        EnableShowLevelButtons();
        BindLevelIfNeeded(selectedMenuItem);
        if (previousSelectedItem != null)
        {
            StartCoroutine(WaitAndSelect());
        }
    }
Beispiel #19
0
 public virtual void UpdateServerLevel(ulong levelID, WorkshopItemSource levelType)
 {
 }
Beispiel #20
0
 public void OnRequestLoadLevel(ulong level, WorkshopItemSource levelType, bool start, uint hash)
 {
     if (start && loadingLevel != level)
     {
         RatingMenu.instance.LoadInit();
     }
     if (NetGame.netlog)
     {
         UnityEngine.Debug.LogFormat("On RequestLoad {0} {1} {2} {3}", level, levelType, start, hash);
     }
     lock (stateLock)
     {
         if (state == AppSate.ClientLoadLevel || state == AppSate.ClientLoadLobby)
         {
             if (NetGame.netlog)
             {
                 UnityEngine.Debug.Log("Queueing on request load");
             }
             queueAfterLevelLoad = delegate
             {
                 OnRequestLoadLevel(level, levelType, start, hash);
             };
         }
         else
         {
             queueAfterLevelLoad = null;
             if (hash == 0)
             {
                 serverLoadedLevel = 57005uL;
             }
             if (!start)
             {
                 loadingLevel        = (loadedLevel = 57005uL);
                 loadedHash          = 0u;
                 queueAfterLevelLoad = null;
                 if (state == AppSate.ClientLobby)
                 {
                     MultiplayerLobbyMenu multiplayerLobbyMenu = MenuSystem.instance.activeMenu as MultiplayerLobbyMenu;
                     if (multiplayerLobbyMenu != null)
                     {
                         multiplayerLobbyMenu.RebindLevel();
                     }
                     state = AppSate.ClientLobby;
                 }
                 else if (isClient)
                 {
                     RatingMenu.instance.LevelOver();
                     if (Game.instance.state == GameState.Paused || Game.instance.state == GameState.PlayingLevel)
                     {
                         ExitGame();
                     }
                     if (RatingMenu.instance.ShowRatingMenu())
                     {
                         GotoRatingsMenu(RatingMenu.RatingDestination.kMultiplayerLobby, showLoading: true);
                     }
                     else
                     {
                         MenuCameraEffects.FadeToBlack(0.02f);
                         Dialogs.ShowLoadLevelProgress(57005uL);
                     }
                     EnterLobby(isServer: false, delegate
                     {
                         state = AppSate.ClientLobby;
                     });
                 }
             }
             else
             {
                 if (loadingLevel != level)
                 {
                     if (state == AppSate.ClientLobby)
                     {
                         ExitLobby();
                     }
                     loadingLevel = level;
                     LaunchGame(level, levelType, 0, 0, delegate
                     {
                         loadedLevel = level;
                         loadedHash  = Game.currentLevel.netHash;
                         if (!LevelLoadedClient())
                         {
                             state = AppSate.ClientWaitServerLoad;
                         }
                     });
                 }
                 if (hash != 0)
                 {
                     serverLoadedLevel = level;
                     serverLoadedHash  = hash;
                     LevelLoadedClient();
                 }
             }
         }
     }
 }
Beispiel #21
0
 public List <T> BySource(WorkshopItemSource source)
 {
     return(bySource[source]);
 }
Beispiel #22
0
 public void BeginLoadLevel(string levelId, ulong levelNumber, int checkpointNumber, int checkpointSubObjectives, Action onComplete, WorkshopItemSource type)
 {
     passedLevel = false;
     StartCoroutine(LoadLevel(levelId, levelNumber, checkpointNumber, checkpointSubObjectives, onComplete, type));
 }
    public void BindLevel(WorkshopLevelMetadata level)
    {
        if (boundLevel != null)
        {
            boundLevel.ReleaseThumbnailReference();
        }
        boundLevel = level;
        if (boundLevel != null)
        {
            selectedPath = boundLevel.folder;
            BindImage(boundLevel.thumbnailTexture);
            levelName.text             = boundLevel.title;
            LevelDescriptionTitle.text = boundLevel.title;
            BuildMetaAndDescription();
            LevelDescriptionDescription.text = levelDescriptionBuilder.ToString();
            if (!isMultiplayer)
            {
                bool flag = false;
                WorkshopItemSource levelType = level.levelType;
                if (levelType == WorkshopItemSource.LocalWorkshop || levelType == WorkshopItemSource.Subscription)
                {
                    checkpointToStart = Game.instance.gameProgress.GetProgressWorkshop(level.hash);
                    if (checkpointToStart > 0)
                    {
                        flag = true;
                    }
                }
                else
                {
                    flag = false;
                }
                if (flag)
                {
                    EnableLevelContinue();
                }
                else
                {
                    DisableLevelContinue();
                }
            }
        }
        else
        {
            selectedPath = null;
            BindImage(null);
            levelName.text = "MISSING";
        }
        workshopMissingThubnail.SetActive(value: false);
        workshopMissingDescription.SetActive(value: false);
        InvalidLevelInfoPanel.SetActive(value: false);
        levelImage.SetActive(displayMode != LevelSelectMenuMode.LocalWorkshop);
        LevelDescriptionPanel.SetActive(displayMode == LevelSelectMenuMode.LocalWorkshop);
        PublishButton.interactable = true;
        if (displayMode != LevelSelectMenuMode.LocalWorkshop)
        {
            return;
        }
        Texture2D thumbnailTexture = boundLevel.thumbnailTexture;
        bool      flag2            = thumbnailTexture == null;
        bool      flag3            = string.IsNullOrEmpty(boundLevel.description);
        bool      flag4            = string.IsNullOrEmpty(boundLevel.title);

        mLevelError = (flag2 || flag3 || flag4);
        if (mLevelError)
        {
            bool flag5 = flag4 && !flag3 && !flag2;
            workshopMissingThubnail.SetActive(flag2);
            workshopMissingDescription.SetActive(flag3);
            if (!flag5)
            {
                levelImage.SetActive(value: false);
                InvalidLevelInfoPanel.SetActive(value: true);
                LevelDescriptionPanel.SetActive(value: false);
            }
            PublishButton.interactable = false;
        }
    }
Beispiel #24
0
    private IEnumerator LoadLevel(string levelId, ulong levelNumber, int checkpointNumber, int checkpointSubObjectives, Action onComplete, WorkshopItemSource levelType)
    {
        bool localLevel = false;

        NetScope.ClearAllButPlayers();
        BeforeLoad();
        skyColor       = RenderSettings.ambientLight;
        skyboxMaterial = RenderSettings.skybox;
        state          = GameState.LoadingLevel;
        bool isBundle = !string.IsNullOrEmpty(levelId) || (levelNumber > 16 && levelNumber != ulong.MaxValue);

        if (isBundle)
        {
            if (string.IsNullOrEmpty(levelId))
            {
                bool loaded2 = false;
                WorkshopRepository.instance.levelRepo.GetLevel(levelNumber, levelType, delegate(WorkshopLevelMetadata l)
                {
                    workshopLevel = l;
                    loaded2       = true;
                });
                while (!loaded2)
                {
                    yield return(null);
                }
            }
            else
            {
                localLevel    = levelId.StartsWith("lvl:");
                workshopLevel = WorkshopRepository.instance.levelRepo.GetItem(levelId);
            }
            RatingMenu.instance.LoadInit();
            if (!localLevel && workshopLevel != null)
            {
                App.StartPlaytimeForItem(workshopLevel.workshopId);
                RatingMenu.instance.QueryRatingStatus(workshopLevel.workshopId);
            }
        }
        App.StartPlaytimeLocalPlayers();
        if (currentLevelNumber != (int)levelNumber)
        {
            Level oldLevel = currentLevel;
            SubtitleManager.instance.SetProgress(ScriptLocalization.TUTORIAL.LOADING);
            Application.backgroundLoadingPriority = ThreadPriority.Low;
            string sceneName = string.Empty;
            currentLevelType = levelType;
            switch (levelType)
            {
            case WorkshopItemSource.BuiltIn:
                sceneName = levels[levelNumber];
                break;

            case WorkshopItemSource.EditorPick:
                Debug.Log("Loading editor pick level");
                sceneName = editorPickLevels[(uint)levelNumber];
                break;
            }
            Debug.Log("scename = " + sceneName);
            if (!isBundle)
            {
                if (string.IsNullOrEmpty(sceneName))
                {
                    sceneName = levels[levelNumber];
                }
            }
            else
            {
                if (!localLevel && workshopLevel != null)
                {
                    bool loaded = false;
                    WorkshopRepository.instance.levelRepo.LoadLevel(workshopLevel.workshopId, delegate(WorkshopLevelMetadata l)
                    {
                        workshopLevel = l;
                        loaded        = true;
                    });
                    while (!loaded)
                    {
                        yield return(null);
                    }
                }
                bundle = null;
                if (workshopLevel != null)
                {
                    bundle = FileTools.LoadBundle(workshopLevel.dataPath);
                }
                if (bundle == null)
                {
                    SubtitleManager.instance.ClearProgress();
                    Debug.Log("Level load failed.");
                    App.instance.ServerFailedToLoad();
                    SignalManager.EndReset();
                    yield break;
                }
                string[] scenePath = bundle.GetAllScenePaths();
                if (string.IsNullOrEmpty(sceneName))
                {
                    sceneName = Path.GetFileNameWithoutExtension(scenePath[0]);
                }
            }
            instance.HasSceneLoaded = false;
            SwitchAssetBundle.LoadingCurrentScene loader2 = SwitchAssetBundle.LoadSceneAsync(sceneName);
            if (loader2 == null)
            {
                AsyncOperation sceneLoader2 = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
                while (!sceneLoader2.isDone || !instance.HasSceneLoaded)
                {
                    yield return(null);
                }
                sceneLoader2 = null;
                SubtitleManager.instance.SetProgress(ScriptLocalization.TUTORIAL.LOADING, 1f, 1f);
                currentLevelNumber = (int)levelNumber;
            }
            else
            {
                while (!loader2.isDone || !instance.HasSceneLoaded)
                {
                    yield return(null);
                }
                loader2 = null;
                SubtitleManager.instance.SetProgress(ScriptLocalization.TUTORIAL.LOADING, 1f, 1f);
                currentLevelNumber = (int)levelNumber;
            }
        }
        if (currentLevel == null)
        {
            SignalManager.EndReset();
            onComplete?.Invoke();
            yield break;
        }
        if (isBundle)
        {
            FixupLoadedBundle(SceneManager.GetActiveScene());
            bundle.Unload(unloadAllLoadedObjects: false);
        }
        if (currentLevelNumber >= 0 && !isBundle)
        {
            HumanAnalytics.instance.LoadLevel(levels[currentLevelNumber], (int)levelNumber, checkpointNumber, 0f);
        }
        FixAssetBundleImport();
        AfterLoad(checkpointNumber, checkpointSubObjectives);
        if (NetGame.isLocal)
        {
            if (levelType == WorkshopItemSource.BuiltIn && currentLevelNumber < levelCount - 1)
            {
                GameSave.PassCheckpointCampaign((uint)currentLevelNumber, checkpointNumber, checkpointSubObjectives);
            }
            if (levelType == WorkshopItemSource.EditorPick)
            {
                GameSave.PassCheckpointEditorPick((uint)currentLevelNumber, checkpointNumber, checkpointSubObjectives);
            }
        }
        onComplete?.Invoke();
    }
Beispiel #25
0
        private IEnumerator LaunchGame(string levelPath, ulong level, WorkshopItemSource type, int checkpoint, int subObjectives, Action onComplete)
        {
            object obj = stateLock;

            Monitor.Enter(obj);
            try
            {
                if (state == AppSate.Menu || state == AppSate.PlayLevel || state == AppSate.ClientJoin || state == AppSate.ClientLobby || state == AppSate.ClientPlayLevel || state == AppSate.ClientWaitServerLoad || state == AppSate.ServerLobby || state != AppSate.ServerPlayLevel)
                {
                }
                bool ui = state == AppSate.Menu || state == AppSate.ServerLobby || state == AppSate.ClientLobby || state == AppSate.ClientJoin;
                if (ui)
                {
                    MenuSystem.instance.FadeOutActive();
                }
                if (isServer || isClient)
                {
                    MenuCameraEffects.FadeToBlack((!ui) ? 0.02f : 0.2f);
                    Dialogs.ShowLoadLevelProgress(level);
                }
                if (isServer)
                {
                    state = AppSate.ServerLoadLevel;
                }
                else if (isClient)
                {
                    state = AppSate.ClientLoadLevel;
                }
                else
                {
                    state = AppSate.LoadLevel;
                }
                queueAfterLevelLoad = null;
                if (ui)
                {
                    yield return(new WaitForSeconds(0.2f));
                }
                NetStream.DiscardPools();
                Game.instance.BeginLoadLevel(levelPath, level, checkpoint, subObjectives, delegate
                {
                    lock (stateLock)
                    {
                        if (state == AppSate.LoadLevel || state == AppSate.ServerLoadLevel || state != AppSate.ClientLoadLevel)
                        {
                        }
                        MenuSystem.instance.ExitMenus();
                        NetStream.DiscardPools();
                        ResumeDeltasAfterLoad();
                        if (onComplete != null)
                        {
                            onComplete();
                        }
                        if (queueAfterLevelLoad != null)
                        {
                            Action action       = queueAfterLevelLoad;
                            queueAfterLevelLoad = null;
                            if (NetGame.netlog)
                            {
                                UnityEngine.Debug.Log("Executing queue");
                            }
                            action();
                        }
                    }
                }, type);
            }
            finally
            {
            }
        }