internal Coordinate CalculatePredictedPosition() { if ((this.moveDirection == MoveDirections.None) && (this.strafeDirection == SpinOrStrafeDirections.None)) { return(new Coordinate(this.RawCoordinates)); } else if (this.spinDirection == SpinOrStrafeDirections.None) { Vector3 moveVector = this.CalculateMoveVector(); moveVector = moveVector * this.PredictionDuration.TotalSeconds; /*this.RawCoordinates = new Vector3() * { * x = this.RawCoordinates.X + moveVector.x, * y = this.RawCoordinates.Y + moveVector.y, * z = this.RawCoordinates.Z + moveVector.z * }; * * this.PredictionTime = DateTime.UtcNow;*/ Coordinate result = new Coordinate( new Vector3( this.RawCoordinates.X + moveVector.x, this.RawCoordinates.Y + moveVector.y, this.RawCoordinates.Z + moveVector.z)); LogUtil.Debug( DebugInfoDetail.Movement, moveVector.ToString().PadRight(40) + "/" + result.ToString() + "/"); return(result); } else { Vector3 moveVector; Vector3 positionFromCentreOfTurningCircle; double turnArcAngle; double y; double duration; duration = this.PredictionDuration.TotalSeconds; moveVector = this.CalculateMoveVector(); turnArcAngle = this.calculateTurnArcAngle(); // This is calculated seperately as height is unaffected by turning y = this.RawCoordinates.Y + (moveVector.y * duration); if (this.spinDirection == SpinOrStrafeDirections.Left) { positionFromCentreOfTurningCircle = new Vector3(moveVector.z, y, -moveVector.x); } else { positionFromCentreOfTurningCircle = new Vector3(-moveVector.z, y, moveVector.x); } return (new Coordinate( new Vector3(this.RawCoordinates.X, this.RawCoordinates.Y, this.RawCoordinates.Z) + (Vector3) Quaternion.RotateVector3( new Quaternion(Vector3.AxisY, turnArcAngle), positionFromCentreOfTurningCircle) - positionFromCentreOfTurningCircle)); } }
public override void Coordinates(Vector3 position) { this.RawCoordinates = position; LogUtil.Debug(DebugInfoDetail.Movement, "Coord Set at: " + position.ToString()); this.PredictionTime = DateTime.UtcNow; }