Exemplo n.º 1
0
        public static void OpenChapterPanel(Player player, string sid, ChapterPanelTrigger.ReturnToLobbyMode returnToLobbyMode, bool savingAllowed)
        {
            AreaData areaData = (AreaData.Get(sid) ?? AreaData.Get(0));

            if (!Dialog.Has(areaData.Name + "_collabcredits") && areaData.Mode[0].Checkpoints?.Length > 0)
            {
                // saving isn't compatible with checkpoints, because both would appear on the same page.
                savingAllowed = false;
            }

            player.Drop();
            Open(player, AreaData.Get(sid) ?? AreaData.Get(0), out OuiHelper_EnterChapterPanel.Start,
                 overworld => {
                new DynData <Overworld>(overworld).Set("returnToLobbyMode", returnToLobbyMode);
                new DynData <Overworld>(overworld).Set("saveAndReturnToLobbyAllowed", savingAllowed);
            });
        }
        private static IEnumerator modChapterPanelStartRoutine(On.Celeste.OuiChapterPanel.orig_StartRoutine orig, OuiChapterPanel self, string checkpoint)
        {
            // wait for the "chapter start" animation to finish.
            IEnumerator origRoutine = orig(self, checkpoint);

            while (origRoutine.MoveNext())
            {
                yield return(origRoutine.Current);
            }

            DynData <Overworld> data      = new DynData <Overworld>(self.Overworld);
            AreaData            forceArea = self.Overworld == null ? null : data.Get <AreaData>("collabInGameForcedArea");

            if (forceArea != null)
            {
                // current chapter panel is in-game: set up Return to Lobby.
                ChapterPanelTrigger.ReturnToLobbyMode returnToLobbyMode = data.Get <ChapterPanelTrigger.ReturnToLobbyMode>("returnToLobbyMode");

                temporarySaveAllowedHolder = data.Get <bool>("saveAndReturnToLobbyAllowed");

                if (returnToLobbyMode == ChapterPanelTrigger.ReturnToLobbyMode.DoNotChangeReturn)
                {
                    // carry over current values.
                    temporaryLobbySIDHolder   = CollabModule.Instance.Session.LobbySID;
                    temporaryRoomHolder       = CollabModule.Instance.Session.LobbyRoom;
                    temporarySpawnPointHolder = new Vector2(CollabModule.Instance.Session.LobbySpawnPointX, CollabModule.Instance.Session.LobbySpawnPointY);
                }
                else if (returnToLobbyMode == ChapterPanelTrigger.ReturnToLobbyMode.SetReturnToHere)
                {
                    // set the values to the current map, the current room, and the nearest spawn point.
                    temporaryLobbySIDHolder = (Engine.Scene as Level)?.Session?.MapData?.Area.GetSID();
                    temporaryRoomHolder     = (Engine.Scene as Level)?.Session?.LevelData?.Name;

                    // and save the spawn point closest to the player.
                    Player player = Engine.Scene.Tracker.GetEntity <Player>();
                    if (player != null)
                    {
                        temporarySpawnPointHolder = (Engine.Scene as Level).GetSpawnPoint(player.Position);
                    }
                    else
                    {
                        // player is dead, presumably? AAAAA
                        // let's use camera position instead.
                        temporarySpawnPointHolder = (Engine.Scene as Level).GetSpawnPoint((Engine.Scene as Level).Camera.Position + new Vector2(320 / 2, 180 / 2));
                    }
                }
                else if (returnToLobbyMode == ChapterPanelTrigger.ReturnToLobbyMode.RemoveReturn)
                {
                    // make sure the "temporary" variables are empty.
                    temporaryLobbySIDHolder   = null;
                    temporaryRoomHolder       = null;
                    temporarySpawnPointHolder = Vector2.Zero;
                }
            }
            else
            {
                // current chapter panel isn't in-game: make sure the "temporary" variables are empty.
                temporaryLobbySIDHolder   = null;
                temporaryRoomHolder       = null;
                temporarySpawnPointHolder = Vector2.Zero;
            }
        }