public static bool CheckSurroundingEntities(EntityAlive theEntity)
    {
        List <Entity> NearbyEntities = new List <Entity>();
        List <Entity> NearbyEnemies  = new List <Entity>();
        EntityAlive   leader         = EntityUtilities.GetLeaderOrOwner(theEntity.entityId) as EntityAlive;


        float originalView = theEntity.GetMaxViewAngle();

        theEntity.SetMaxViewAngle(250f);

        // Search in the bounds are to try to find the most appealing entity to follow.
        Bounds bb = new Bounds(theEntity.position, new Vector3(20f, 20f, 20f));

        theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, NearbyEntities);
        DisplayLog(" Nearby Entities: " + NearbyEntities.Count);
        for (int i = NearbyEntities.Count - 1; i >= 0; i--)
        {
            EntityAlive x = (EntityAlive)NearbyEntities[i];
            if (x is EntityVehicle)
            {
                continue;
            }

            if (x != theEntity && x.IsAlive())
            {
                if (leader != null && x == leader)
                {
                    continue;
                }

                if (x.CanSee(theEntity.position))
                {
                    DisplayLog(" I can be seen by an enemy.");
                    if (!theEntity.CanSee(x.position))
                    {
                        DisplayLog(" I know an entity is there, but I can't see it: " + x.EntityName);
                        continue;
                    }
                }
                DisplayLog("Nearby Entity: " + x.EntityName);
                if (SphereII_DMTEAIUtilities.CheckFactionForEnemy(theEntity, x))
                {
                    NearbyEnemies.Add(x);
                }
            }
        }

        theEntity.SetMaxViewAngle(originalView);
        return(NearestEnemy(theEntity, NearbyEnemies));
    }