Exemple #1
0
        public void Main(string argument, UpdateType updateSource)
        {
            if ((updateSource & ~(UpdateType.Update1 | UpdateType.Update10 | UpdateType.Update100)) != 0)
            {
                if (Cmd.TryParse(argument))
                {
                    switch (Cmd.Argument(0))
                    {
                    case "fly": FlyForward(); break;

                    case "dock": PerformDocking(); break;

                    case "scan": QuickScan(); break;

                    case "halt": QuickHalt(); break;

                    default:
                        Log($"Unknown command: {Cmd.Argument(0)}"); break;
                    }
                }
            }
            if ((updateSource & (UpdateType.Update1 | UpdateType.Update10 | UpdateType.Update100)) != 0)
            {
                if (Pilot.Tasks.Count > 0)
                {
                    Pilot.Update(Runtime.TimeSinceLastRun.TotalSeconds);
                }
                if (Cockpit.IsUnderControl)
                {
                    UpdateShipInfo();
                    UpdateStorageInfo();
                }
            }
        }
Exemple #2
0
 IEnumerable <string> Launch()
 {
     logScreen?.WriteText("", false);
     Message($"Target: {TargetLocation.ToString()}");
     if (ApproachIndex < 0)
     {
         var minkv = Approaches.MinBy((kv) => (float)(TargetLocation.CurrentPosition - kv.Value[0]).Length());
         ChosenApproach = minkv.Key;
         ApproachIndex  = minkv.Value.Count - 1;
     }
     if ((Approaches[ChosenApproach][0] - TargetLocation.CurrentPosition).Length() > AbortDistance)
     {
         Message("Target location is too far from the dock!");
         yield return("");
     }
     else
     {
         PreFlightPreparations();
         Clamp.Unlock();
         Vector3D detach = DockLocation - DockApproachVector * 2 * Me.CubeGrid.WorldVolume.Radius;
         Pilot.Tasks.Clear();
         var task = new UnaimedFlightStrategy(detach, Connector);
         task.MaxLinearSpeed = MaxSpeed;
         Pilot.Tasks.Add(task);
         while (!Pilot.Update(Runtime.TimeSinceLastRun.TotalSeconds))
         {
             yield return(null);
         }
         foreach (var cam in Cameras)
         {
             cam.EnableRaycast = true;
         }
         yield return("LeaveDock");
     }
 }