public static void OnSessionCreated()
        {
            // transfer the lobby info into the session that was just created.
            CollabModule.Instance.Session.LobbySID                    = temporaryLobbySIDHolder;
            CollabModule.Instance.Session.LobbyRoom                   = temporaryRoomHolder;
            CollabModule.Instance.Session.LobbySpawnPointX            = temporarySpawnPointHolder.X;
            CollabModule.Instance.Session.LobbySpawnPointY            = temporarySpawnPointHolder.Y;
            CollabModule.Instance.Session.SaveAndReturnToLobbyAllowed = temporarySaveAllowedHolder;
            temporaryLobbySIDHolder    = null;
            temporaryRoomHolder        = null;
            temporarySpawnPointHolder  = Vector2.Zero;
            temporarySaveAllowedHolder = false;

            if (CollabModule.Instance.Session.LobbySID == null)
            {
                Session session  = SaveData.Instance.CurrentSession_Safe;
                string  lobbySID = LobbyHelper.GetLobbyForLevelSet(session.Area.GetLevelSet());
                if (lobbySID == null)
                {
                    lobbySID = LobbyHelper.GetLobbyForGym(session.Area.GetSID());
                }
                if (lobbySID != null)
                {
                    Logger.Log(LogLevel.Warn, "CollabUtils2/ReturnToLobbyHelper", $"We are in {session.Area.GetSID()} without a Return to Lobby button! Setting it to {lobbySID}.");
                    CollabModule.Instance.Session.LobbySID = lobbySID;
                }
            }
        }
Esempio n. 2
0
        private static bool shouldDisplaySpeedBerryColumn()
        {
            if (CollabModule.Instance.Settings.BestTimeToDisplayInJournal == CollabSettings.BestTimeInJournal.SpeedBerry)
            {
                foreach (AreaStats item in SaveData.Instance.Areas_Safe)
                {
                    // start going through all maps belonging to the collab level set, or to a lobby level set belonging to this collab.
                    bool belongsToCollab = false;

                    if (item.LevelSet == SaveData.Instance.LevelSet)
                    {
                        belongsToCollab = true;
                    }
                    else
                    {
                        string lobby = LobbyHelper.GetLobbyForLevelSet(item.LevelSet);
                        if (lobby != null && AreaData.Get(lobby).GetLevelSet() == SaveData.Instance.LevelSet)
                        {
                            belongsToCollab = true;
                        }
                    }

                    if (belongsToCollab && CollabMapDataProcessor.SpeedBerries.ContainsKey(item.GetSID()))
                    {
                        // this level has a speed berry!
                        return(true);
                    }
                }
            }

            // either we disabled speed berries in the journal, or just went through all maps without finding any...
            return(false);
        }
Esempio n. 3
0
        private IEnumerator Routine()
        {
            if (targetSID != null && AreaData.Get(targetSID) == null)
            {
                // we are returning to a map that does not exist!
                Logger.Log(LogLevel.Warn, "CollabUtils2/LevelExitToLobby", $"We are trying to return to a nonexistent lobby: {targetSID}!");
                targetSID  = null;
                targetRoom = null;

                // try detecting the lobby. if we don't succeed, targetSID will stay null and we will return to map.
                string lobbySID = LobbyHelper.GetLobbyForLevelSet(SaveData.Instance.CurrentSession_Safe.Area.GetLevelSet());
                if (lobbySID == null)
                {
                    lobbySID = LobbyHelper.GetLobbyForGym(SaveData.Instance.CurrentSession_Safe.Area.GetSID());
                }
                if (lobbySID != null)
                {
                    Logger.Log(LogLevel.Warn, "CollabUtils2/LevelExitToLobby", $"We will be returning to the detected lobby for the current map instead: {lobbySID}.");
                    targetSID = lobbySID;
                }
            }

            Session oldSession = SaveData.Instance.CurrentSession_Safe;
            Session newSession = null;

            if (targetSID != null)
            {
                newSession                      = new Session(AreaData.Get(targetSID).ToKey());
                newSession.FirstLevel           = false;
                newSession.StartedFromBeginning = false;
                newSession.Level                = targetRoom ?? newSession.MapData.StartLevel().Name;
                newSession.RespawnPoint         = targetRoom == null ? (Vector2?)null : targetSpawnPoint;
                SaveData.Instance.StartSession(newSession);
            }

            UserIO.SaveHandler(file: true, settings: true);
            while (UserIO.Saving)
            {
                yield return(null);
            }
            while (SaveLoadIcon.OnScreen)
            {
                yield return(null);
            }

            SaveData.Instance.CurrentSession_Safe = oldSession;

            if (targetSID == null)
            {
                // failsafe: if there is no lobby to return to, return to map instead.
                Engine.Scene = new OverworldLoader(
                    exitMode == LevelExit.Mode.Completed ? Overworld.StartMode.AreaComplete : Overworld.StartMode.AreaQuit);
            }
            else
            {
                new DynData <Session>(newSession)["pauseTimerUntilAction"] = true;
                LevelEnter.Go(newSession, false);
            }
        }