From eff92872367b718533ab79ca1d9b24377ae6b901 Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Thu, 28 Jun 2018 22:47:33 -0500 Subject: [PATCH] Simplify command invocation --- .../Runtime/NetworkBehaviour.cs | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/Unity-Technologies-networking/Runtime/NetworkBehaviour.cs b/Unity-Technologies-networking/Runtime/NetworkBehaviour.cs index 4059067de..cdfe2529d 100644 --- a/Unity-Technologies-networking/Runtime/NetworkBehaviour.cs +++ b/Unity-Technologies-networking/Runtime/NetworkBehaviour.cs @@ -345,20 +345,12 @@ internal bool InvokeCommandDelegate(int cmdHash, NetworkReader reader) return false; } - if (GetType() != inv.invokeClass) + if (inv.invokeClass.IsInstanceOfType(this)) { - if (GetType().IsSubclassOf(inv.invokeClass)) - { - // allowed, commands function is on a base class. - } - else - { - return false; - } + inv.invokeFunction(this, reader); + return true; } - - inv.invokeFunction(this, reader); - return true; + return false; } internal bool InvokeRpcDelegate(int cmdHash, NetworkReader reader) @@ -374,20 +366,12 @@ internal bool InvokeRpcDelegate(int cmdHash, NetworkReader reader) return false; } - if (GetType() != inv.invokeClass) + if (inv.invokeClass.IsInstanceOfType(this)) { - if (GetType().IsSubclassOf(inv.invokeClass)) - { - // allowed, rpc function is on a base class. - } - else - { - return false; - } + inv.invokeFunction(this, reader); + return true; } - - inv.invokeFunction(this, reader); - return true; + return false; } internal bool InvokeSyncEventDelegate(int cmdHash, NetworkReader reader)