/// <summary>
        /// Tests for sendFrom is working and grid attached or in range. Use without range to skip range test. If sendTo is not a block or a grid, will skip grid test. If sendTo is a block, it must be working.
        /// </summary>
        /// <param name="sendFrom"></param>
        /// <param name="sendTo"></param>
        /// <param name="range"></param>
        /// <returns></returns>
        public static bool canSendTo(this IMyCubeBlock sendFrom, IMyEntity sendTo, bool friendsOnly, float range = 0, bool rangeIsSquared = false)
        {
            sendFrom.throwIfNull_argument("sendFrom");
            sendTo.throwIfNull_argument("sendTo");

            if (sendFrom.Closed || !sendFrom.IsWorking)
            {
                return(false);
            }

            IMyCubeBlock sendToAsBlock = sendTo as IMyCubeBlock;

            if (sendToAsBlock != null)
            {
                if (sendToAsBlock.Closed || !sendToAsBlock.IsWorking)
                {
                    return(false);
                }

                if (friendsOnly && !sendFrom.canConsiderFriendly(sendToAsBlock))
                {
                    return(false);
                }

                if (AttachedGrids.isGridAttached(sendFrom.CubeGrid, sendToAsBlock.CubeGrid))
                {
                    return(true);
                }

                if (range > 0)
                {
                    double distanceSquared = (sendFrom.GetPosition() - sendTo.GetPosition()).LengthSquared();
                    if (rangeIsSquared)
                    {
                        return(distanceSquared < range);
                    }
                    else
                    {
                        return(distanceSquared < range * range);
                    }
                }
            }
            else
            {
                IMyCubeGrid sendToAsGrid = sendTo as IMyCubeGrid;
                if (sendToAsGrid != null)
                {
                    if (friendsOnly && !sendFrom.canConsiderFriendly(sendToAsGrid))
                    {
                        return(false);
                    }

                    if (Rynchodon.AttachedGrids.isGridAttached(sendFrom.CubeGrid, sendToAsGrid))
                    {
                        return(true);
                    }
                }

                // may or may not be grid
                if (range > 0)
                {
                    double distance = sendTo.WorldAABB.Distance(sendFrom.GetPosition());
                    if (rangeIsSquared)
                    {
                        return(distance * distance < range);
                    }
                    else
                    {
                        return(distance < range);
                    }
                }
            }

            return(false);
        }