public void AssertData(MotionResult data, SnapshotSpan? span, MotionKind motionKind = null) { if (span.HasValue) { Assert.Equal(span.Value, data.Span); } if (motionKind != null) { Assert.Equal(motionKind, data.MotionKind); } }
public void AssertData(MotionResult data, SnapshotSpan? span, MotionKind motionKind = null, CaretColumn desiredColumn = null) { if (span.HasValue) { Assert.Equal(span.Value, data.Span); } if (motionKind != null) { Assert.Equal(motionKind, data.MotionKind); } if (desiredColumn != null) { Assert.Equal(desiredColumn, data.DesiredColumn); } }
public static MotionResult PhysicsStepHorizontal(ref CharacterPhysicsInfo cpi, ref Position position, ref ThreeDVelocity velocity, bool onGround, int coefficientOfRestitution256, int groundFriction256, WorldPhysics physics) { MotionResult result = MotionResult.None; int newPositionX = velocity.X.Update(position.X); int newPositionZ = velocity.Z.Update(position.Z); int deltaX = newPositionX - position.X; int deltaZ = newPositionZ - position.Z; if (deltaX != 0) { if (CharacterPhysics.TryMoveHorizontalDidHitWall(ref cpi, physics, deltaX, 0, onGround, ref position)) { // Hit wall, bounce: velocity.X.Scale256(-coefficientOfRestitution256); result = MotionResult.HitWall; } } // Z-motion just stops if it hits anything if (deltaZ != 0 && CharacterPhysics.TryMoveHorizontalDidHitWall(ref cpi, physics, 0, deltaZ, onGround, ref position)) { velocity.Z.Reset(); // NOTE: Currently not even bothering to give a hit result, just carry on... } // TODO: Slope handling for rolling objects if (onGround) { // Friction: velocity.X.Scale256(groundFriction256); velocity.Z.Scale256(groundFriction256); } return(result); }
public void MoveCaretToMotionResult_CaretAfterLastLine() { Create("dog", "cat", "bear"); _editorOperations.Setup(x => x.ResetSelection()); var data = new MotionResult( _textBuffer.GetLineRange(0).ExtentIncludingLineBreak, true, MotionKind.Exclusive, OperationKind.CharacterWise, FSharpOption.Create(CaretColumn.AfterLastLine)); _operations.MoveCaretToMotionResult(data); Assert.AreEqual(_textBuffer.GetLine(1).Start, _textView.GetCaretPoint()); }