Beispiel #1
0
        public static Waypoint CreateWaypointAt(
            string name,
            CelestialBody body,
            double latitude,
            double longitude,
            string detail1 = null,
            string detail2 = null,
            string detail3 = null)
        {
            var waypoint = new Waypoint()
            {
                celestialName = body.name,
                name          = name,
                nodeCaption1  = detail1,
                nodeCaption2  = detail2,
                nodeCaption3  = detail3,
                latitude      = latitude,
                longitude     = longitude,
                id            = "custom",
                seed          = 269,
                height        = TerrainHeight(latitude, longitude, body),
                altitude      = 0
            };

            ScenarioCustomWaypoints.AddWaypoint(waypoint);
            return(waypoint);
        }
        /// <summary>
        /// Adds the waypoint to the custom waypoint list.
        /// </summary>
        /// <param name="waypoint">The waypoint to add</param>
        public static void AddWaypoint(Waypoint waypoint)
        {
            int    seed     = waypoint.seed;
            string id       = waypoint.id;
            double altitude = waypoint.altitude;

            ScenarioCustomWaypoints.AddWaypoint(waypoint);

            waypoint.seed     = seed;
            waypoint.id       = id;
            waypoint.altitude = altitude;

            waypoint.index = Instance.nextIndex++;
        }
Beispiel #3
0
        public static Waypoint CreateWaypointNear(
            string name,
            Vessel near,
            double minDistanceInMeters,
            double maxDistanceInMeters,
            double scannerNetQuality,
            bool waterAllowed,
            string detail1 = null,
            string detail2 = null,
            string detail3 = null)
        {
            Waypoint bestWaypoint         = null;
            double   bestWaypointDistance = 0;
            double   currentMaxDistance   = maxDistanceInMeters;

            for (int i = 0; i <= 3 * scannerNetQuality; ++i)
            {
                var waypoint = new Waypoint()
                {
                    celestialName = near.mainBody.name,
                    name          = name,
                    nodeCaption1  = detail1,
                    nodeCaption2  = detail2,
                    nodeCaption3  = detail3,
                    id            = "custom",
                    seed          = 269,
                };

                waypoint.RandomizeNear(near.latitude, near.longitude, minDistanceInMeters, currentMaxDistance, waterAllowed: false, generator: new System.Random());
                waypoint.height   = WaypointHeight(waypoint);
                waypoint.altitude = 0;

                double thisWaypointDistance = StraightLineDistanceInMeters(near, waypoint);

                if (i == 0 || thisWaypointDistance < bestWaypointDistance)
                {
                    bestWaypoint         = waypoint;
                    bestWaypointDistance = thisWaypointDistance;
                }

                currentMaxDistance = minDistanceInMeters + (currentMaxDistance - minDistanceInMeters) * .75;
            }

            ScenarioCustomWaypoints.AddWaypoint(bestWaypoint);
            return(bestWaypoint);
        }
Beispiel #4
0
        public void AddWaypoint(bool challenge, string HoloKronName, Vector3 nextLocation)
        {
            waypointColor                 = new System.Random().Next(1, int.MaxValue) * _rColors.Count();
            currentWaypoint               = new Waypoint();
            currentWaypoint.id            = "marker";
            currentWaypoint.seed          = _rColors[waypointColor];
            currentWaypoint.name          = HoloKronName;
            currentWaypoint.celestialName = FlightGlobals.currentMainBody.name;
            currentWaypoint.longitude     = nextLocation.y;
            currentWaypoint.longitude     = nextLocation.y;
            currentWaypoint.latitude      = nextLocation.x;
            currentWaypoint.altitude      = nextLocation.z;
            currentWaypoint.height        = nextLocation.z + 1;

            //currentWaypoint.iconSize = 1;
            OrXLog.instance.DebugLog("[OrX Target Manager] === ADDING WAYPOINT FOR " + HoloKronName + " ===");
            waypoints.Add(currentWaypoint);
            ScenarioCustomWaypoints.AddWaypoint(currentWaypoint);
        }
Beispiel #5
0
        protected string setWaypoint(string resourceName, GoldStrikeLode lode)
        {
            if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH)
            {
                debugLog("Trying to set waypoint");
                string location = string.Format("Lon: {0:f2} Lat: {1:f2} Alt: {2:f2}", this.part.vessel.longitude, this.part.vessel.latitude, this.part.vessel.altitude);

                Waypoint waypoint = new Waypoint();
                waypoint.name          = resourceName + " Lode";
                waypoint.isExplored    = true;
                waypoint.isNavigatable = true;
                waypoint.isOnSurface   = true;
                waypoint.celestialName = this.part.vessel.mainBody.name;
                waypoint.longitude     = this.part.vessel.longitude;
                waypoint.latitude      = this.part.vessel.latitude;
                waypoint.altitude      = this.part.vessel.altitude;
                waypoint.seed          = UnityEngine.Random.Range(0, int.MaxValue);
                waypoint.navigationId  = Guid.NewGuid();

                //Add the waypoint to the custom waypoint scenario
                ScenarioCustomWaypoints.AddWaypoint(waypoint);

                //Our icon is not correct, do a quick remove, reset the icon, and add
                WaypointManager.RemoveWaypoint(waypoint);
                waypoint.id           = WBIGoldStrikeScenario.kLodeIcon;
                waypoint.nodeCaption1 = location;
                WaypointManager.AddWaypoint(waypoint);

                //Record the waypoint info
                lode.navigationID = waypoint.navigationId.ToString();

                //Save the game
                GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP);

                //Done
                return(waypoint.navigationId.ToString());
            }

            return(string.Empty);
        }