private static void LoadLevel(On.Celeste.Level.orig_LoadLevel orig, Celeste.Level self, Celeste.Player.IntroTypes playerIntro, bool isFromLoader)
        {
            orig(self, playerIntro, isFromLoader);
            if (playerIntro != Celeste.Player.IntroTypes.Transition || isFromLoader)
            {
                Celeste.Player player = self.Tracker.GetEntity <Celeste.Player>();

                foreach (Celeste.EntityID key in (FactoryHelperModule.Instance._Session as FactoryHelperSession).Batteries)
                {
                    self.Add(new Battery(player, key));
                }
            }
        }
        bool Level_OnLoadEntity(Celeste.Level l, Celeste.LevelData levelData, Vector2 offset, Celeste.EntityData entityData)
        {
            if (entityData.Name.StartsWith("madelineparty/", StringComparison.InvariantCulture))
            {
                switch (entityData.Name.Substring("madelineparty/".Length))
                {
                case "leftbutton":
                    l.Add(new LeftButton(entityData, offset));
                    return(true);

                case "rightbutton":
                    l.Add(new RightButton(entityData, offset));
                    return(true);

                case "boardcontroller":
                    l.Add(new BoardController(entityData));
                    return(true);

                case "playernumberselect":
                    l.Add(new PlayerNumberSelect(entityData, offset));
                    return(true);

                case "playerselecttrigger":
                    l.Add(new PlayerSelectTrigger(entityData, offset));
                    return(true);

                case "gamescoreboard":
                    l.Add(new GameScoreboard(entityData, offset));
                    return(true);

                case "minigamefinishtrigger":
                    l.Add(new MinigameFinishTrigger(entityData, offset));
                    return(true);

                case "playerrankingcontroller":
                    l.Add(new PlayerRankingController());
                    return(true);

                case "gameendcontroller":
                    l.Add(new GameEndController());
                    return(true);

                case "theominigamecontroller":
                    l.Add(new MinigameTheoMover(entityData, offset));
                    return(true);
                }
            }
            return(false);
        }
        private void OnLevelLoadLevel(On.Celeste.Level.orig_LoadLevel orig, Celeste.Level self, Celeste.Player.IntroTypes playerIntro, bool isFromLoader)
        {
            orig(self, playerIntro, isFromLoader);

            Session.SpawnedOshiros.Clear();
            Session.SpawnedBadelineChasers.Clear();

            if (Settings.Enabled)
            {
                Celeste.Player player = self.Tracker.GetEntity <Celeste.Player>();

                if (!isFromLoader)
                {
                    ApplyRules(self, "ScreenChange");

                    if (self.NewLevel)
                    {
                        ApplyRules(self, "NewRoom");
                    }
                }

                if (player != null)
                {
                    int chaserCount = self.Tracker.CountEntities <BadelineOldsite>() + self.Tracker.CountEntities <EveryTimeCustomChaser>();
                    int added       = 0;
                    while (added < Session.ChaserCount)
                    {
                        if (chaserCount >= 7)
                        {
                            break;
                        }
                        EveryTimeCustomChaser chaser = new EveryTimeCustomChaser(player.Position + Vector2.UnitY * 32, chaserCount++);
                        self.Add(chaser);
                        Session.SpawnedBadelineChasers.Add(chaser);
                        added++;
                    }

                    player.Add(new Coroutine(OshiroSpawnRoutine(player, Session.OshiroCount)));
                }
            }
        }
 private Celeste.ScreenWipe OnLevelCompleteArea(On.Celeste.Level.orig_CompleteArea_bool_bool_bool orig, Celeste.Level self, bool spotlightWipe, bool skipScreenWipe, bool skipCompleteScreen)
 {
     Celeste.ScreenWipe wipe = orig(self, spotlightWipe, skipScreenWipe, skipCompleteScreen);
     Session.Reset();
     return(wipe);
 }