protected MovementStruct GetSimilarManeuverByStruct(MovementStruct alternativeManeuverStruct) { MovementStruct result = alternativeManeuverStruct; if (!Selection.ThisShip.HasManeuver(result) || (failedManeuvers.Contains(result))) { if (result.Speed == ManeuverSpeed.Speed1) { result.SpeedInt++; } else { result.SpeedInt--; if (!Selection.ThisShip.HasManeuver(result) || (failedManeuvers.Contains(result))) { result.SpeedInt--; if (!Selection.ThisShip.HasManeuver(result) || (failedManeuvers.Contains(result))) { result.SpeedInt--; //for example, 5 bank -> 2 bank } } } } result.UpdateColorComplexity(); return(result); }
protected virtual void TryAlternativeMovement() { if (alternativeManeuvers.Count > 0) { MovementStruct maneuver = alternativeManeuvers[0]; maneuver.UpdateColorComplexity(); alternativeManeuvers.Remove(alternativeManeuvers[0]); if (failedManeuvers.Contains(maneuver) || !Selection.ThisShip.HasManeuver(maneuver)) { TryAlternativeMovement(); } else { GenericMovement newMovementAttempt = ShipMovementScript.MovementFromStruct(maneuver); if (DebugManager.DebugAI) { Debug.Log("Tries: " + newMovementAttempt); } Selection.ThisShip.SetAssignedManeuver(newMovementAttempt); newMovementAttempt.Initialize(); movementPrediction = new MovementPrediction(newMovementAttempt, CheckSwerveAlternativePrediction); } } else { Console.Write("Ship doesn't see alternatives to the asteroid collision", LogTypes.AI, false, "yellow"); Selection.ThisShip.SetAssignedManeuver(originalMovement); Selection.ThisShip.AssignedManeuver.LaunchShipMovement(); } }