示例#1
0
        private IEnumerable <long> GetMatchingAttributeIds(SearchAreas attribute, string searchTerm, bool exactMatch = false)
        {
            if (attribute == SearchAreas.Album)
            {
                if (exactMatch)
                {
                    return(_musicLibrary.OrderedAlbums.Where(a => a.ToString().ToLower().Equals(searchTerm)).Select(a => a.Id));
                }
                else
                {
                    return(_musicLibrary.OrderedAlbums.Where(a => a.ToString().ToLower().Contains(searchTerm)).Select(a => a.Id));
                }
            }
            else if (attribute == SearchAreas.Artist)
            {
                if (exactMatch)
                {
                    return(_musicLibrary.OrderedArtists.Where(a => a.ToString().ToLower().Equals(searchTerm)).Select(a => a.Id));
                }
                else
                {
                    return(_musicLibrary.OrderedArtists.Where(a => a.ToString().ToLower().Contains(searchTerm)).Select(a => a.Id));
                }
            }

            return(Enumerable.Empty <long>());
        }
示例#2
0
        public void Execute()
        {
            if (Finished || WowInterface.Player.IsCasting)
            {
                return;
            }

            if (!WowInterface.Player.IsInCombat && DateTime.UtcNow.Subtract(LastUnitCheck).TotalMilliseconds >= 1250.0)
            {
                LastUnitCheck = DateTime.UtcNow;
                WowUnit       = WowInterface.ObjectManager.WowObjects
                                .OfType <WowUnit>()
                                .Where(e => !e.IsDead && NpcIds.Contains(WowGuid.ToNpcId(e.Guid)) && !e.IsNotAttackable &&
                                       WowInterface.HookManager.WowGetUnitReaction(WowInterface.Player, e) != WowUnitReaction.Friendly)
                                .OrderBy(e => e.Position.GetDistance(WowInterface.Player.Position))
                                .Take(3)
                                .OrderBy(e => WowInterface.PathfindingHandler.GetPathDistance((int)WowInterface.ObjectManager.MapId, WowInterface.Player.Position, e.Position))
                                .FirstOrDefault();

                // Kill enemies in the path
                if (WowUnit != null && !WowInterface.CombatClass.IsTargetAttackable(WowUnit))
                {
                    var path = WowInterface.PathfindingHandler.GetPath((int)WowInterface.ObjectManager.MapId,
                                                                       WowInterface.Player.Position, WowUnit.Position);
                    if (path != null)
                    {
                        var nearEnemies =
                            WowInterface.ObjectManager.GetEnemiesInPath <WowUnit>(path, 10.0f);
                        if (nearEnemies.Any())
                        {
                            WowUnit = nearEnemies.FirstOrDefault();
                        }
                    }
                }

                if (WowUnit != null)
                {
                    WowInterface.HookManager.WowTargetGuid(WowUnit.Guid);
                }
            }

            if (WowUnit != null)
            {
                SearchAreas.NotifyDetour();
                WowInterface.CombatClass.AttackTarget();
            }
            else if (WowInterface.Player.Position.GetDistance(CurrentSpot) < 3.0f || SearchAreas.HasAbortedPath() || WowInterface.MovementEngine.Status == MovementAction.None)
            {
                CurrentSpot = SearchAreas.GetNextPosition(WowInterface);
                WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, CurrentSpot);
            }
        }
示例#3
0
        /// <summary>
        /// Get a list of tracks who's attribute type equals the id specified. Filename
        /// attribute is supported by this lookup method.
        /// </summary>
        /// <param name="attribute">The attribute type to select.</param>
        /// <param name="attributeId">The id of the attribute.</param>
        /// <returns>A list of tracks that match the given attribute keypair.</returns>
        public List <ITrack> GetTracksByAttributeId(SearchAreas attribute, long attributeId)
        {
            var stopwatch = Stopwatch.StartNew();

            var searchAreas = new List <SearchAreas>();

            _dbContextMutex.Wait();
            var songs = _dukeboxData.Songs;

            _dbContextMutex.Release();

            var matchingSongs = Enumerable.Empty <Song>();

            if (attribute == SearchAreas.Filename)
            {
                throw new InvalidOperationException("The filename search attribute is not supported when looking up tracks by attribute id");
            }

            if (attribute == SearchAreas.All)
            {
                AddSearchAreasToList(searchAreas);
            }
            else
            {
                searchAreas.Add(attribute);
            }

            if (searchAreas.Contains(SearchAreas.Album))
            {
                matchingSongs = matchingSongs.Concat(songs.Where(s => s.AlbumId != null ? s.AlbumId == attributeId : false));
            }

            if (searchAreas.Contains(SearchAreas.Artist))
            {
                matchingSongs = matchingSongs.Concat(songs.Where(s => s.ArtistId != null ? s.ArtistId == attributeId : false));
            }

            if (searchAreas.Contains(SearchAreas.Song))
            {
                matchingSongs = matchingSongs.Concat(songs.Where(s => s.Id == attributeId));
            }

            stopwatch.Stop();
            logger.DebugFormat("Getting tracks by attribute {0} and value {1} took {2}ms and returned {3} results.",
                               Enum.GetName(typeof(SearchAreas), attribute), attributeId, stopwatch.ElapsedMilliseconds, matchingSongs.Count());

            return(matchingSongs.Count() < 1 ? new List <ITrack>() : matchingSongs.Select(Track.BuildTrackInstance).ToList());
        }
示例#4
0
        public void Execute()
        {
            if (Finished || Bot.Player.IsCasting)
            {
                return;
            }

            if (!SearchAreas.IsPlayerNearSearchArea(Bot) && Bot.Target == null) // if i have target, go nearby don't clear it
            {
                Bot.Wow.ClearTarget();
                IWowUnit = null;
            }

            if (!Bot.Player.IsInCombat &&
                Bot.Target == null)    // if pulling with ranged we have target and yet not in combat
            {
                IWowUnit = Bot.Objects.All
                           .OfType <IWowUnit>()
                           .Where(e => !e.IsDead && !e.IsNotAttackable &&
                                  Bot.Db.GetReaction(Bot.Player, e) != WowUnitReaction.Friendly &&
                                  e.Health > 10 &&   // workaround to filter some critters, would be nice e.CreatureType != WoWCreatureType.Critter
                                  BotMath.SlopeGradientAngle(Bot.Player.Position, e.Position) <= 39.0f)      // check if not too steep
                           .OrderBy(e => e.Position.GetDistance(Bot.Player.Position))
                           .FirstOrDefault();

                if (IWowUnit != null)
                {
                    Bot.Wow.ChangeTarget(IWowUnit.Guid);
                }
            }

            if (IWowUnit != null)
            {
                SearchAreas.NotifyDetour();
                Bot.CombatClass.AttackTarget();
            }
            else if (Bot.Player.Position.GetDistance(CurrentNode) < 3.5f || SearchAreas.HasAbortedPath())
            {
                CurrentNode = SearchAreas.GetNextPosition(Bot);
                Bot.Movement.SetMovementAction(MovementAction.Move, CurrentNode);
            }
        }
示例#5
0
        public List <ITrack> GetTracksByAttributeValue(SearchAreas attribute, string attributeValue)
        {
            var stopwatch = Stopwatch.StartNew();

            _dbContextMutex.Wait();
            var songs = _dukeboxData.Songs;

            _dbContextMutex.Release();

            var matchingSongs = Enumerable.Empty <Song>();

            var lowerAttributeValue = attributeValue.ToLower();

            if (attribute == SearchAreas.Album)
            {
                var matchingAlbums = GetMatchingAttributeIds(SearchAreas.Album, lowerAttributeValue, true);
                matchingSongs = matchingSongs.Concat(songs.Where(s => s.AlbumId.HasValue ? matchingAlbums.Contains(s.AlbumId.Value) : false));
            }

            if (attribute == SearchAreas.Artist)
            {
                var matchingArtists = GetMatchingAttributeIds(SearchAreas.Artist, lowerAttributeValue, true);
                matchingSongs = matchingSongs.Concat(songs.Where(t => t.ArtistId.HasValue ? matchingArtists.Contains(t.ArtistId.Value) : false));
            }

            if (attribute == SearchAreas.Song)
            {
                matchingSongs = matchingSongs.Concat(songs.Where(s => s.Title.ToLower().Equals(lowerAttributeValue)));
            }

            if (attribute == SearchAreas.Filename)
            {
                matchingSongs = matchingSongs.Concat(songs.Where(s => s.FileName.ToLower().Equals(lowerAttributeValue)));
            }


            stopwatch.Stop();
            logger.DebugFormat("Getting tracks by attribute(s) '{0}' where name or title equal '{1}' took {2}ms and returned {3} results.",
                               attribute, lowerAttributeValue, stopwatch.ElapsedMilliseconds, matchingSongs.Count());

            return(matchingSongs.Count() < 1 ? new List <ITrack>() : matchingSongs.ToList().Select(Track.BuildTrackInstance).ToList());
        }
示例#6
0
        public void Execute()
        {
            if (Finished || WowInterface.Player.IsCasting)
            {
                return;
            }

            if (!SearchAreas.IsPlayerNearSearchArea(WowInterface))
            {
                WowInterface.HookManager.WowClearTarget();
                WowUnit = null;
            }

            if (!WowInterface.Player.IsInCombat)
            {
                WowUnit = WowInterface.ObjectManager.WowObjects
                          .OfType <WowUnit>()
                          .Where(e => !e.IsDead && !e.IsNotAttackable &&
                                 WowInterface.HookManager.WowGetUnitReaction(WowInterface.Player, e) != WowUnitReaction.Friendly)
                          .OrderBy(e => e.Position.GetDistance(WowInterface.Player.Position))
                          .FirstOrDefault();

                if (WowUnit != null)
                {
                    WowInterface.HookManager.WowTargetGuid(WowUnit.Guid);
                }
            }

            if (WowUnit != null)
            {
                SearchAreas.NotifyDetour();
                WowInterface.CombatClass.AttackTarget();
            }
            else if (WowInterface.Player.Position.GetDistance(CurrentNode) < 3.5f || SearchAreas.HasAbortedPath())
            {
                CurrentNode = SearchAreas.GetNextPosition(WowInterface);
                WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, CurrentNode);
            }
        }
示例#7
0
 public List <ITrack> GetTracksByAttributeId(SearchAreas attribute, long attributeId)
 {
     return(_searchService.GetTracksByAttributeId(attribute, attributeId));
 }
示例#8
0
 public List <ITrack> GetTracksByAttributeValue(SearchAreas attribute, string attributeValue)
 {
     return(_searchService.GetTracksByAttributeValue(attribute, attributeValue));
 }
示例#9
0
 public List <ITrack> SearchForTracksInArea(SearchAreas attribute, string nameOrTitle)
 {
     return(SearchForTracks(nameOrTitle, new List <SearchAreas> {
         attribute
     }));
 }