예제 #1
0
        private static Vendor FindNearestVendor(Vendor.VendorType vendorType)
        {
            var results = new List<Vendor>();

            WoWPoint loc = StyxWoW.Me.Location;

            using (SQLiteDataReader reader = GetSqliteDataReader(SqlCmd_NearestVendor, StyxWoW.Me.MapId, (uint)vendorType.AsNpcFlag(), loc.X, loc.Y, loc.Z))
            {
                while (reader.Read())
                {
                    Vendor result = GetVendor(reader, vendorType);
                    var factionId = (uint)reader.GetInt32(reader.GetOrdinal("faction"));
                    if (StyxWoW.Me.FactionTemplate.GetReactionTowards(WoWFactionTemplate.FromId(factionId)) >= WoWUnitReaction.Neutral && !VendorBlacklist.Contains(result.Entry) &&
                        Navigator.CanNavigateFully(loc, result.Location))
                    {
                        results.Add(result);
                        if (results.Count >= 5)
                            break;
                    }
                }
            }
            return results.Any() ? results.OrderBy(r => r.Location.DistanceSqr(loc)).FirstOrDefault() : null;
        }