Exemplo n.º 1
0
        private Session onSessionRestart(On.Celeste.Session.orig_Restart orig, Session self, string intoLevel)
        {
            Session session = orig(self, intoLevel);

            if (Settings.AllStrawberriesAreGoldens && Engine.Scene is LevelExit levelExit)
            {
                DynData <LevelExit> exitData = new DynData <LevelExit>(levelExit);
                if (exitData.Get <LevelExit.Mode>("mode") == LevelExit.Mode.GoldenBerryRestart && exitData.Data.ContainsKey("playerInventoryToRestore"))
                {
                    session.Inventory = exitData.Get <PlayerInventory>("playerInventoryToRestore");
                }
            }

            return(session);
        }
        private static Session onSessionRestart(On.Celeste.Session.orig_Restart orig, Session self, string intoLevel)
        {
            Session restartSession = orig(self, intoLevel);

            if (intoLevel != null && Engine.Scene is LevelExit exit && new DynData <LevelExit>(exit).Get <LevelExit.Mode>("mode") == LevelExit.Mode.GoldenBerryRestart)
            {
                // we are doing a golden berry restart! look for a golden berry player respawn point.
                LevelData  levelData     = restartSession.MapData.Levels.Find(level => level.Name == intoLevel);
                EntityData goldenRespawn = levelData.Entities.FirstOrDefault(entityData => entityData.Name == "CollabUtils2/GoldenBerryPlayerRespawnPoint");
                if (goldenRespawn != null)
                {
                    restartSession.RespawnPoint         = goldenRespawn.Position + levelData.Position;
                    restartSession.StartedFromBeginning = false;
                }
            }

            return(restartSession);
        }