/// <summary> /// Calculate the best rotation to stop the ship. /// </summary> /// TODO: if ship cannot rotate quickly, find a reasonable alternative to facing primary public void CalcRotate_Stop() { //Log.DebugLog("entered CalcRotate_Stop()", "CalcRotate_Stop()"); Vector3 linearVelocity = LinearVelocity; if (!Thrust.CanMoveAnyDirection() || linearVelocity.LengthSquared() > 1f) { //Log.DebugLog("rotate to stop"); if (SignificantGravity()) { CalcRotate_InGravity(RelativeDirection3F.FromWorld(Block.CubeGrid, -linearVelocity)); } else { CalcRotate(Thrust.Standard.LocalMatrix, RelativeDirection3F.FromWorld(Block.CubeGrid, -linearVelocity)); } return; } CalcRotate_Hover(); }
/// <summary> /// Rotate to face the best direction for flight. /// </summary> public void CalcRotate() { //Log.DebugLog("entered CalcRotate()", "CalcRotate()"); //Vector3 pathMoveResult = m_newPathfinder.m_targetDirection; //if (!pathMoveResult.IsValid()) //{ // CalcRotate_Stop(); // return; //} // if the ship is limited, it must always face accel direction if (!Thrust.CanMoveAnyDirection() && m_moveAccel != Vector3.Zero) { //Log.DebugLog("limited thrust"); CalcRotate_Accel(); return; } //if (NavSet.Settings_Current.NearingDestination) //{ // CalcRotate_Stop(); // return; //} if (m_thrustHigh && m_moveAccel != Vector3.Zero) { m_thrustHigh = false; //Log.DebugLog("accel high"); CalcRotate_Accel(); return; } CalcRotate_Hover(); }