static public WoWPoint GetLocationFromDB(MoveToType type, uint entry)
        {
            NpcResult npcResults = null;

            switch (type)
            {
            case MoveToType.NearestRepair:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Repair);
                break;

            case MoveToType.NearestVendor:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Vendor);
                break;

            case MoveToType.NpcByID:
                npcResults = NpcQueries.GetNpcById(entry);
                break;
            }
            if (npcResults != null)
            {
                return(npcResults.Location);
            }
            else
            {
                return(WoWPoint.Zero);
            }
        }
Example #2
0
        public static WoWPoint GetLocationFromDB(MoveToType type, uint entry)
        {
            NpcResult npcResults = null;

            switch (type)
            {
            case MoveToType.NearestAH:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Auctioneer);
                break;

            case MoveToType.NearestBanker:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Banker);
                break;

            case MoveToType.NearestFlight:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Flightmaster);
                break;

            case MoveToType.NearestGB:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.GuildBanker);
                break;

            case MoveToType.NearestReagentVendor:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.ReagentVendor);
                break;

            case MoveToType.NearestRepair:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Repair);
                break;

            case MoveToType.NearestVendor:
                npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                                      ObjectManager.Me.Location, UnitNPCFlags.Vendor);
                break;

            case MoveToType.NpcByID:
                npcResults = NpcQueries.GetNpcById(entry);
                break;
            }
            if (npcResults != null)
            {
                return(npcResults.Location);
            }
            return(WoWPoint.Zero);
        }
        static public WoWPoint GetLocationFromType(MoveToType type, uint entry)
        {
            WoWObject obj = null;

            if (entry != 0)
            {
                obj = ObjectManager.ObjectList.FirstOrDefault(o => o.Entry == entry);
            }
            if (obj == null)
            {
                switch (type)
                {
                case MoveToType.NearestAH:
                    obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.IsAuctioneer && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                    break;

                case MoveToType.NearestBanker:
                    obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.IsBanker && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                    break;

                case MoveToType.NearestFlight:
                    obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.IsFlightMaster && u.IsFriendly && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                    break;

                case MoveToType.NearestGB:
                    obj = ObjectManager.ObjectList.Where(u => {
                        if (u is WoWUnit)
                        {
                            var un = (WoWUnit)u;
                            if (un.IsGuildBanker)
                            {
                                return(true);
                            }
                        }
                        else if (u is WoWGameObject)
                        {
                            var go = (WoWGameObject)u;
                            if (go.SubType == WoWGameObjectType.GuildBank)
                            {
                                return(true);
                            }
                        }
                        return(false);
                    }).OrderBy(u => u.Distance).FirstOrDefault();
                    break;

                case MoveToType.NearestMailbox:
                    obj = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(u => u.SubType == WoWGameObjectType.Mailbox).OrderBy(u => u.Distance).FirstOrDefault();
                    break;

                case MoveToType.NearestReagentVendor:
                    obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.IsReagentVendor && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                    break;

                case MoveToType.NearestRepair:
                    obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.IsRepairMerchant && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                    break;

                case MoveToType.NearestVendor:
                    obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.IsAnyVendor && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                    break;
                }
            }
            if (obj != null)
            {
                if (obj is WoWUnit && (!ObjectManager.Me.GotTarget || ObjectManager.Me.CurrentTarget != obj))
                {
                    ((WoWUnit)obj).Target();
                }
                return(obj.Location);
            }
            return(WoWPoint.Zero);
        }
 public static WoWPoint GetLocationFromType(MoveToType type, uint entry)
 {
     WoWObject obj = null;
     if (entry != 0)
     {
         obj = ObjectManager.ObjectList.FirstOrDefault(o => o.Entry == entry);
     }
     if (obj == null)
     {
         switch (type)
         {
             case MoveToType.NearestAH:
                 obj = ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => u.IsAuctioneer && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
             case MoveToType.NearestBanker:
                 obj = ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => u.IsBanker && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
             case MoveToType.NearestFlight:
                 obj = ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => u.IsFlightMaster && u.IsFriendly && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
             case MoveToType.NearestGB:
                 obj = ObjectManager.ObjectList.Where(u => {
                     if (u is WoWUnit)
                     {
                         var un = (WoWUnit)u;
                         if (un.IsGuildBanker)
                             return true;
                     }
                     else if (u is WoWGameObject)
                     {
                         var go = (WoWGameObject)u;
                         if (go.SubType == WoWGameObjectType.GuildBank)
                             return true;
                     }
                     return false;
                 }).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
             case MoveToType.NearestMailbox:
                 obj = ObjectManager.GetObjectsOfType<WoWGameObject>().Where(u => u.SubType == WoWGameObjectType.Mailbox).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
             case MoveToType.NearestReagentVendor:
                 obj = ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => u.IsReagentVendor && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
             case MoveToType.NearestRepair:
                 obj = ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => u.IsRepairMerchant && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
             case MoveToType.NearestVendor:
                 obj = ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => u.IsAnyVendor && u.IsAlive).OrderBy(u => u.Distance).FirstOrDefault();
                 break;
         }
     }
     if (obj != null)
     {
         if (obj is WoWUnit && (!ObjectManager.Me.GotTarget || ObjectManager.Me.CurrentTarget != obj))
         {
             ((WoWUnit)obj).Target();
         }
         return obj.Location;
     }
     return WoWPoint.Zero;
 }
 public static WoWPoint GetLocationFromDB(MoveToType type, uint entry)
 {
     NpcResult npcResults = null;
     switch (type)
     {
         case MoveToType.NearestAH:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.Auctioneer);
             break;
         case MoveToType.NearestBanker:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.Banker);
             break;
         case MoveToType.NearestFlight:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.Flightmaster);
             break;
         case MoveToType.NearestGB:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.GuildBanker);
             break;
         case MoveToType.NearestReagentVendor:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.ReagentVendor);
             break;
         case MoveToType.NearestRepair:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.Repair);
             break;
         case MoveToType.NearestVendor:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.Vendor);
             break;
         case MoveToType.NpcByID:
             npcResults = NpcQueries.GetNpcById(entry);
             break;
     }
     if (npcResults != null)
         return npcResults.Location;
     return WoWPoint.Zero;
 }
  static public WoWPoint GetLocationFromDB(MoveToType type, uint entry)
 {
     NpcResult npcResults = null;
     switch (type)
     {
         case MoveToType.NearestRepair:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.Repair);
             break;
         case MoveToType.NearestVendor:
             npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId,
                                          ObjectManager.Me.Location, UnitNPCFlags.Vendor);
             break;
         case MoveToType.NpcByID:
             npcResults = NpcQueries.GetNpcById(entry);
             break;
     }
     if (npcResults != null)
         return npcResults.Location;
     else
         return WoWPoint.Zero;
 }