Ejemplo n.º 1
0
 public override void Close()
 {
     selectedObject = null;
     base.Close();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws the groundStation icons on the map
        /// </summary>
        public void drawTrackingStations()
        {
            if (CareerUtils.isSandboxGame)
            {
                KerbalKonstructs.instance.mapShowClosed = true;
                KerbalKonstructs.instance.mapShowOpen   = true;
            }

            if (!KerbalKonstructs.instance.mapShowGroundStation)
            {
                return;
            }

            body = PlanetariumCamera.fetch.target.GetReferenceBody();

            displayingTooltip2 = false;

            // Do tracking stations first
            for (int i = 0; i < groundStations.Count; i++)
            {
                groundStation = groundStations[i];
                if ((mapHideIconsBehindBody) && (IsOccluded(groundStation.position, body)))
                {
                    continue;
                }

                isOpen = ((GroundStation)groundStation.myFacilities[0]).isOpen;


                if (!KerbalKonstructs.instance.mapShowClosed && !isOpen)
                {
                    continue;
                }

                if (!KerbalKonstructs.instance.mapShowOpen && isOpen)
                {
                    continue;
                }

                if (groundStation.groupCenter.isHidden && !isOpen || groundStation.groupCenter.isHidden && (((GroundStation)groundStation.myFacilities[0]).OpenCost == 0))
                {
                    continue;
                }


                Vector3 pos = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(groundStation.position));

                Rect screenRect6 = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16);
                // Distance between camera and spawnpoint sort of
                float fPosZ        = pos.z;
                float fRadarRadius = 12800 / fPosZ;

                if (fRadarRadius > 15)
                {
                    GUI.DrawTexture(screenRect6, UIMain.TrackingStationIcon, ScaleMode.ScaleToFit, true);
                }


                if (screenRect6.Contains(Event.current.mousePosition) && !displayingTooltip2)
                {
                    var objectpos2 = groundStation.CelestialBody.transform.InverseTransformPoint(groundStation.position);

                    var disObjectLat2 = KKMath.GetLatitudeInDeg(objectpos2);
                    var disObjectLon2 = KKMath.GetLongitudeInDeg(objectpos2);

                    if (disObjectLon2 < 0)
                    {
                        disObjectLon2 = disObjectLon2 + 360;
                    }

                    //Only display one tooltip at a time
                    DisplayMapIconToolTip("Tracking Station " + "\n(Lat." + disObjectLat2.ToString("#0.00") + "/ Lon." + disObjectLon2.ToString("#0.00") + ")", pos);

                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                    {
                        selectedFacility = groundStation;
                        FacilityManager.selectedInstance = groundStation;
                        FacilityManager.instance.Open();
                    }
                }
            }
        }