/// <summary> /// GUI Tracking /// </summary> /// <param name="windowID"></param> private void WindowGUITracking(int windowID) { GUI.DragWindow(new Rect(0, 0, 200, 30)); GUILayout.BeginVertical(); if (!trackingActive && RmmUtil.IsPreLaunch(vessel)) { if (trackWinMode != 0) { windowPosGUITracking = new Rect(200, 200, 300, 100); trackWinMode = 0; } createMissionForm(); } else if (trackingActive) { if (trackWinMode != 1) { windowPosGUITracking = new Rect(0, 400, 200, 50); trackWinMode = 1; } GUILayout.BeginHorizontal(); GUILayout.Label("tracking", RmmStyle.Instance.LabelStyle, GUILayout.Width(60)); if (GUILayout.Button("stop tracking", RmmStyle.Instance.ButtonStyle, GUILayout.Width(100), GUILayout.Height(22))) { trackAbort(); } GUILayout.EndHorizontal(); } else if (returnMission && !trackingActive && RmmUtil.IsDocked(vessel, part)) { if (trackWinMode != 2) { windowPosGUITracking = new Rect(200, 200, 300, 50); trackWinMode = 2; } returnMissionForm(); } else { CloseGUITracking(); } GUILayout.EndVertical(); }
public static Structure GetDockedStructure(Vessel vessel, Part dockedPort) { if (dockedPort == null) { return(null); } List <Part> dockedParts = RmmUtil.GetDockedParts(vessel, dockedPort); // root of structure is the docked port Part rootPart = dockedPort; // seperate child parts dockedParts.Remove(dockedPort); List <Part> childParts = dockedParts; // Create structure var structure = new Structure(); structure.Parts = new List <StructurePart>(); structure.Root = StructurePart.GetStructurePart(rootPart, rootPart); // decrement link count if root part is docked if (RmmUtil.IsDocked(vessel, dockedPort)) { structure.Root.LinkCount--; } structure.Parts = new List <StructurePart>(); // add root to structure parts structure.Parts.Add(structure.Root); // add all child parts to structure parts foreach (Part childPart in dockedParts) { structure.Parts.Add(StructurePart.GetStructurePart(childPart, rootPart)); } return(structure); }
public void handleTrackingPrimary() { switch (trackingStatus) { case "Launch": if (vessel.situation == Vessel.Situations.FLYING || vessel.situation == Vessel.Situations.SUB_ORBITAL || vessel.situation == Vessel.Situations.ORBITING) { trackLaunch(); } break; case "Departure": foreach (Part p in vessel.parts) { if (p.flightID == trackPort && !RmmUtil.IsDocked(vessel, p)) { trackDeparture(); } } break; case "Underway": updatePartCount(); updateCrewCount(); updateMaxCrewCount(); // check for arrival if (_mission.Info.Type == 10) { if (vessel.situation == Vessel.Situations.ORBITING && RmmUtil.AllowedBody(vessel.mainBody.name)) { foreach (Part p in vessel.parts) { ModuleDockingNode dockingModule = p.Modules.OfType <ModuleDockingNode>().FirstOrDefault(); if (dockingModule != null) { Part dockedPart = RmmUtil.GetDockedPart(vessel, p); if (dockedPart != null && !Mission.PartIsMissionPart(dockedPart, _mission.Launch.Parts)) { trackArrival(p); return; } } } } } // make snapshot of vessel if (_mission.Info.Type == 10) { if (vessel.situation == Vessel.Situations.ORBITING && RmmUtil.AllowedBody(vessel.mainBody.name)) { // don't make snapshot when the vessel is in the process of docking. It leaves the docking port in the wrong state. bool isAnyPartDocking = false; foreach (Part p in vessel.parts) { ModuleDockingNode dockingModule = p.Modules.OfType <ModuleDockingNode>().FirstOrDefault(); if (dockingModule != null && RmmUtil.IsDocking(p)) { isAnyPartDocking = true; } } if (!isAnyPartDocking) { TakeVesselSnapShot(); } } } // check for landing if (_mission.Info.Type == 10 || _mission.Info.Type == 20) { if ((vessel.situation == Vessel.Situations.LANDED || vessel.situation == Vessel.Situations.SPLASHED) && RmmUtil.HomeBody(vessel.mainBody.name)) { if (landedTime == 0.0) { landedTime = Planetarium.GetUniversalTime(); landedLatitude = vessel.latitude; landedLongitude = vessel.longitude; landedTimeMessage = 0; } } if (landedTime > 0.0) { // Check still landed if (!(vessel.situation == Vessel.Situations.LANDED || vessel.situation == Vessel.Situations.SPLASHED) || !RmmUtil.HomeBody(vessel.mainBody.name)) { landedTime = 0.0; landedLatitude = 0.0; landedLongitude = 0.0; landedTimeMessage = 0; } // Check not moved else if (RmmUtil.GetDistanceBetweenPoints(landedLatitude, landedLongitude, vessel.latitude, vessel.longitude, vessel.mainBody.Radius) > 2) { landedTime = 0.0; landedLatitude = 0.0; landedLongitude = 0.0; landedTimeMessage = 0; } // Countdown else if (Planetarium.GetUniversalTime() - landedTime > 0.0 && Planetarium.GetUniversalTime() - landedTime < 10) { if (Planetarium.GetUniversalTime() - landedTime > landedTimeMessage + 1.0) { landedTimeMessage = landedTimeMessage + 1; ScreenMessages.PostScreenMessage("landing confirmation " + (10 - landedTimeMessage).ToString() + " seconds", 1, ScreenMessageStyle.UPPER_CENTER); } } // Landed else if (Planetarium.GetUniversalTime() - landedTime > 10) { TrackLanding(); return; } } } if (RmmUtil.CountVesselParts(vessel) > trackPartCount) { trackAbort("vessel has joined with non mission vessel"); } if (RmmUtil.AstronautCrewCount(vessel) > trackCrew) { trackAbort("crew has been added to vessel"); } updateTrackingVars(vessel); break; } }