Ejemplo n.º 1
0
        /// <summary>
        /// ReplaceMent for finding vessels
        /// </summary>
        /// <param name="flightState"></param>
        /// <param name="landedAt"></param>
        /// <param name="count"></param>
        /// <param name="name"></param>
        /// <param name="idx"></param>
        /// <param name="vType"></param>
        public static void FindVesselsLandedAtKK(FlightState flightState, string landedAt, out int count, out string name, out int idx, out VesselType vType)
        {
            // Log.Normal("Called");
            float maxDistance = 100f;

            int          vesselIndex = 0;
            KKLaunchSite launchSite  = LaunchSiteManager.GetLaunchSiteByName(landedAt);

            count = 0;
            name  = string.Empty;
            idx   = 0;
            vType = VesselType.Debris;

            if (flightState != null)
            {
                foreach (ProtoVessel vessel in flightState.protoVessels)
                {
                    if (vessel == null)
                    {
                        continue;
                    }

                    if (launchSite == null || launchSite.isSquad)
                    {
                        if (vessel.landedAt.Contains(landedAt))
                        {
                            count++;
                            name  = vessel.vesselName;
                            idx   = vesselIndex;
                            vType = vessel.vesselType;
                            break;
                        }
                    }
                    else
                    {
                        //if (vessel.situation == Vessel.Situations.SPLASHED || vessel.situation == Vessel.Situations.LANDED || vessel.situation == Vessel.Situations.PRELAUNCH )
                        //                        {
                        ////                            Log.Normal("Body: "+ FlightGlobals.Bodies[vessel.orbitSnapShot.ReferenceBodyIndex].name);
                        CelestialBody body     = FlightGlobals.Bodies[vessel.orbitSnapShot.ReferenceBodyIndex];
                        Vector3       position = body.GetWorldSurfacePosition(vessel.latitude, vessel.longitude, vessel.altitude);
                        float         distance = Vector3.Distance(position, launchSite.staticInstance.gameObject.transform.position);
                        //Log.Normal("Vessel with distance: " + distance);
                        if (distance < maxDistance)
                        {
                            Log.Normal("Found Vessel at Launchsite with distance: " + distance);
                            count++;
                            name  = vessel.vesselName;
                            idx   = vesselIndex;
                            vType = vessel.vesselType;
                            break;
                        }
                        //}
                    }
                    vesselIndex++;
                }
            }
        }
Ejemplo n.º 2
0
 public KKPrelaunchSizeCheck(string launchSiteName)
 {
     if (HighLogic.LoadedScene == GameScenes.EDITOR)
     {
         shipSize   = ShipConstruction.CalculateCraftSize(EditorLogic.fetch.ship);
         launchSite = LaunchSiteManager.GetLaunchSiteByName(launchSiteName);
     }
     else
     {
         allowLaunch = true;
     }
 }
Ejemplo n.º 3
0
 public KKPrelaunchPartCheck(string launchSiteName)
 {
     if (HighLogic.LoadedScene == GameScenes.EDITOR)
     {
         shipParts  = EditorLogic.fetch.ship.parts.Count;
         launchSite = LaunchSiteManager.GetLaunchSiteByName(launchSiteName);
     }
     else
     {
         allowLaunch = true;
     }
 }
Ejemplo n.º 4
0
 public KKPrelaunchMassCheck(string launchSiteName)
 {
     if (HighLogic.LoadedScene == GameScenes.EDITOR)
     {
         shipMass   = EditorLogic.fetch.ship.GetTotalMass();
         launchSite = LaunchSiteManager.GetLaunchSiteByName(launchSiteName);
     }
     else
     {
         allowLaunch = true;
     }
 }
Ejemplo n.º 5
0
        public void SetDefault(bool value)
        {
            if (value)
            {
                LaunchSiteManager.setLaunchSite(LaunchSiteManager.GetLaunchSiteByName(siteName));
                MiscUtils.HUDMessage(siteName + " has been set as the launchsite", 10, 0);

                if (EditorDriver.editorFacility == EditorFacility.VAB)
                {
                    KerbalKonstructs.instance.defaultVABlaunchsite = siteName;
                }
                else
                {
                    KerbalKonstructs.instance.defaultSPHlaunchsite = siteName;
                }
            }
        }
Ejemplo n.º 6
0
        public static List <ProtoVessel> FindVesselsLandedAt2(FlightState flightState, string landedAt)
        {
            float maxDistance       = 100f;
            List <ProtoVessel> list = new List <ProtoVessel>();

            if (flightState != null)
            {
                KKLaunchSite launchSite = LaunchSiteManager.GetLaunchSiteByName(landedAt);

                foreach (ProtoVessel vessel in flightState.protoVessels)
                {
                    if (vessel == null)
                    {
                        continue;
                    }

                    if (launchSite == null || launchSite.isSquad)
                    {
                        if (vessel.landedAt.Contains(landedAt))
                        {
                            list.Add(vessel);
                        }
                    }
                    else
                    {
                        //if (vessel.situation == Vessel.Situations.SPLASHED || vessel.situation == Vessel.Situations.LANDED || vessel.situation == Vessel.Situations.PRELAUNCH)
                        //{
                        CelestialBody body     = FlightGlobals.Bodies[vessel.orbitSnapShot.ReferenceBodyIndex];
                        Vector3       position = body.GetWorldSurfacePosition(vessel.latitude, vessel.longitude, vessel.altitude);
                        float         distance = Vector3.Distance(position, launchSite.staticInstance.transform.position);

                        if (distance < maxDistance)
                        {
                            Log.Normal("Found Vessel at Launchsite with distance: " + distance);
                            list.Add(vessel);
                        }
                        //}
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 7
0
 public void LauchVessel()
 {
     LaunchSiteManager.setLaunchSite(LaunchSiteManager.GetLaunchSiteByName(siteName));
     EditorLogic.fetch.launchVessel();
 }