private static Celeste.PlayerDeadBody PlayerDie(On.Celeste.Player.orig_Die orig, Celeste.Player self, Vector2 direction, bool evenIfInvincible, bool registerDeathInStats) { Celeste.Session session = (self.Scene as Celeste.Level).Session; Celeste.PlayerDeadBody playerDeadBody = orig(self, direction, evenIfInvincible, registerDeathInStats); if (playerDeadBody != null) { Celeste.Strawberry goldenStrawb = null; foreach (Celeste.Follower follower in self.Leader.Followers) { if (follower.Entity is Celeste.Strawberry && (follower.Entity as Celeste.Strawberry).Golden && !(follower.Entity as Celeste.Strawberry).Winged) { goldenStrawb = (follower.Entity as Celeste.Strawberry); } } Vector2?specialBoxLevel = (FactoryHelperModule.Instance._Session as FactoryHelperSession).SpecialBoxPosition; if (goldenStrawb == null && specialBoxLevel != null) { playerDeadBody.DeathAction = delegate { Engine.Scene = new Celeste.LevelExit(Celeste.LevelExit.Mode.Restart, session); }; } } return(playerDeadBody); }
private static Celeste.PlayerDeadBody OnDeath(On.Celeste.Player.orig_Die orig, Celeste.Player self, Vector2 direction, bool evenIfInvincible, bool registerDeathInStats) { Celeste.PlayerDeadBody result = orig(self, direction, evenIfInvincible, registerDeathInStats); if (result != null) { string level = self.SceneAs <Celeste.Level>().Session.Level; if (TrollLandModule.Session.DeathCountPerLevel.ContainsKey(level)) { TrollLandModule.Session.DeathCountPerLevel[level] += 1; } else { TrollLandModule.Session.DeathCountPerLevel[level] = 1; } } return(result); }