Exemple #1
0
        static bool Actor_MoveVExact(On.Celeste.Actor.orig_MoveVExact orig, Actor self, int moveV, Collision onCollide, Solid pusher)
        {
            bool barrierWasCollidable = self.Scene.Tracker.GetEntity <MoveBlockBarrier>()?.Collidable ?? false;

            foreach (Entity barrier in self.Scene.Tracker.GetEntities <MoveBlockBarrier>())
            {
                barrier.Collidable = false;
            }

            bool result = orig(self, moveV, onCollide, pusher);

            foreach (Entity barrier in self.Scene.Tracker.GetEntities <MoveBlockBarrier>())
            {
                barrier.Collidable = barrierWasCollidable;
            }

            return(result);
        }
Exemple #2
0
        private static bool onActorMoveVExact(On.Celeste.Actor.orig_MoveVExact orig, Actor self, int moveV, Collision onCollide, Solid pusher)
        {
            // fall back to vanilla if no upside-down jumpthru is in the room.
            if (self.SceneAs <Level>().Tracker.CountEntities <UpsideDownJumpThru>() == 0)
            {
                return(orig(self, moveV, onCollide, pusher));
            }

            Vector2 targetPosition = self.Position + Vector2.UnitY * moveV;
            int     moveDirection  = Math.Sign(moveV);
            int     moveAmount     = 0;

            while (moveV != 0)
            {
                bool didCollide = false;

                Platform      platform = self.CollideFirst <Solid>(self.Position + Vector2.UnitY * moveDirection);
                CollisionData data;
                if (platform != null)
                {
                    // hit platform
                    didCollide = true;
                }
                else if (!self.IgnoreJumpThrus)
                {
                    if (moveV > 0)
                    {
                        platform = self.CollideFirstOutside <JumpThru>(self.Position + Vector2.UnitY * moveDirection);
                        if (platform != null && platform.GetType() != typeof(UpsideDownJumpThru))
                        {
                            // hit vanilla jumpthru while going down
                            didCollide = true;
                        }
                    }
                    else if (moveV < 0)
                    {
                        platform = self.CollideFirstOutside <UpsideDownJumpThru>(self.Position + Vector2.UnitY * moveDirection);
                        if (platform != null)
                        {
                            // hit upside-down jumpthru while going up
                            didCollide = true;
                        }
                    }
                }

                if (didCollide)
                {
                    Vector2 movementCounter = (Vector2)actorMovementCounter.GetValue(self);
                    movementCounter.Y = 0f;
                    if (onCollide != null)
                    {
                        data = new CollisionData {
                            Direction      = Vector2.UnitY * moveDirection,
                            Moved          = Vector2.UnitY * moveAmount,
                            TargetPosition = targetPosition,
                            Hit            = platform,
                            Pusher         = pusher
                        };
                        onCollide(data);
                    }
                    return(true);
                }

                // continue moving
                moveAmount += moveDirection;
                moveV      -= moveDirection;
                self.Y     += moveDirection;
            }
            return(false);
        }