ace/Source/ACE.Server/Factories/Entity/SpellLevelCache.cs
gmriggs 8494eeb6bf
minor performance improvements to AssignMagic() (#3222)
* minor performance improvements to AssignMagic()

* updating to latest master branch
2020-10-20 12:05:09 -04:00

21 lines
603 B
C#

using System.Collections.Concurrent;
using ACE.Server.Entity;
namespace ACE.Server.Factories.Entity
{
public static class SpellLevelCache
{
private static readonly ConcurrentDictionary<int, int> spellLevels = new ConcurrentDictionary<int, int>();
public static int GetSpellLevel(int spellId)
{
if (!spellLevels.TryGetValue(spellId, out var spellLevel))
{
var spell = new Spell(spellId);
spellLevel = spellLevels[spellId] = (int)spell.Formula.Level;
}
return spellLevel;
}
}
}