public void SetLobbyTitle(ulong lobbyID) { if (lobbyID >= 128) { List <WorkshopLevelMetadata> list = instance.levelRepo.BySource(WorkshopItemSource.SubscriptionLobbies); foreach (WorkshopLevelMetadata item in list) { if (item.workshopId == lobbyID) { App.instance.SetLobbyTitle(item.title); return; } } WorkshopLevelMetadata levelMetaDataFromID = GetLevelMetaDataFromID(lobbyID); if (levelMetaDataFromID != null) { App.instance.SetLobbyTitle(levelMetaDataFromID.title); return; } Game.multiplayerLobbyLevel = 0uL; lobbyID = 0uL; } string lobbyTitle = string.Empty; if (lobbyID < 128) { lobbyTitle = "\u0011\u0012" + (char)(lobbyID + 48); } App.instance.SetLobbyTitle(lobbyTitle); }
public void OnDestroy() { if (boundData != null) { boundData.ReleaseThumbnailReference(); } boundData = null; }
private void OnApplicationFocus(bool hasFocus) { if (hasFocus) { boundLevel = null; Rebind(); } }
public override void OnLostFocus() { base.OnLostFocus(); NetGame.instance.transport.UnregisterForLobbyData(OnLobbyDataUpdate); if (level != null) { level.ReleaseThumbnailReference(); level = null; } m_MenuOptions.SetPlayerActionVisibility(flag: false); }
private void BindLevelIfNeeded(WorkshopMenuItem item) { if (!(item == null)) { WorkshopLevelMetadata level = item.level; if (boundLevel == null || level.folder != boundLevel.folder) { BindLevel(level); } } }
public override void OnLostFocus() { base.OnLostFocus(); list.Clear(); if (boundLevel != null) { boundLevel.ReleaseThumbnailReference(); boundLevel = null; } InDLCMenu = false; }
public void RebindLevel() { if (level != null) { level.ReleaseThumbnailReference(); } switch (NetGame.instance.currentLevelType) { case WorkshopItemSource.BuiltIn: WorkshopRepository.instance.LoadBuiltinLevels(); break; case WorkshopItemSource.BuiltInLobbies: WorkshopRepository.instance.LoadBuiltinLevels(requestLobbies: true); break; case WorkshopItemSource.EditorPick: WorkshopRepository.instance.LoadEditorPickLevels(); break; } WorkshopRepository.instance.levelRepo.GetLevel(NetGame.instance.currentLevel, NetGame.instance.currentLevelType, delegate(WorkshopLevelMetadata l) { level = l; bool flag = false; if (level != null) { if (NetGame.isServer && DLC.instance.SupportsDLC() && level.workshopId < 16 && !DLC.instance.LevelIsAvailable((int)level.workshopId)) { flag = true; } if (!flag) { BindImage(level.thumbnailTexture); levelName.text = level.title; } } else { flag = true; } if (flag) { BindImage(null); levelName.text = "MISSING"; NetGame.instance.currentLevel = 0uL; if (NetGame.isServer) { App.instance.ChangeLobbyLevel(0uL, WorkshopItemSource.BuiltIn); } RebindLevel(); } }); }
public void AfterUnload() { workshopLevel = null; workshopLevelIsCustom = false; state = GameState.Inactive; if (currentLevel != null) { DisableOnExit.ExitingLevel(currentLevel); defaultLight.gameObject.SetActive(value: true); currentLevel = null; StartCoroutine(UnloadBundle()); } currentLevelNumber = -1; state = GameState.Inactive; }
public override void OnLostFocus() { base.OnLostFocus(); MenuSystem menuSystem = MenuSystem.instance; menuSystem.InputDeviceChange = (Action <MenuSystem.eInputDeviceType>)Delegate.Remove(menuSystem.InputDeviceChange, new Action <MenuSystem.eInputDeviceType>(OnInputDeviceChange)); ButtonLegendBar.instance.ToogleCarouselLegend(state: false); NetGame.instance.transport.RegisterForGameOverlayActivation(null); InLevelSelectMenu = false; list.Clear(); if (boundLevel != null) { boundLevel.ReleaseThumbnailReference(); boundLevel = null; } }
public override void Bind(int index, object data) { base.Bind(index, data); level = (WorkshopLevelMetadata)data; if (level == null) { base.gameObject.SetActive(value: false); } else { base.gameObject.SetActive(value: true); if (label != null) { Type type = label.GetType(); if (labelIsUIText) { if (labelComponent != null) { ((Text)labelComponent).text = level.title; } } else if (labelComponent != null) { ((TextMeshProUGUI)labelComponent).text = level.title; } if (image != null && level != null) { image.texture = level.thumbnailTexture; } } if (newLevelStar != null) { bool active = false; if (!GameSave.HasSeenLatestLevel() && level.levelType == WorkshopItemSource.EditorPick && level.workshopId == 2) { active = true; } newLevelStar.SetActive(active); } } if (boundData != null) { boundData.ReleaseThumbnailReference(); } boundData = level; }
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; } else { selectedPath = null; BindImage(null); levelName.text = "MISSING"; } }
private void SubmitItemPlay(ListViewItem item) { if (IsLobbyMode()) { boundLevel = (item as WorkshopMenuItem).level; PlayClick(); } else if (MenuSystem.CanInvoke && !BoundIsLobbyLevel()) { WorkshopMenuItem workshopMenuItem = item as WorkshopMenuItem; if ((displayMode == LevelSelectMenuMode.Campaign || isMultiplayer) && DLC.instance.SupportsDLC() && !DLC.instance.LevelIsAvailable((int)workshopMenuItem.level.workshopId)) { FindMoreClick(); } else { Play(workshopMenuItem.level); } } }
private void Play(WorkshopLevelMetadata level) { if (isMultiplayer) { App.instance.ChangeLobbyLevel(level.workshopId, level.levelType); TransitionForward <MultiplayerLobbyMenu>(); return; } switch (displayMode) { case LevelSelectMenuMode.Campaign: Game.instance.workshopLevelIsCustom = false; if (level.levelType == WorkshopItemSource.LocalWorkshop) { App.instance.LaunchCustomLevel(level.folder, level.levelType, (checkpointToStart != -1) ? checkpointToStart : 0, 0); } else { App.instance.LaunchSinglePlayer(level.workshopId, level.levelType, (checkpointToStart != -1) ? checkpointToStart : 0, 0); } break; case LevelSelectMenuMode.EditorPicks: App.instance.LaunchSinglePlayer(level.workshopId, level.levelType, (checkpointToStart != -1) ? checkpointToStart : 0, 0); break; case LevelSelectMenuMode.SubscribedWorkshop: Game.instance.workshopLevelIsCustom = false; App.instance.LaunchCustomLevel(level.folder, level.levelType, (checkpointToStart != -1) ? checkpointToStart : 0, 0); break; case LevelSelectMenuMode.LocalWorkshop: Game.instance.workshopLevelIsCustom = true; App.instance.LaunchCustomLevel(level.folder, level.levelType, (checkpointToStart != -1) ? checkpointToStart : 0, 0); break; } }
public void UpdateDisplay(NetTransport.LobbyDisplayInfo dispInfo) { if (InviteText != null) { InviteText.gameObject.SetActive(NetGame.instance.transport.CanSendInvite()); } if (!base.gameObject.activeSelf) { return; } if (dispInfo.FeaturesMask == 0) { ClearDisplay(); base.gameObject.SetActive(value: false); return; } if ((dispInfo.FeaturesMask & 0x20) != 0 && (dispInfo.Flags & 0x20) == 0) { ClearDisplay(); base.gameObject.SetActive(value: false); return; } uint num = dispInfo.Compare(ref prevDispInfo); prevDispInfo = dispInfo; uint num2 = 3221225472u; if (((int)num & -1073741824) != 0) { if (dispInfo.ShouldDisplayAllAttr(3221225472u)) { MaxPlayersText.text = MakePlayers(dispInfo.NumPlayersForDisplay, dispInfo.MaxPlayers, 4); } else { MaxPlayersText.text = string.Empty; } } if ((num & 1) != 0) { JoinGameInProgressText.text = MakeFlag(dispInfo.Flags, dispInfo.FeaturesMask, 1u, 6); } if ((num & 4) != 0) { InviteText.text = MakeFlag(dispInfo.Flags, dispInfo.FeaturesMask, 4u, 8); } if ((num & 2) != 0) { LockLevelText.text = MakeFlag(dispInfo.Flags, dispInfo.FeaturesMask, 2u, 7); } if ((num & 8) != 0) { if ((dispInfo.FeaturesMask & 8) != 0) { LaunchedText.text = (((dispInfo.Flags & 8) == 0) ? sLocalisedStrings[3] : sLocalisedStrings[2]); } else { LaunchedText.text = string.Empty; } } if ((num & 0x8000000) != 0) { if ((dispInfo.FeaturesMask & 0x8000000) != 0) { LobbyNameText.text = MakeLobbyTitle(dispInfo.LobbyTitle); } else { LobbyNameText.text = string.Empty; } } if (LevelText == null || LevelImage == null || (num & 0x20000000) == 0) { return; } if ((dispInfo.FeaturesMask & 0x20000000) == 0) { LevelText.text = string.Empty; LevelImage.texture = null; LevelImage.enabled = false; return; } string path; switch (dispInfo.LevelType) { case WorkshopItemSource.BuiltIn: WorkshopRepository.instance.LoadBuiltinLevels(); path = "builtin:" + dispInfo.LevelID; break; case WorkshopItemSource.EditorPick: WorkshopRepository.instance.LoadEditorPickLevels(); path = "editorpick:" + dispInfo.LevelID; break; default: path = "ws:" + dispInfo.LevelID + "/"; break; } WorkshopLevelMetadata item = WorkshopRepository.instance.levelRepo.GetItem(path); if (item != null) { LevelText.text = item.title; LevelImage.texture = item.thumbnailTexture; LevelImage.enabled = (LevelImage.texture != null); } else if (dispInfo.LevelID == (ulong)(Game.instance.levels.Length - 1)) { LevelText.text = ScriptLocalization.Get("LEVEL/" + Game.instance.levels[Game.instance.levels.Length - 1]); LevelImage.texture = HFFResources.instance.FindTextureResource("LevelImages/" + Game.instance.levels[Game.instance.levels.Length - 1]); LevelImage.enabled = true; } else { LevelText.text = string.Empty; LevelImage.texture = null; LevelImage.enabled = false; StartCoroutine(GetNewLevel(dispInfo.LevelID)); } }
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; } }
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(); }
private IEnumerator EnterLobbyAsync(bool asServer, Action callback = null) { NetScope.ClearAllButPlayers(); object obj = stateLock; Monitor.Enter(obj); try { state = ((!asServer) ? AppSate.ClientLoadLobby : AppSate.ServerLoadLobby); SuspendDeltasForLoad(); Game.instance.HasSceneLoaded = false; string sceneName = null; if (Game.multiplayerLobbyLevel < 128) { sceneName = WorkshopRepository.GetLobbyFilename(Game.multiplayerLobbyLevel); goto IL_01fb; } bool loaded = false; WorkshopLevelMetadata workshopLevel = null; WorkshopRepository.instance.levelRepo.LoadLevel(Game.multiplayerLobbyLevel, delegate(WorkshopLevelMetadata l) { workshopLevel = l; loaded = true; }); while (!loaded) { yield return(null); } if (workshopLevel != null) { lobbyAssetbundle = FileTools.LoadBundle(workshopLevel.dataPath); string[] allScenePaths = lobbyAssetbundle.GetAllScenePaths(); sceneName = Path.GetFileNameWithoutExtension(allScenePaths[0]); StopPlaytimeForItem(previousLobbyID); StartPlaytimeForItem(workshopLevel.workshopId); previousLobbyID = workshopLevel.workshopId; goto IL_01fb; } if (NetGame.isServer) { goto IL_01fb; } SubtitleManager.instance.ClearProgress(); UnityEngine.Debug.Log("Level load failed."); instance.ServerFailedToLoad(); SignalManager.EndReset(); goto end_IL_0055; IL_01fb: if (string.IsNullOrEmpty(sceneName)) { sceneName = WorkshopRepository.GetLobbyFilename(0uL); Game.multiplayerLobbyLevel = 0uL; } AsyncOperation loader = SceneManager.LoadSceneAsync(sceneName); if (loader != null) { while (!loader.isDone || !Game.instance.HasSceneLoaded) { yield return(null); } } if (state != AppSate.ServerLoadLobby && state != AppSate.ClientLoadLobby) { UnityEngine.Debug.Log("Exiting wrong app state (" + state.ToString() + ")"); } state = ((!asServer) ? AppSate.ClientLobby : AppSate.ServerLobby); ResumeDeltasAfterLoad(); if (!RatingMenu.instance.ShowRatingMenu()) { MenuSystem.instance.ShowMainMenu <MultiplayerLobbyMenu>(); } Game.instance.state = GameState.Inactive; UpdateJoinable(); callback?.Invoke(); if (queueAfterLevelLoad != null) { Action action = queueAfterLevelLoad; queueAfterLevelLoad = null; if (NetGame.netlog) { UnityEngine.Debug.Log("Executing queue"); } action(); } if (lobbyAssetbundle != null) { lobbyAssetbundle.Unload(unloadAllLoadedObjects: false); lobbyAssetbundle = null; } Game.instance.FixAssetBundleImport(lobby: true); end_IL_0055 :; } finally { } }
private void ClearSelectedItem() { boundLevel = null; selectedMenuItem = null; }