protected override string GetNotes()
 {
     if (displayNotes)
     {
         if (sop == null)
         {
             sop = new SpecificOrbitParameter(OrbitType.POLAR, orbit.inclination, orbit.eccentricity, orbit.semiMajorAxis, orbit.LAN, orbit.argumentOfPeriapsis, orbit.meanAnomalyAtEpoch, orbit.epoch, targetBody, deviationWindow);
         }
         return(sop.Notes);
     }
     else
     {
         return(notes);
     }
 }
Exemplo n.º 2
0
        public void Draw()
        {
            // No contract
            if (contract == null)
            {
                return;
            }

            // Check contract state when displaying
            if (contract.ContractState == Contract.State.Active ||
                contract.ContractState == Contract.State.Offered && HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                // Update the map icons
                foreach (OrbitData obData in orbits)
                {
                    SpecificOrbitParameter s = AlwaysTrue.FetchOrAdd(contract).GetParameter(obData.index) as SpecificOrbitParameter;
                    s.updateMapIcons(CelestialUtilities.MapFocusBody() == obData.orbit.referenceBody);
                }
            }
        }
Exemplo n.º 3
0
        private CelestialBody getTargetBody()
        {
            if (root == null)
            {
                return(null);
            }

            bool checkTitle = false;

            Type t = root.GetType();

            try
            {
                if (t == typeof(CollectScience))
                {
                    return(((CollectScience)root).TargetBody);
                }
                else if (t == typeof(PartTest))
                {
                    var fields = typeof(PartTest).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

                    return(fields[1].GetValue((PartTest)root) as CelestialBody);
                }
                else if (t == typeof(PlantFlag))
                {
                    return(((PlantFlag)root).TargetBody);
                }
                else if (t == typeof(RecoverAsset))
                {
                    var fields = typeof(RecoverAsset).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

                    return(fields[0].GetValue((RecoverAsset)root) as CelestialBody);
                }
                else if (t == typeof(GrandTour))
                {
                    return(((GrandTour)root).TargetBodies.LastOrDefault());
                }
                else if (t == typeof(ARMContract))
                {
                    var fields = typeof(ARMContract).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

                    return(fields[0].GetValue((ARMContract)root) as CelestialBody);
                }
                else if (t == typeof(BaseContract))
                {
                    return(((BaseContract)root).targetBody);
                }
                else if (t == typeof(ISRUContract))
                {
                    return(((ISRUContract)root).targetBody);
                }
                else if (t == typeof(SatelliteContract))
                {
                    SpecificOrbitParameter p = root.GetParameter <SpecificOrbitParameter>();

                    if (p == null)
                    {
                        return(null);
                    }

                    return(p.TargetBody);
                }
                else if (t == typeof(StationContract))
                {
                    return(((StationContract)root).targetBody);
                }
                else if (t == typeof(SurveyContract))
                {
                    return(((SurveyContract)root).targetBody);
                }
                else if (t == typeof(TourismContract))
                {
                    return(null);
                }
                else if (t == typeof(ExplorationContract))
                {
                    var fields = typeof(ExplorationContract).GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

                    return(fields[1].GetValue((ExplorationContract)root) as CelestialBody);
                }
                else
                {
                    checkTitle = true;
                }
            }
            catch (Exception e)
            {
                Debug.LogError("[Contract Parser] Error Detecting Target Celestial Body...\n" + e);
                return(null);
            }

            if (checkTitle)
            {
                foreach (CelestialBody b in FlightGlobals.Bodies)
                {
                    string n = b.name;

                    Regex r = new Regex(string.Format(@"\b{0}\b", n));

                    if (r.IsMatch(title))
                    {
                        return(b);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 4
0
        public void OnPreCull()
        {
            if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                if (navIsActive())
                {
                    if (trackWP == null)
                    {
                        navWaypoint.Deactivate();
                    }
                }
            }

            if (MapView.MapIsEnabled)
            {
                /*
                 * This block makes me feel dirty inside, but Contracts don't fire OnUpdate unless they are active.
                 * To show inactive satellite contracts in the Tracking Station, we need either this or an elaborate Monobehavior.
                 */
                MapObject target = PlanetariumCamera.fetch.target;

                foreach (SatelliteContract c in ContractSystem.Instance.GetCurrentContracts <SatelliteContract>())
                {
                    SpecificOrbitParameter p = c.GetParameter <SpecificOrbitParameter>();

                    bool focused = true;

                    switch (target.type)
                    {
                    case MapObject.MapObjectType.CELESTIALBODY:
                        if (target.celestialBody.GetName() != p.targetBody.GetName())
                        {
                            focused = false;
                        }
                        break;

                    case MapObject.MapObjectType.MANEUVERNODE:
                        if (target.maneuverNode.patch.referenceBody.GetName() != p.targetBody.GetName())
                        {
                            focused = false;
                        }
                        break;

                    case MapObject.MapObjectType.VESSEL:
                        if (target.vessel.mainBody.GetName() != p.targetBody.GetName())
                        {
                            focused = false;
                        }
                        break;

                    default:
                        focused = false;
                        break;
                    }

                    p.updateMapIcons(focused);
                }

                foreach (Waypoint wp in waypoints)
                {
                    UpdateWaypoint(wp);
                }
            }
        }