From 3f0d3af3495fc04aad4ff42e729b67e2e63f07ec Mon Sep 17 00:00:00 2001 From: vis2k Date: Tue, 1 Jan 2019 16:37:56 +0100 Subject: [PATCH] Weaver IsNetworkBehaviour uses IsDerivedFrom --- Mirror/Weaver/Weaver.cs | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/Mirror/Weaver/Weaver.cs b/Mirror/Weaver/Weaver.cs index 46d3f0f1e..33e96ac3e 100644 --- a/Mirror/Weaver/Weaver.cs +++ b/Mirror/Weaver/Weaver.cs @@ -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;