Weaver IsNetworkBehaviour uses IsDerivedFrom

This commit is contained in:
vis2k 2019-01-01 16:37:56 +01:00
parent 22c97de71a
commit 3f0d3af349

View File

@ -1400,33 +1400,6 @@ static void SetupWriteFunctions()
};
}
static bool IsNetworkBehaviour(TypeDefinition td)
{
if (!td.IsClass)
return false;
// are ANY parent classes NetworkBehaviours
TypeReference parent = td.BaseType;
while (parent != null)
{
if (parent.FullName == NetworkBehaviourType.FullName)
{
return true;
}
try
{
parent = parent.Resolve().BaseType;
}
catch (AssemblyResolutionException)
{
// this can happen for plugins.
//Console.WriteLine("AssemblyResolutionException: "+ ex.ToString());
break;
}
}
return false;
}
public static bool IsDerivedFrom(TypeDefinition td, TypeReference baseClass)
{
if (!td.IsClass)
@ -1463,6 +1436,11 @@ public static bool IsDerivedFrom(TypeDefinition td, TypeReference baseClass)
return false;
}
static bool IsNetworkBehaviour(TypeDefinition td)
{
return IsDerivedFrom(td, NetworkBehaviourType);
}
public static bool ImplementsInterface(TypeDefinition td, TypeReference baseInterface)
{
TypeDefinition typedef = td;