public override void Update()
 {
     base.Update();
     if (MasterOfGroup)
     {
         bool blockHasPlayerOnIt = false;
         foreach (FloatySpaceBlockWithAttachedSidewaysJumpthruSupport block in group)
         {
             if (block.HasPlayerRider())
             {
                 blockHasPlayerOnIt = true;
                 break;
             }
         }
         if (!blockHasPlayerOnIt)
         {
             foreach (JumpThru jumpthru in jumpthrus)
             {
                 if (jumpthru.HasPlayerRider())
                 {
                     blockHasPlayerOnIt = true;
                     break;
                 }
             }
         }
         if (!blockHasPlayerOnIt)
         {
             foreach (AttachedSidewaysJumpThru jumpthru in attachedSidewaysJumpthrus)
             {
                 if (SidewaysMovingPlatform.GetPlayerClimbing(jumpthru, jumpthru.Left) != null)
                 {
                     blockHasPlayerOnIt = true;
                     break;
                 }
             }
         }
         if (blockHasPlayerOnIt)
         {
             sinkTimer = 0.3f;
         }
         else if (sinkTimer > 0f)
         {
             sinkTimer -= Engine.DeltaTime;
         }
         if (sinkTimer > 0f)
         {
             yLerp = Calc.Approach(yLerp, 1f, 1f * Engine.DeltaTime);
         }
         else
         {
             yLerp = Calc.Approach(yLerp, 0f, 1f * Engine.DeltaTime);
         }
         sineWave += Engine.DeltaTime;
         dashEase  = Calc.Approach(dashEase, 0f, Engine.DeltaTime * 1.5f);
         moveToTarget();
     }
     LiftSpeed = Vector2.Zero;
 }
        public override void Added(Scene scene)
        {
            base.Added(scene);


            // add the hidden solid to the scene as well.
            scene.Add(playerInteractingSolid);

            // load the texture.
            MTexture fullTexture = GFX.Game["objects/woodPlatform/" + texture];

            textures = new MTexture[fullTexture.Width / 8];
            for (int i = 0; i < textures.Length; i++)
            {
                textures[i] = fullTexture.GetSubtexture(i * 8, 0, 8, 8);
            }

            if (spawnedByOtherPlatform)
            {
                // this platform was spawned by another platform that spawned the moving platform. so don't manage the static mover!
                return;
            }

            // add a multi-node moving platform, pass the platform settings to it, and attach the bumper to it.
            StaticMover staticMover = new StaticMover()
            {
                OnMove = move => SidewaysJumpthruOnMove(this, playerInteractingSolid, left, move)
            };

            Add(staticMover);
            animatingPlatform = new MultiNodeMovingPlatform(thisEntityData, thisOffset, otherPlatform => {
                if (otherPlatform != animatingPlatform)
                {
                    // another multi-node moving platform was spawned (because of the "count" setting), spawn another platform...
                    SidewaysMovingPlatform otherSidewaysPlatform = new SidewaysMovingPlatform(thisEntityData, thisOffset);
                    otherSidewaysPlatform.spawnedByOtherPlatform = true;
                    Scene.Add(otherSidewaysPlatform);

                    // ... and attach it to that new platform.
                    StaticMover otherStaticMover = new StaticMover()
                    {
                        OnMove = move => SidewaysJumpthruOnMove(otherSidewaysPlatform, otherSidewaysPlatform.playerInteractingSolid, otherSidewaysPlatform.left, move)
                    };
                    otherSidewaysPlatform.Add(otherStaticMover);
                    otherPlatform.AnimateObject(otherStaticMover, forcedTrackOffset: new Vector2(Width + 4f, Height) / 2f);
                }
            });
            animatingPlatform.AnimateObject(staticMover, forcedTrackOffset: new Vector2(Width + 4f, Height) / 2f);
            scene.Add(animatingPlatform);
        }
        public AttachedSidewaysJumpThru(EntityData data, Vector2 offset) : base(data, offset)
        {
            Left = data.Bool("left");

            // this solid will be made solid only when moving the player with the platform, so that the player gets squished and can climb the platform properly.
            playerInteractingSolid            = new Solid(Position, Width, Height, safe: false);
            playerInteractingSolid.Collidable = false;
            playerInteractingSolid.Visible    = false;
            if (!Left)
            {
                playerInteractingSolid.Position.X += 3f;
            }

            // create the StaticMover that will make this jumpthru attached.
            StaticMover staticMover = new StaticMover()
            {
                SolidChecker = solid => solid.CollideRect(new Rectangle((int)X, (int)Y - 1, (int)Width, (int)Height + 2)),
                OnMove       = move => SidewaysMovingPlatform.SidewaysJumpthruOnMove(this, playerInteractingSolid, Left, move),
                OnShake      = shake => SidewaysMovingPlatform.SidewaysJumpthruOnMove(this, playerInteractingSolid, Left, shake)
            };

            Add(staticMover);
        }