public void Test(System.Random rnd)
 {
     if (tgt_ast == null)
     {
         var obt  = CreateRandomOrbitNearby(VesselOrbit);
         var seed = (uint)rnd.Next();
         tgt_ast = DiscoverableObjectsUtil.SpawnAsteroid("REN Test " + seed, obt, seed, UntrackedObjectClass.C, 5e5, 1e6);
         if (tgt_ast.vesselRef != null)
         {
             tgt_ast.vesselRef.DiscoveryInfo.SetLevel(DiscoveryLevels.Owned);
             CheatOptions.InfinitePropellant = true;
             SetTarget(tgt_ast.vesselRef);
             CFG.AP2.XOn(Autopilot2.Rendezvous);
         }
         return;
     }
     if (CFG.AP2[Autopilot2.Rendezvous])
     {
         delay.Reset();
         return;
     }
     CFG.AP2.XOff();
     if (!delay.TimePassed)
     {
         return;
     }
     if (tgt_ast != null)
     {
         if (tgt_ast.vesselRef != null)
         {
             tgt_ast.vesselRef.Die();
         }
         tgt_ast = null;
     }
 }
示例#2
0
        public void MakeAsteroid()
        {
            var obt  = Orbit.CreateRandomOrbitNearby(vessel.orbit);
            var seed = (uint)UnityEngine.Random.Range(0, int.MaxValue);
            var ast  = DiscoverableObjectsUtil.SpawnAsteroid("Ast. N" + seed, obt, seed, UntrackedObjectClass.E, 5e5, 1e6);

            ast.vesselRef.DiscoveryInfo.SetLevel(DiscoveryLevels.Owned);
        }
        public ProtoVessel SpawnAsteroid()
        {
            double baseDays = 21 + random.NextDouble() * 360;
            Orbit  orbit    = Orbit.CreateRandomOrbitFlyBy(Planetarium.fetch.Home, baseDays);

            ProtoVessel pv = DiscoverableObjectsUtil.SpawnAsteroid(
                DiscoverableObjectsUtil.GenerateAsteroidName(),
                orbit,
                (uint)SentinelUtilities.RandomRange(random),
                SentinelUtilities.WeightedAsteroidClass(random),
                double.PositiveInfinity, double.PositiveInfinity);

            return(pv);
        }
        protected bool CreateAsteriod(System.Random RND)
        {
            var obt  = CreateRandomOrbit(TCA.vessel.orbit);
            var seed = (uint)RND.Next();

            target = DiscoverableObjectsUtil.SpawnAsteroid("REN Test " + seed, obt, seed, UntrackedObjectClass.C, 5e5, 1e6);
            if (target.vesselRef == null)
            {
                Utils.Message("Unable to create test asteroid");
                return(false);
            }
            target.vesselRef.DiscoveryInfo.SetLevel(DiscoveryLevels.Owned);
            VSL.SetTarget(REN, new WayPoint(target.vesselRef));
            return(true);
        }
示例#5
0
        /// <summary>
        /// Spawn an asteroid of the given class at the given position.
        /// </summary>
        /// <param name="position">The position to spawn the asteroid.</param>
        /// <param name="untrackedObjectClassIndex">The class of the asteroid. -1 picks one at random.</param>
        /// <returns>The asteroid vessel.</returns>
        public static Vessel SpawnAsteroid(Vector3d position, int untrackedObjectClassIndex = -1)
        {
            if (untrackedObjectClassIndex < 0)
            {
                untrackedObjectClassIndex = RNG.Next(UntrackedObjectClasses.Length);
            }
            var asteroid = DiscoverableObjectsUtil.SpawnAsteroid(DiscoverableObjectsUtil.GenerateAsteroidName(), GetOrbitForApoapsis2(position), (uint)RNG.Next(), UntrackedObjectClasses[untrackedObjectClassIndex], double.MaxValue, double.MaxValue);

            if (asteroid != null && asteroid.vesselRef != null)
            {
                return(asteroid.vesselRef);
            }
            else
            {
                return(null);
            }
        }