예제 #1
0
        /// <summary>
        /// Whether this vessel meets the parameter condition.
        /// </summary>
        /// <param name="vessel">The vessel to check</param>
        /// <returns>Whether the vessel meets the condition</returns>
        protected override bool VesselMeetsCondition(Vessel vessel)
        {
            LoggingUtil.LogVerbose(this, "Checking VesselMeetsCondition: " + vessel.id);

            // Not even close
            if (vessel.mainBody.name != waypoint.celestialName)
            {
                return(false);
            }

            // Default distance
            if (distance == 0.0)
            {
                if (waypoint.isOnSurface)
                {
                    distance = 500.0;
                }
                else
                {
                    distance = Math.Max(1000.0, waypoint.altitude / 5.0);
                }
            }

            // Calculate the distance
            double actualDistance = WaypointUtil.GetDistanceToWaypoint(vessel, waypoint, ref height);

            LoggingUtil.LogVerbose(this, "Distance to waypoint '" + waypoint.name + "': " + actualDistance);
            return(actualDistance <= distance);
        }
예제 #2
0
        /// <summary>
        /// Whether this vessel meets the parameter condition.
        /// </summary>
        /// <param name="vessel">The vessel to check</param>
        /// <returns>Whether the vessel meets the condition</returns>
        protected override bool VesselMeetsCondition(Vessel vessel)
        {
            LoggingUtil.LogVerbose(this, "Checking VesselMeetsCondition: " + vessel.id);

            // Make sure we have a waypoint
            if (waypoint == null && Root != null)
            {
                waypoint = FetchWaypoint(Root, true);
            }
            if (waypoint == null)
            {
                return(false);
            }

            // Not even close
            if (vessel.mainBody.name != waypoint.celestialName)
            {
                return(false);
            }

            // Default distance
            if (distance == 0.0 && horizontalDistance == 0.0)
            {
                // Close to the surface
                if (waypoint.altitude < 25.0)
                {
                    distance = 500.0;
                }
                else
                {
                    distance = Math.Max(1000.0, waypoint.altitude / 5.0);
                }
            }

            // Calculate the distance
            bool check = false;

            if (distance != 0.0)
            {
                double actualDistance = WaypointUtil.GetDistanceToWaypoint(vessel, waypoint, ref height);
                LoggingUtil.LogVerbose(this, "Distance to waypoint '" + waypoint.name + "': " + actualDistance);
                check = actualDistance <= distance;
            }
            else
            {
                double actualDistance = WaypointUtil.GetDistance(vessel.latitude, vessel.longitude, waypoint.latitude, waypoint.longitude, vessel.altitude);
                LoggingUtil.LogVerbose(this, "Horizontal distance to waypoint '" + waypoint.name + "': " + actualDistance);
                check = actualDistance <= horizontalDistance;
            }

            // Output the message for entering/leaving the waypoint area.
            if (showMessages)
            {
                if (check ^ nearWaypoint)
                {
                    nearWaypoint = check;
                    string waypointName = waypoint.name + (waypoint.isClustered ? " " + StringUtilities.IntegerToGreek(waypoint.index) : "");
                    string msg          = "You are " + (nearWaypoint ? "entering " : "leaving ") + waypointName + ".";
                    ScreenMessages.PostScreenMessage(msg, 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }

                NavWaypoint navWaypoint = NavWaypoint.fetch;
                if (navWaypoint != null && navWaypoint.Latitude == waypoint.latitude && navWaypoint.Longitude == waypoint.longitude)
                {
                    navWaypoint.IsBlinking = nearWaypoint;
                }
            }

            return(check);
        }