Пример #1
0
        /// <summary>
        /// Prepare for harvesting
        /// </summary>
        /// <remarks>
        /// <para>If drills are full, change stage to Finished.</para>
        /// <para>Get closest asteroid, pick a random point.</para>
        /// <para>Set CNS settings</para>
        /// <para>Enables Drills.</para>
        /// </remarks>>
        private void Ready()
        {
            LogEntered("Ready()");
            HarvestState = Navigator.ReportableState.H_Ready;

            if (DrillFullness(GetDrills()) > FullAmount_Return)
            {
                myLogger.debugLog("Drills are full: " + DrillFullness(GetDrills()) + " > " + FullAmount_Return, "Ready()");
                SetNextStage(Finished, false);
                return;
            }

            Vector3D?target = GetUsefulTarget(GetClosestAsteroid().WorldVolume);

            if (!target.HasValue)
            {
                myLogger.debugLog("failed to get a useful point inside asteroid", "Ready()");
                SetNextStage(Ready, false);
                return;
            }
            targetVoxel = (Vector3)target;
            CNS_RestorePrevious();
            CNS.setDestination(closestVoxel);
            CNS.ignoreAsteroids = true;
            ReadyPoint          = NavigationDrill.GetPosition();

            myLogger.debugLog("Ready", "Ready()");
            SetNextStage(ApproachAsteroid, false);
        }
Пример #2
0
        /// <summary>
        /// Keep getting random point in sphere until there is one with voxels between it and nav drill
        /// </summary>
        private Vector3D?GetUsefulTarget(BoundingSphereD sphere)
        {
            Vector3 navPos = NavigationDrill.GetPosition();

            for (int attempt = 0; attempt < 10; attempt++)
            {
                Vector3 point = GetRandomTarget(sphere);
                if (VoxelsBetweenNavAndPoint(point))
                {
                    myLogger.debugLog("got a useful point: " + point, "GetUsefulTarget()");
                    return(point);
                }
                myLogger.debugLog("totally useless: " + point, "GetUsefulTarget()");
            }
            return(null);
        }
Пример #3
0
        private void StartTunnelThrough()
        {
            LogEntered("StartTunnelThrough()");
            HarvestState = Navigator.ReportableState.H_Tunnel;

            //CNS.atWayDest(); // consider destination reached
            Vector3D current     = NavigationDrill.GetPosition();
            Vector3D forwardVect = NavigationDrill.WorldMatrix.Forward;

            CNS_SetHarvest();
            CNS.setDestination(current + forwardVect * 128);
            CNS.SpecialFlyingInstructions = NavSettings.SpecialFlying.Line_Any;
            myNav.fullStop("start tunneling through");

            SetNextStage(TunnelThrough, true);
        }
Пример #4
0
 /// <summary>
 /// Determines if there are voxels between navigation drill and given point
 /// </summary>
 private bool VoxelsBetweenNavAndPoint(Vector3D point)
 {
     return(MyAPIGateway.Entities.RayCastVoxel(NavigationDrill.GetPosition(), point, out closestVoxel));
 }