private void modEnforceBounds(On.Celeste.Level.orig_EnforceBounds orig, Level self, Player player) { if (isTheoCrystalsEverywhere() && !isAllowLeavingTheoBehind() && // the player is holding nothing... (player.Holding == null || player.Holding.Entity == null || !player.Holding.IsHeld || // or this thing is not a Theo crystal (f.e. jellyfish) (player.Holding.Entity.GetType() != typeof(TheoCrystal) && player.Holding.Entity.GetType() != typeof(ExtendedVariantTheoCrystal) && player.Holding.Entity.GetType() != typeof(ExtendedVariantTheoCrystalGoingOffscreen))) && // but there is a Theo crystal on screen so the player has to grab it self.Tracker.CountEntities<ExtendedVariantTheoCrystal>() != 0) { // the player does not hold Theo, check if they try to leave the screen without him Rectangle bounds = self.Bounds; if (player.Left < bounds.Left) { // prevent the player from going left player.Left = bounds.Left; player.OnBoundsH(); } else if (player.Right > bounds.Right) { // prevent the player from going right player.Right = bounds.Right; player.OnBoundsH(); } else if (player.Top < bounds.Top) { // prevent the player from going up player.Top = bounds.Top; player.OnBoundsV(); } else if (player.Bottom > bounds.Bottom) { if (SaveData.Instance.Assists.Invincible) { // bounce the player off the bottom of the screen (= falling into a pit with invincibility on) player.Play("event:/game/general/assist_screenbottom"); player.Bounce(bounds.Bottom); } else { // kill the player if they try to go down player.Die(Vector2.Zero); } } else { // no screen transition detected => proceed to vanilla orig(self, player); } } else { // the variant is disabled, we are allowed to leave Theo behind, or the player is holding Theo => we have no business here. orig(self, player); } }