/// <summary> /// /// </summary> /// <param name="method"></param> /// <returns></returns> /// <exception cref="RpcException">Throws when could not get Serializer for any parameter</exception> protected ValueSerializer[] GetValueSerializers(MethodDefinition method) { var serializers = new ValueSerializer[method.Parameters.Count]; var error = false; for (var i = 0; i < method.Parameters.Count; i++) { if (IsNetworkPlayer(method.Parameters[i].ParameterType)) { continue; } try { serializers[i] = ValueSerializerFinder.GetSerializer(method, method.Parameters[i], writers, readers); } catch (SerializeFunctionException e) { logger.Error(e, method.DebugInformation.SequencePoints.FirstOrDefault()); error = true; } catch (ValueSerializerException e) { logger.Error(e.Message, method); error = true; } } // check and log all bad params before throwing RPC if (error) { throw new RpcException($"Could not process Rpc because one or more of its parameter were invalid", method); } return(serializers); }
/// <summary> /// Finds any attribute values needed for this syncvar /// </summary> /// <param name="module"></param> public void ProcessAttributes(Writers writers, Readers readers) { var hook = HookMethodFinder.GetHookMethod(FieldDefinition, OriginalType); Hook = hook; HasHook = hook != null; InitialOnly = GetInitialOnly(FieldDefinition); InvokeHookOnServer = GetFireOnServer(FieldDefinition); ValueSerializer = ValueSerializerFinder.GetSerializer(this, writers, readers); if (!HasHook && InvokeHookOnServer) { throw new HookMethodException("'invokeHookOnServer' is set to true but no hook was implemented. Please implement hook or set 'invokeHookOnServer' back to false or remove for default false.", FieldDefinition); } }