public static bool EntityCollideCheckWithSidewaysJumpthrus(Entity self, Vector2 checkAtPosition, bool isClimb, bool isWallJump) { // our entity collides if this is with a jumpthru and we are colliding with the solid side of it. // we are in this case if the jumpthru is left to right (the "solid" side of it is the right one) // and we are checking the collision on the left side of the player for example. bool collideOnLeftSideOfPlayer = (self.Position.X > checkAtPosition.X); SidewaysJumpThru jumpthru = self.CollideFirstOutside <SidewaysJumpThru>(checkAtPosition); return(jumpthru != null && self is Player && (jumpthru.AllowLeftToRight == collideOnLeftSideOfPlayer && (!isWallJump || jumpthru.allowWallJumping) && (!isClimb || jumpthru.allowClimbing)) && jumpthru.Bottom >= self.Top + checkAtPosition.Y - self.Position.Y + 3); }
private static int onPlayerNormalUpdate(On.Celeste.Player.orig_NormalUpdate orig, Player self) { int result = orig(self); // kill speed if player is going towards a jumpthru. if (self.Speed.X != 0) { bool movingLeftToRight = self.Speed.X > 0; SidewaysJumpThru jumpThru = self.CollideFirstOutside <SidewaysJumpThru>(self.Position + Vector2.UnitX * Math.Sign(self.Speed.X)); if (jumpThru != null && jumpThru.AllowLeftToRight != movingLeftToRight) { self.Speed.X = 0; } } return(result); }
public static bool CheckCollisionWithSidewaysJumpthruWhileMoving(Actor self, int moveDirection, bool movingLeftToRight) { // check if colliding with a sideways jumpthru SidewaysJumpThru jumpThru = self.CollideFirstOutside <SidewaysJumpThru>(self.Position + Vector2.UnitX * moveDirection); if (jumpThru != null && jumpThru.AllowLeftToRight != movingLeftToRight && (!(self is Seeker) || !jumpThru.letSeekersThrough)) { // there is a sideways jump-thru and we are moving in the opposite direction => collision if (self is Player player && player.DashAttacking && jumpThru is AttachedSidewaysJumpThru attachedSidewaysJumpThru) { // attached sideways jumpthrus potentially have a callback to call when the player is dashing into them. attachedSidewaysJumpThru.OnDashCollide?.Invoke(player, Vector2.UnitX * moveDirection); } return(true); } return(false); }
private static Platform modSurfaceIndexGetPlatformByPriority(On.Celeste.SurfaceIndex.orig_GetPlatformByPriority orig, List <Entity> platforms) { // if vanilla already has platforms to get the sound index from, use those. if (platforms.Count != 0) { return(orig(platforms)); } // check if we are climbing a sideways jumpthru. Player player = Engine.Scene.Tracker.GetEntity <Player>(); if (player != null) { SidewaysJumpThru jumpThru = player.CollideFirst <SidewaysJumpThru>(player.Center + Vector2.UnitX * (float)player.Facing); if (jumpThru != null && jumpThru.surfaceIndex != -1) { // yes we are! pass it off as a Platform so that the game can get its surface index later. return(new WallSoundIndexHolder(jumpThru.surfaceIndex)); } } return(orig(platforms)); }
private static bool onPlatformMoveHExactCollideSolids(On.Celeste.Platform.orig_MoveHExactCollideSolids orig, Platform self, int moveH, bool thruDashBlocks, Action <Vector2, Vector2, Platform> onCollide) { // fall back to vanilla if no sideways jumpthru is in the room. if (self.Scene == null || self.Scene.Tracker.CountEntities <SidewaysJumpThru>() == 0) { return(orig(self, moveH, thruDashBlocks, onCollide)); } float x = self.X; int moveDirection = Math.Sign(moveH); int moveAmount = 0; Solid solid = null; bool movingLeftToRight = moveH > 0; bool collidedWithJumpthru = false; while (moveH != 0) { if (thruDashBlocks) { // check if we have dash blocks to break on our way. foreach (DashBlock entity in self.Scene.Tracker.GetEntities <DashBlock>()) { if (self.CollideCheck(entity, self.Position + Vector2.UnitX * moveDirection)) { entity.Break(self.Center, Vector2.UnitX * moveDirection, true, true); self.SceneAs <Level>().Shake(0.2f); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); } } } // check for collision with a solid solid = self.CollideFirst <Solid>(self.Position + Vector2.UnitX * moveDirection); // check for collision with a sideways jumpthru SidewaysJumpThru jumpThru = self.CollideFirstOutside <SidewaysJumpThru>(self.Position + Vector2.UnitX * moveDirection); if (jumpThru != null && jumpThru.AllowLeftToRight != movingLeftToRight) { // there is a sideways jump-thru and we are moving in the opposite direction => collision collidedWithJumpthru = true; } if (solid != null || collidedWithJumpthru) { break; } // continue moving moveAmount += moveDirection; moveH -= moveDirection; self.X += moveDirection; } // actually move and call the collision callback if any self.X = x; self.MoveHExact(moveAmount); if (solid != null && onCollide != null) { onCollide(Vector2.UnitX * moveDirection, Vector2.UnitX * moveAmount, solid); } return(solid != null || collidedWithJumpthru); }