public void Execute(Entity entity, int index,
                                DynamicBuffer <VelocityCurveBuffer> velocityCurveBuffer,
                                ref VelocityCurve velocityCurve, ref MovingPlatformController movingPlatformController, ref Translation translation)
            {
                //The platform never moves on the Z axis
                velocityCurve.Z = VelocityCurveAxis.Zero();

                //Check if we've reached our current destination
                float3 destination           = movingPlatformController.IsMovingTowardsA ? movingPlatformController.PositionA : movingPlatformController.PositionB;
                float  distanceToDestination = math.abs(math.distance(translation.Value, destination));

                if (distanceToDestination == 0.0f)
                {
                    //Reverse the destination
                    movingPlatformController.IsMovingTowardsA = !movingPlatformController.IsMovingTowardsA;

                    destination           = movingPlatformController.IsMovingTowardsA ? movingPlatformController.PositionA : movingPlatformController.PositionB;
                    distanceToDestination = math.abs(math.distance(translation.Value, destination));
                }



                //Move towards the destination, being carefull not to move past it
                float distanceToMoveThisTimeStep        = DeltaTime * movingPlatformController.AbsoluteVelocity;
                float distanceToMoveThisTimeStepSquared = distanceToMoveThisTimeStep * distanceToMoveThisTimeStep;

                float3 distanceAvailableToMove        = destination - translation.Value;
                float  distanceAvailableToMoveSquared = math.lengthsq(distanceAvailableToMove);

                float3 directionToMove = math.normalize(distanceAvailableToMove);

                float3 linearVelocity = new float3();

                if (distanceAvailableToMoveSquared < distanceToMoveThisTimeStepSquared)
                {
                    linearVelocity = distanceAvailableToMove / DeltaTime;
                }
                else
                {
                    linearVelocity = directionToMove * movingPlatformController.AbsoluteVelocity;
                }


                //Set the velocity curve
                velocityCurve.X = VelocityCurveAxis.Linear(linearVelocity.x > 0.0f,
                                                           math.abs(linearVelocity.x));

                velocityCurve.Y = VelocityCurveAxis.Linear(linearVelocity.y > 0.0f,
                                                           math.abs(linearVelocity.y));


                //Add this velocity curve to the moving platform's velocity curve buffer
                velocityCurveBuffer.Add(new VelocityCurveBuffer
                {
                    VelocityCurveEntity = entity
                });
            }
            private void ComputeVerticalMovement(ref VelocityCurve velocityCurve,
                                                 ref SideScrollingCharacterController sideScrollingCharacterController,
                                                 [ReadOnly] ref SolidAgent solidAgent)
            {
                //Check if we're grounded
                if (solidAgent.IsGroundCollided)
                {
                    //We're grounded.
                    //Reset jumping and falling flags
                    sideScrollingCharacterController.IsJumping  = false;
                    sideScrollingCharacterController.IsFalling  = false;
                    sideScrollingCharacterController.IsJumpHeld = false;

                    //Check if we want to jump
                    if (IsJumpPressedThisFrame)
                    {
                        sideScrollingCharacterController.IsJumping  = true;
                        sideScrollingCharacterController.IsJumpHeld = true;

                        velocityCurve.Y = VelocityCurveAxis.Quadratic(sideScrollingCharacterController.JumpAbsoluteVelocity,
                                                                      false,
                                                                      sideScrollingCharacterController.JumpAbsoluteDeceleration,
                                                                      sideScrollingCharacterController.TerminalVelocity);
                    }
                    else
                    {
                        //While grounded, continue to push down on the ground an amount
                        //equal to a single step off acceleration
                        velocityCurve.Y = VelocityCurveAxis.Linear(false,
                                                                   sideScrollingCharacterController.FallingAbsoluteAcceleration * DeltaTime);
                    }
                }
                else
                {
                    //Check for hitting your head on the ceiling
                    if ((velocityCurve.Y.CurrentVelocity > 0.0f) &&
                        (solidAgent.IsCeilingCollided))
                    {
                        //Cancel the jump and reduce velocity to zero
                        velocityCurve.Y.CurrentVelocity             = 0.0f;
                        sideScrollingCharacterController.IsJumpHeld = false;
                    }

                    //Differentiate between jumping and falling
                    if (!IsJumpPressedThisFrame)
                    {
                        sideScrollingCharacterController.IsJumpHeld = false;
                    }

                    //Did the player let go of jump?
                    if (sideScrollingCharacterController.IsJumping && !sideScrollingCharacterController.IsJumpHeld)
                    {
                        sideScrollingCharacterController.IsJumping = false;
                    }

                    //Check if we should start falling
                    if (!sideScrollingCharacterController.IsJumping && !sideScrollingCharacterController.IsFalling)
                    {
                        //Start Falling
                        sideScrollingCharacterController.IsFalling = true;

                        velocityCurve.Y = VelocityCurveAxis.Quadratic(velocityCurve.Y.CurrentVelocity,
                                                                      false,
                                                                      sideScrollingCharacterController.FallingAbsoluteAcceleration,
                                                                      sideScrollingCharacterController.TerminalVelocity);
                    }
                }
            }