Scripts/Auras: Lookup aura scripts by their type, not name

Port From (https://github.com/TrinityCore/TrinityCore/commit/9fc8c86e9a47194a1b271fbcf7bf9e85cb3f0826)
This commit is contained in:
hondacrx
2021-11-03 12:31:46 -04:00
parent b1e6aabee7
commit 5a90a3ddde
6 changed files with 15 additions and 14 deletions
+5 -4
View File
@@ -362,16 +362,17 @@ namespace Game.Spells
// m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
}
public T GetScript<T>(string scriptName) where T : AuraScript
public T GetScript<T>() where T : AuraScript
{
return (T)GetScriptByName(scriptName);
return (T)GetScriptByType(typeof(T));
}
public AuraScript GetScriptByName(string scriptName)
public AuraScript GetScriptByType(Type type)
{
foreach (var auraScript in m_loadedScripts)
if (auraScript._GetScriptName().Equals(scriptName))
if (auraScript.GetType() == type)
return auraScript;
return null;
}