示例#1
0
        [PatchLevelLoader] // Manually manipulate the method via MonoModRules
        public new void LoadLevel(Player.IntroTypes playerIntro, bool isFromLoader = false)
        {
            // Read player introType from metadata as player enter the C-Side
            if (Session.FirstLevel && Session.StartedFromBeginning && Session.JustStarted &&
                Session.Area.Mode == AreaMode.CSide &&
                AreaData.GetMode(Session.Area)?.GetMapMeta() is MapMeta mapMeta && (mapMeta.OverrideASideMeta ?? false) &&
                mapMeta.IntroType is Player.IntroTypes introType)
            {
                playerIntro = introType;
            }

            try {
                orig_LoadLevel(playerIntro, isFromLoader);
            } catch (Exception e) {
                Mod.Logger.Log(LogLevel.Warn, "misc", $"Failed loading level {Session.Area}");
                e.LogDetailed();

                string message = Dialog.Get("postcard_levelloadfailed");
                if (e is ArgumentOutOfRangeException && e.StackTrace.Contains("get_DefaultSpawnPoint"))
                {
                    message = Dialog.Get("postcard_levelnospawn");
                }
                message = message
                          .Replace("((player))", SaveData.Instance.Name)
                          .Replace("((sid))", Session.Area.GetSID());

                Entity helperEntity = new Entity();
                helperEntity.Add(new Coroutine(ErrorRoutine(message)));
                Add(helperEntity);
                return;
            }
            Everest.Events.Level.LoadLevel(this, playerIntro, isFromLoader);
        }
示例#2
0
        private void ReloadMenu()
        {
            menu = new TextMenu {
                new TextMenu.Header(Dialog.Clean("MODOPTIONS_RANDOMIZER_MAPPICKER_HEADER")),
                new TextMenu.Button(Dialog.Clean("MODOPTIONS_RANDOMIZER_MAPPICKER_TOGGLEALL")).Pressed(() => {
                    var items = menu.GetItems();
                    if (!(items[2] is TextMenu.OnOff firstToggle))
                    {
                        // ???
                        return;
                    }

                    var newValue = 1 - firstToggle.Index;
                    for (int i = 0; i < items.Count; i++)
                    {
                        if (items[i] is TextMenu.OnOff toggle)
                        {
                            toggle.Index = newValue;
                            toggle.OnValueChange(toggle.Values[newValue].Item2);
                        }
                    }
                }),
            };

            foreach (var key in RandoLogic.AvailableAreas)
            {
                var area = AreaData.Get(key);
                var mode = AreaData.GetMode(key);

                var on   = Settings.MapIncluded(key);
                var name = area.Name;
                name = name.DialogCleanOrNull() ?? name.SpacedPascalCase();
                if (key.Mode != AreaMode.Normal || (area.Mode.Length != 1 && area.Mode[1] != null))
                {
                    name += " " + Char.ToString((char)('A' + (int)key.Mode));
                }

                menu.Add(new TextMenu.OnOff(name, on).Change(this.MakeChangeFunc(key)));
                menu.Add(new TextMenuExt.SubHeaderExt(mode.MapData.LevelCount.ToString() + " " + Dialog.Clean("MODOPTIONS_RANDOMIZER_MAPPICKER_LEVELS"))
                {
                    HeightExtra = -10f,
                    Offset      = new Vector2(30, -5),
                });
            }

            Scene.Add(menu);
        }
示例#3
0
        private void ReloadMenu()
        {
            menu = new TextMenu {
                new TextMenu.Header(Dialog.Clean("MODOPTIONS_RANDOMIZER_MAPPICKER_HEADER")),
                new TextMenu.Button(Dialog.Clean("MODOPTIONS_RANDOMIZER_MAPPICKER_TOGGLEALL")).Pressed(() => {
                    var items = menu.GetItems();
                    TextMenu.OnOff firstToggle = null;
                    foreach (var item in items)
                    {
                        if (item is TextMenu.OnOff)
                        {
                            firstToggle = item as TextMenu.OnOff;
                            break;
                        }
                    }
                    if (firstToggle == null)
                    {
                        // ???
                        return;
                    }

                    var newValue = 1 - firstToggle.Index;
                    for (int i = 0; i < items.Count; i++)
                    {
                        if (items[i] is TextMenu.OnOff toggle)
                        {
                            toggle.Index = newValue;
                            toggle.OnValueChange(toggle.Values[newValue].Item2);
                        }
                    }
                }),
            };

            var lvlCount = new Dictionary <RandoSettings.AreaKeyNotStupid, int>();

            foreach (var room in RandoLogic.AllRooms)
            {
                var notstupid = new RandoSettings.AreaKeyNotStupid(room.Area);
                if (lvlCount.TryGetValue(notstupid, out int c))
                {
                    lvlCount[notstupid] = c + 1;
                }
                else
                {
                    lvlCount[notstupid] = 1;
                }
            }
            string currentSet = null;

            foreach (var key in RandoLogic.AvailableAreas)
            {
                var area = AreaData.Get(key);
                var mode = AreaData.GetMode(key);

                if (currentSet != area.GetLevelSet())
                {
                    currentSet = area.GetLevelSet();
                    menu.Add(new TextMenu.SubHeader(DialogExt.CleanLevelSet(currentSet)));
                }

                var on   = Settings.MapIncluded(key);
                var name = area.Name;
                name = name.DialogCleanOrNull() ?? name.SpacedPascalCase();
                if (key.Mode != AreaMode.Normal || (area.Mode.Length != 1 && area.Mode[1] != null))
                {
                    name += " " + Char.ToString((char)('A' + (int)key.Mode));
                }

                menu.Add(new TextMenu.OnOff(name, on).Change(this.MakeChangeFunc(key)));
                menu.Add(new TextMenuExt.SubHeaderExt(lvlCount[new RandoSettings.AreaKeyNotStupid(key)].ToString() + " " + Dialog.Clean("MODOPTIONS_RANDOMIZER_MAPPICKER_LEVELS"))
                {
                    HeightExtra = -10f,
                    Offset      = new Vector2(30, -5),
                });
            }

            if (currentSet != "Celeste")
            {
                menu.Insert(2, new TextMenu.Button(Dialog.Clean("MODOPTIONS_RANDOMIZER_MAPPICKER_RESET")).Pressed(() => {
                    Settings.SetNormalMaps();
                    // this is a stupid way to do this
                    int levelsetIdx = -1;
                    foreach (var item in menu.GetItems())
                    {
                        if (item is TextMenu.SubHeader && !(item is TextMenuExt.SubHeaderExt))
                        {
                            levelsetIdx++;
                        }
                        else if (item is TextMenu.OnOff toggle)
                        {
                            toggle.Index = levelsetIdx == 0 ? 1 : 0;
                        }
                    }
                }));
            }

            Scene.Add(menu);
        }