Exemple #1
0
        /// <summary>
        /// Starts harvesting.
        /// </summary>
        private void StartHarvest()
        {
            LogEntered("StartHarvest()");
            HarvestState = Navigator.ReportableState.Harvest;
            CNS.setDestination(targetVoxel);

            if (!VoxelsBetweenNavAndPoint((Vector3D)CNS.getWayDest()))
            {
                myLogger.debugLog("no voxels between nav drill and destination", "StartHarvest()");
                SetNextStage(Ready, false);
                return;
            }
            if (myNav.MM.rotLenSq > rotLenSq_offCourse)
            {
                myLogger.debugLog("too far from correct direction", "StartHarvest()");
                SetNextStage(StartTunnelThrough, false);
                return;
            }

            if (IsInsideAsteroid())
            {
                myLogger.debugLog("now inside asteroid", "StartHarvest()");
                SetNextStage(Harvest, true);
            }

            myNav.collisionCheckMoveAndRotate();
        }
Exemple #2
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);
        }
Exemple #3
0
        /// <summary>
        /// Starts backing out
        /// </summary>
        private void StartBackout()
        {
            LogEntered("StartBackout()");
            HarvestState = Navigator.ReportableState.H_Back;

            //CNS.atWayDest(); // consider destination reached
            CNS_SetHarvest();
            CNS.setDestination(ReadyPoint);
            CNS.SpecialFlyingInstructions = NavSettings.SpecialFlying.Line_SidelForward;
            myNav.fullStop("StartBackout");

            SetNextStage(Backout, false);
        }
Exemple #4
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);
        }
Exemple #5
0
        /// <summary>
        /// if outside of asteroid move using closestVoxel
        /// </summary>
        private void ApproachAsteroid()
        {
            LogEntered("ApproachAsteroid()");
            if (IsInsideAsteroid() || myNav.MM.distToWayDest < 10)
            {
                myLogger.debugLog("Reached point (possibly)", "ApproachAsteroid()");
                myNav.fullStop("close to asteroid");
                CNS_SetHarvest();
                CNS.setDestination(targetVoxel);
                CNS.SpecialFlyingInstructions = NavSettings.SpecialFlying.Line_Any;

                SetNextStage(RotateToWaypoint, false);
                return;
            }

            myNav.collisionCheckMoveAndRotate();
        }