public static void SpellIdByNameCreateCache() { lock (SpellManagerLocker) { try { foreach (var spell in ListSpell) { string name = spell.Value.ToLower(); if (!CacheSpellIdByName.ContainsKey(name)) { CacheSpellIdByName.Add(name, new List <uint> { spell.Key }); } else if (!CacheSpellIdByName[name].Contains(spell.Key)) { CacheSpellIdByName[name].Add(spell.Key); } } } catch (Exception exception) { Logging.WriteError("SpellIdByNameCreateCache(): " + exception); } } }
// Get the spell id using the provided English spell name public static List <uint> SpellIdByName(string spellName) { lock (SpellManagerLocker) { var listIdSpellFound = new List <UInt32>(); try { spellName = spellName.ToLower(); if (CacheSpellIdByName.TryGetValue(spellName, out listIdSpellFound)) { return(listIdSpellFound); } listIdSpellFound = new List <uint>(); foreach (var spell in ListSpell) { if (spell.Value.ToLower() == spellName) { listIdSpellFound.Add(spell.Key); } } CacheSpellIdByName.Add(spellName, listIdSpellFound); return(listIdSpellFound); } catch (Exception exception) { Logging.WriteError("SpellIdByName(string spellName): " + exception); return(listIdSpellFound); } } }