mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-12-11 20:15:10 +01:00
Account for classes that are subclasses of subclasses of QSBItem
This commit is contained in:
parent
accd958dc1
commit
0461aab31c
@ -65,9 +65,26 @@ public class ItemManager : WorldObjectManager
|
|||||||
assemblies = assemblies.Append(QSBCore.QSBNHAssembly);
|
assemblies = assemblies.Append(QSBCore.QSBNHAssembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the class inherits from QSBItem<T>, this will return what T is else null
|
||||||
|
static Type GetTypeFromQSBItem(Type type)
|
||||||
|
{
|
||||||
|
if (type.IsInterface || type.IsAbstract || type.BaseType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(QSBItem<>))
|
||||||
|
{
|
||||||
|
return type.BaseType.GetGenericArguments()[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetTypeFromQSBItem(type.BaseType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return assemblies.SelectMany(x => x.GetTypes())
|
return assemblies.SelectMany(x => x.GetTypes())
|
||||||
.Where(x => !x.IsInterface && !x.IsAbstract && x.BaseType != null && x.BaseType.IsGenericType && x.BaseType.GetGenericTypeDefinition() == typeof(QSBItem<>))
|
.Select(GetTypeFromQSBItem)
|
||||||
.Select(x => x.BaseType.GetGenericArguments()[0])
|
.Where(x => x != null)
|
||||||
.OrderBy(x => x.FullName);
|
.OrderBy(x => x.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user