/// <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); }
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); }
/// <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)); }