Esempio n. 1
0
        public static List <INamedWorldZoneLocation> GetMatches(string partialName)
        {
            List <INamedWorldZoneLocation> worldZoneLocationList = new List <INamedWorldZoneLocation>(3);

            string[] strArray = partialName.Split(new char[1]
            {
                ' '
            }, StringSplitOptions.RemoveEmptyEntries);
            for (int index1 = 0; index1 < WorldLocationMgr.LocationCache.Length; ++index1)
            {
                INamedWorldZoneLocation worldZoneLocation = WorldLocationMgr.LocationCache[index1];
                bool flag = true;
                for (int index2 = 0; index2 < strArray.Length; ++index2)
                {
                    string str = strArray[index2];
                    if (worldZoneLocation.DefaultName.IndexOf(str, StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    worldZoneLocationList.Add(worldZoneLocation);
                }
            }

            return(worldZoneLocationList);
        }
Esempio n. 2
0
 /// <summary>Depends on Table-Creation (Third)</summary>
 public static void Initialize()
 {
     ContentMgr.Load <WorldZoneLocation>();
     WorldLocationMgr.LocationCache = WorldLocationMgr.WorldLocations.Values.ToArray <INamedWorldZoneLocation>();
     WorldLocationMgr.Stormwind     = WorldLocationMgr.GetFirstMatch("Stormwind");
     WorldLocationMgr.Orgrimmar     = WorldLocationMgr.GetFirstMatch("Orgrimmar");
 }
Esempio n. 3
0
        /// <summary>
        /// Gets the first <see cref="T:WCell.RealmServer.Global.WorldZoneLocation" /> matching the given name parts
        /// </summary>
        /// <param name="partialName"></param>
        /// <returns></returns>
        public static INamedWorldZoneLocation GetFirstMatch(string partialName)
        {
            string[] strArray = partialName.Split(new char[1]
            {
                ' '
            }, StringSplitOptions.RemoveEmptyEntries);
            for (int index1 = 0; index1 < LocationCache.Length; ++index1)
            {
                INamedWorldZoneLocation worldZoneLocation = LocationCache[index1];
                bool flag = true;
                for (int index2 = 0; index2 < strArray.Length; ++index2)
                {
                    string str = strArray[index2];
                    if (worldZoneLocation.DefaultName.IndexOf(str, StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    return(worldZoneLocation);
                }
            }

            return(null);
        }
Esempio n. 4
0
 /// <summary>Depends on Table-Creation (Third)</summary>
 public static void Initialize()
 {
     ContentMgr.Load <WorldZoneLocation>();
     LocationCache = WorldLocations.Values.ToArray();
     Stormwind     = GetFirstMatch("Stormwind");
     Orgrimmar     = GetFirstMatch("Orgrimmar");
 }
Esempio n. 5
0
		public static void Initialize()
		{
			ContentMgr.Load<WorldZoneLocation>();
			LocationCache = WorldLocations.Values.ToArray();

			Stormwind = GetFirstMatch("Stormwind");
			Orgrimmar = GetFirstMatch("Orgrimmar");
		}
Esempio n. 6
0
        public static GossipMenu CreateTeleMenu(List <INamedWorldZoneLocation> locations,
                                                Action <GossipConversation, INamedWorldZoneLocation> callback)
        {
            GossipMenu gossipMenu = new GossipMenu();

            foreach (INamedWorldZoneLocation location in locations)
            {
                INamedWorldZoneLocation loc = location;
                gossipMenu.AddItem((GossipMenuItemBase) new GossipMenuItem(loc.Names.LocalizeWithDefaultLocale(),
                                                                           (GossipActionHandler)(convo => callback(convo, loc))));
            }

            return(gossipMenu);
        }
Esempio n. 7
0
        public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            string remainder = trigger.Text.Remainder;
            Unit   target    = trigger.Args.Target;

            if (remainder.Length < 2)
            {
                trigger.Reply("Invalid search term: " + remainder);
            }
            else if (trigger.Args.Character != null)
            {
                List <INamedWorldZoneLocation> matches = WorldLocationMgr.GetMatches(remainder);
                if (matches.Count == 0)
                {
                    trigger.Reply("No matches found for: " + remainder);
                }
                else if (matches.Count > 20)
                {
                    trigger.Reply("Found too many matches ({0}), please narrow down the location.",
                                  (object)matches.Count);
                }
                else if (matches.Count == 1)
                {
                    CreatePortal(target, matches[0]);
                }
                else
                {
                    trigger.Args.Character.StartGossip(WorldLocationMgr.CreateTeleMenu(matches,
                                                                                       (convo, loc) =>
                                                                                       CreatePortal(target, loc)));
                }
            }
            else
            {
                INamedWorldZoneLocation firstMatch = WorldLocationMgr.GetFirstMatch(remainder);
                if (firstMatch != null)
                {
                    CreatePortal(target, firstMatch);
                }
                else
                {
                    trigger.Reply("No matches found for: " + remainder);
                }
            }
        }
Esempio n. 8
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                string str1 = trigger.Text.NextModifiers();
                string name = "";

                if (str1.Contains("n"))
                {
                    name = trigger.Text.NextWord();
                }
                Map rgn;

                if (str1.Contains("d"))
                {
                    string str2 = trigger.Text.NextWord();
                    INamedWorldZoneLocation worldZoneLocation = WorldLocationMgr.Get(str2);
                    if (worldZoneLocation == null)
                    {
                        MapId result;
                        rgn = !EnumUtil.TryParse(str2, out result)
              ? null
              : World.GetNonInstancedMap(result);
                        if (rgn == null)
                        {
                            trigger.Reply("Invalid Destination: " + str2);
                            return;
                        }
                    }
                    else
                    {
                        rgn = worldZoneLocation.Map;
                    }
                }
                else
                {
                    Unit target = trigger.Args.Target;
                    if (target == null)
                    {
                        trigger.Reply("Must have target or specify destination (using the -d switch).");
                        return;
                    }

                    rgn = target.Map;
                    int phase = (int)target.Phase;
                }

                if (rgn == null)
                {
                    trigger.Reply("Instance-destinations are currently not supported.");
                }
                else
                {
                    NPC npc = null;
                    rgn.ExecuteInContext(() =>
                    {
                        foreach (WorldObject worldObject in rgn)
                        {
                            if (worldObject is NPC && (name == "" || worldObject.Name.ContainsIgnoreCase(name)))
                            {
                                npc = (NPC)worldObject;
                                break;
                            }
                        }

                        if (npc == null)
                        {
                            trigger.Reply("Could not find a matching NPC.");
                        }
                        else
                        {
                            Character character = trigger.Args.Character;
                            if (trigger.Args.HasCharacter)
                            {
                                if (name == "" && character.Target != null)
                                {
                                    if (character.Target is NPC)
                                    {
                                        npc = character.Target as NPC;
                                    }
                                    else
                                    {
                                        character.Target = npc;
                                    }
                                }
                                else
                                {
                                    character.Target = npc;
                                }
                            }
                            else
                            {
                                trigger.Args.Target  = npc;
                                trigger.Args.Context = npc;
                            }

                            trigger.Reply("Selected: {0}", (object)npc);
                        }
                    });
                }
            }
Esempio n. 9
0
        public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            if (!trigger.Text.HasNext)
            {
                trigger.Reply("Invalid position. Usage: " + EnglishParamInfo);
            }
            else
            {
                Unit target = trigger.Args.Target;
                if (trigger.Text.NextModifiers() == "c")
                {
                    float?orientation = new float?();
                    Map   map         = null;
                    float num1        = trigger.Text.NextFloat(-50001f);
                    float num2        = trigger.Text.NextFloat(-50001f);
                    if (trigger.Text.HasNext)
                    {
                        MapId mapId = trigger.Text.NextEnum(MapId.End);
                        map = World.GetNonInstancedMap(mapId);
                        if (map == null)
                        {
                            trigger.Reply("Invalid map: " + mapId);
                            return;
                        }
                    }

                    if (num1 < -50000.0 || num2 < -50000.0)
                    {
                        trigger.Reply("Invalid position. Usage: " + EnglishParamInfo);
                    }
                    else
                    {
                        if (map == null)
                        {
                            map = trigger.Args.Character.Map;
                        }
                        Vector3 pos = new Vector3(num1 + map.Offset, num2 + map.Offset, 0.0f);
                        trigger.Args.Target.TeleportTo(map, ref pos, orientation);
                    }
                }
                else
                {
                    string targetName = trigger.Text.Remainder;
                    if (trigger.Args.Character != null)
                    {
                        List <INamedWorldZoneLocation> matches = WorldLocationMgr.GetMatches(targetName);
                        if (matches.Count == 0)
                        {
                            trigger.Reply("No matches found for: " + targetName);
                        }
                        else if (matches.Count == 1)
                        {
                            target.TeleportTo(matches[0]);
                        }
                        else
                        {
                            INamedWorldZoneLocation worldZoneLocation =
                                matches.FirstOrDefault(
                                    loc =>
                                    loc.DefaultName.Equals(targetName,
                                                           StringComparison.InvariantCultureIgnoreCase));
                            if (worldZoneLocation != null)
                            {
                                target.TeleportTo(worldZoneLocation);
                            }
                            else
                            {
                                trigger.Args.Character.StartGossip(WorldLocationMgr.CreateTeleMenu(matches));
                            }
                        }
                    }
                    else
                    {
                        INamedWorldZoneLocation firstMatch = WorldLocationMgr.GetFirstMatch(targetName);
                        if (firstMatch != null)
                        {
                            target.TeleportTo(firstMatch);
                        }
                        else
                        {
                            trigger.Reply("No matches found for: " + targetName);
                        }
                    }
                }
            }
        }