Core/Scripts: Reworked scripts. More to come.

This commit is contained in:
hondacrx
2021-02-18 11:57:11 -05:00
parent 1e2b303b35
commit 03456fb574
19 changed files with 2158 additions and 704 deletions
+6 -18
View File
@@ -79,21 +79,7 @@ namespace Game.Scripting
foreach (var type in assembly.GetTypes())
{
var attributes = (ScriptAttribute[])type.GetCustomAttributes<ScriptAttribute>();
if (attributes.Empty())
{
var baseType = type.BaseType;
while (baseType != null)
{
if (baseType == typeof(ScriptObject))
{
Log.outWarn(LogFilter.Server, "Script {0} does not have ScriptAttribute", type.Name);
continue;
}
baseType = baseType.BaseType;
}
}
else
if (!attributes.Empty())
{
var constructors = type.GetConstructors();
if (constructors.Length == 0)
@@ -136,14 +122,17 @@ namespace Game.Scripting
switch (type.BaseType.Name)
{
case "SpellScript":
case nameof(SpellScript):
genericType = typeof(GenericSpellScriptLoader<>).MakeGenericType(type);
name = name.Replace("_SpellScript", "");
break;
case "AuraScript":
case nameof(AuraScript):
genericType = typeof(GenericAuraScriptLoader<>).MakeGenericType(type);
name = name.Replace("_AuraScript", "");
break;
case nameof(GameObjectAI):
genericType = typeof(GenericGameObjectScript<>).MakeGenericType(type);
break;
case "SpellScriptLoader":
case "AuraScriptLoader":
case "WorldScript":
@@ -177,7 +166,6 @@ namespace Game.Scripting
Activator.CreateInstance(genericType);
else
Activator.CreateInstance(genericType, new object[] { name }.Combine(attribute.Args));
continue;
default:
genericType = typeof(GenericCreatureScript<>).MakeGenericType(type);