/// <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++; } } }
public KKPrelaunchSizeCheck(string launchSiteName) { if (HighLogic.LoadedScene == GameScenes.EDITOR) { shipSize = ShipConstruction.CalculateCraftSize(EditorLogic.fetch.ship); launchSite = LaunchSiteManager.GetLaunchSiteByName(launchSiteName); } else { allowLaunch = true; } }
public KKPrelaunchPartCheck(string launchSiteName) { if (HighLogic.LoadedScene == GameScenes.EDITOR) { shipParts = EditorLogic.fetch.ship.parts.Count; launchSite = LaunchSiteManager.GetLaunchSiteByName(launchSiteName); } else { allowLaunch = true; } }
public KKPrelaunchMassCheck(string launchSiteName) { if (HighLogic.LoadedScene == GameScenes.EDITOR) { shipMass = EditorLogic.fetch.ship.GetTotalMass(); launchSite = LaunchSiteManager.GetLaunchSiteByName(launchSiteName); } else { allowLaunch = true; } }
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; } } }
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); }
public void LauchVessel() { LaunchSiteManager.setLaunchSite(LaunchSiteManager.GetLaunchSiteByName(siteName)); EditorLogic.fetch.launchVessel(); }