public static SpeechEntry[] GetKeywords(string text) { if (!NewConfig.EncodeSpeech) { return(new SpeechEntry[0]); } if (m_Speech == null) { LoadSpeechTable(); } text = text.ToLower(); ArrayList dataStore = Engine.GetDataStore(); SpeechEntry[] speech = m_Speech; int length = speech.Length; for (int i = 0; i < length; i++) { SpeechEntry entry = speech[i]; if (IsMatch(text, entry.m_Keywords)) { dataStore.Add(entry); } } dataStore.Sort(); SpeechEntry[] entryArray2 = (SpeechEntry[])dataStore.ToArray(typeof(SpeechEntry)); Engine.ReleaseDataStore(dataStore); return(entryArray2); }
private LayoutEntry[] ParseLayout(string layout) { int num; ArrayList dataStore = Engine.GetDataStore(); int startIndex = 0; while ((num = layout.IndexOf('{', startIndex)) >= 0) { num++; startIndex = layout.IndexOf('}', num); dataStore.Add(new LayoutEntry(layout.Substring(num, startIndex - num).Trim())); } LayoutEntry[] entryArray = (LayoutEntry[])dataStore.ToArray(typeof(LayoutEntry)); Engine.ReleaseDataStore(dataStore); return(entryArray); }
public Item[] FindItems(IItemValidator check) { if (check == null) { throw new ArgumentNullException("check"); } ArrayList dataStore = Engine.GetDataStore(); Queue queue = m_FindItems_Queue; if (queue == null) { queue = m_FindItems_Queue = new Queue(); } else if (queue.Count > 0) { queue.Clear(); } if (check.IsValid(this)) { dataStore.Add(this); } if (this.m_Items.Count > 0) { queue.Enqueue(this); while (queue.Count > 0) { Item item = (Item)queue.Dequeue(); ArrayList items = item.m_Items; int count = items.Count; for (int i = 0; i < count; i++) { Item item2 = (Item)items[i]; if (check.IsValid(item2)) { dataStore.Add(item2); } if (item2.m_Items.Count > 0) { queue.Enqueue(item2); } } } } Item[] itemArray = (Item[])dataStore.ToArray(typeof(Item)); Engine.ReleaseDataStore(dataStore); return(itemArray); }
public static Item[] FindItems(IItemValidator check) { ArrayList dataStore = Engine.GetDataStore(); IEnumerator enumerator = m_Items.Values.GetEnumerator(); while (enumerator.MoveNext()) { Item current = (Item)enumerator.Current; if (((current.Visible && current.InWorld) && (!current.IsMulti && InRange(current))) && check.IsValid(current)) { dataStore.Add(current); } } Item[] itemArray = (Item[])dataStore.ToArray(typeof(Item)); Engine.ReleaseDataStore(dataStore); return(itemArray); }
public void Update() { ArrayList dataStore = Engine.GetDataStore(); Gump[] gumpArray = base.m_Children.ToArray(); for (int i = 0; i < gumpArray.Length; i++) { GMacroKeyButton button = gumpArray[i] as GMacroKeyButton; if ((button != null) && (button.Macro != null)) { dataStore.Add(button); } } bool flag = (this.m_Mods & MacroModifiers.All) != MacroModifiers.None; bool flag2 = (this.m_Mods & MacroModifiers.Ctrl) != MacroModifiers.None; bool flag3 = (this.m_Mods & MacroModifiers.Alt) != MacroModifiers.None; bool flag4 = (this.m_Mods & MacroModifiers.Shift) != MacroModifiers.None; ArrayList list = Macros.List; for (int j = 0; j < list.Count; j++) { Macro mc = (Macro)list[j]; if (flag || (((mc.Control == flag2) && (mc.Alt == flag3)) && (mc.Shift == flag4))) { object obj2 = this.GetButton(mc.Key); if (obj2 is GMacroKeyButton[]) { GMacroKeyButton[] buttonArray = (GMacroKeyButton[])obj2; for (int m = 0; m < buttonArray.Length; m++) { this.SetMacro(dataStore, buttonArray[m], mc); } } else if (obj2 is GMacroKeyButton) { this.SetMacro(dataStore, (GMacroKeyButton)obj2, mc); } } } for (int k = 0; k < dataStore.Count; k++) { ((GMacroKeyButton)dataStore[k]).Macro = null; } Engine.ReleaseDataStore(dataStore); }
public PSellItems(int serial, SellInfo[] info) : base(0x9f, "Sell Items") { ArrayList dataStore = Engine.GetDataStore(); for (int i = 0; i < info.Length; i++) { if (info[i].ToSell > 0) { dataStore.Add(info[i]); } } base.m_Stream.Write(serial); base.m_Stream.Write((ushort)dataStore.Count); for (int j = 0; j < dataStore.Count; j++) { SellInfo info2 = (SellInfo)dataStore[j]; base.m_Stream.Write(info2.Item.Serial); base.m_Stream.Write((ushort)info2.ToSell); } Engine.ReleaseDataStore(dataStore); }
public PGumpButton(GServerGump gump, int buttonID) : base(0xb1, "Gump Response") { base.m_Stream.Write(gump.Serial); base.m_Stream.Write(gump.DialogID); base.m_Stream.Write(buttonID); ArrayList dataStore = Engine.GetDataStore(); ArrayList list = Engine.GetDataStore(); Gump[] gumpArray = gump.Children.ToArray(); for (int i = 0; i < gumpArray.Length; i++) { if (gumpArray[i] is IRelayedSwitch) { IRelayedSwitch switch2 = (IRelayedSwitch)gumpArray[i]; if (switch2.Active) { dataStore.Add(switch2.RelayID); } } else if (gumpArray[i] is GServerTextBox) { list.Add(gumpArray[i]); } } base.m_Stream.Write(dataStore.Count); for (int j = 0; j < dataStore.Count; j++) { base.m_Stream.Write((int)dataStore[j]); } base.m_Stream.Write(list.Count); for (int k = 0; k < list.Count; k++) { GServerTextBox box = (GServerTextBox)list[k]; base.m_Stream.Write((short)box.RelayID); base.m_Stream.Write((short)box.String.Length); base.m_Stream.WriteUnicode(box.String); } Engine.ReleaseDataStore(list); Engine.ReleaseDataStore(dataStore); }
public static void Load(string filename) { m_List = new ArrayList(); m_Running = new ArrayList(); string path = Engine.FileManager.BasePath(string.Format("Data/Plugins/Macros/{0}.txt", filename)); if (File.Exists(path)) { int num = 0; using (StreamReader reader = new StreamReader(path)) { while (true) { string str4; string line = ReadLine(reader); if (line == null) { break; } if (line.Length != 5) { Skip(line, reader); break; } string[] strArray = line.Split(new char[] { ' ' }); if (strArray.Length != 3) { Skip(line, reader); break; } bool flag = true; for (int i = 0; flag && (i < strArray.Length); i++) { flag = (strArray[i] == "0") || (strArray[i] == "1"); } if (!flag) { Skip(line, reader); break; } Keys none = Keys.None; if (strArray[0] != "0") { none |= Keys.Control; } if (strArray[1] != "0") { none |= Keys.Alt; } if (strArray[2] != "0") { none |= Keys.Shift; } string str3 = ReadLine(reader); if (str3 == null) { break; } Keys key = ~Keys.None; switch (str3) { case "WheelUp": case "Wheel Up": key = 0x11000; break; case "WheelDown": case "Wheel Down": key = 0x11001; break; case "WheelPress": case "Wheel Press": key = 0x11002; break; default: try { key = (Keys)Enum.Parse(typeof(Keys), str3, true); } catch { } break; } if (key == ~Keys.None) { Skip(str3, reader); break; } ArrayList dataStore = Engine.GetDataStore(); while ((str4 = ReadLine(reader)) != null) { if (str4.StartsWith("#")) { break; } Action action = new Action(str4); if (action.Handler == null) { Debug.Trace("Bad macro action: {0}", str4); } dataStore.Add(action); } Macro macro = new Macro(key, none, (Action[])dataStore.ToArray(typeof(Action))) { FileIndex = num++ }; m_List.Add(macro); Engine.ReleaseDataStore(dataStore); } m_List.Sort(); } } }