/// <summary>
        /// Gets nearby objects matching flags and within maxRange.
        /// Can be used as needed, does not trigger a scene search.
        /// This only searches pre-populated list of nearby objects which is updated at low frequency.
        /// </summary>
        /// <param name="flags">Flags to search for.</param>
        /// <param name="maxRange">Max range for search. Not matched to classic range at this time.</param>
        /// <returns>NearbyObject list. Can be null or empty.</returns>
        public List <NearbyObject> GetNearbyObjects(NearbyObjectFlags flags, float maxRange = 14f)
        {
            if (flags == NearbyObjectFlags.None)
            {
                return(null);
            }

            var query =
                from no in nearbyObjects
                where ((no.flags & flags) == flags) && no.distance < maxRange
                select no;

            return(query.ToList());
        }
        public NearbyObjectFlags GetEntityFlags(DaggerfallEntityBehaviour entity)
        {
            NearbyObjectFlags result = NearbyObjectFlags.None;

            if (!entity)
            {
                return(result);
            }

            if (entity.EntityType == EntityTypes.EnemyClass || entity.EntityType == EntityTypes.EnemyMonster)
            {
                result |= NearbyObjectFlags.Enemy;
                DFCareer.EnemyGroups enemyGroup = (entity.Entity as EnemyEntity).GetEnemyGroup();
                switch (enemyGroup)
                {
                case DFCareer.EnemyGroups.Undead:
                    result |= NearbyObjectFlags.Undead;
                    break;

                case DFCareer.EnemyGroups.Daedra:
                    result |= NearbyObjectFlags.Daedra;
                    break;

                case DFCareer.EnemyGroups.Humanoid:
                    result |= NearbyObjectFlags.Humanoid;
                    break;

                case DFCareer.EnemyGroups.Animals:
                    result |= NearbyObjectFlags.Animal;
                    break;
                }
            }
            else if (entity.EntityType == EntityTypes.CivilianNPC)
            {
                result |= NearbyObjectFlags.Humanoid;
            }

            // Set magic flag
            // Not completely sure what conditions should flag entity for "detect magic"
            // Currently just assuming entity has active effects
            EntityEffectManager manager = entity.GetComponent <EntityEffectManager>();

            if (manager && manager.EffectCount > 0)
            {
                result |= NearbyObjectFlags.Magic;
            }

            return(result);
        }
        public NearbyObjectFlags GetLootFlags(DaggerfallLoot loot)
        {
            NearbyObjectFlags result = NearbyObjectFlags.None;

            if (!loot)
            {
                return(result);
            }

            // Set treasure flag when container not empty
            // Are any other conditions required?
            // Should corspes loot container be filtered out?
            if (loot.Items.Count > 0)
            {
                result |= NearbyObjectFlags.Treasure;
            }

            return(result);
        }