Example #1
0
        public void WorldAction(ForwardFunctionCall ffc, WorldInfo info)
        {
            if (!ValidateWorldInfo(info))
            {
                return;
            }

            MyAssert.Assert(world != null);
            ffc.Apply(world);
            ffc.Apply(worldHook);
        }
Example #2
0
 protected override void ProcessWorldMessage(MessageType mt, Stream stm, Node n, WorldInfo inf)
 {
     if (mt == MessageType.WORLD_VAR_INIT)
     {
         WorldInitializer wrld = Serializer.Deserialize <WorldInitializer>(stm);
         OnNewWorldVar(wrld);
     }
     else if (mt == MessageType.WORLD_VAR_CHANGE)
     {
         ForwardFunctionCall ffc = ForwardFunctionCall.Deserialize(stm, typeof(World));
         worlds.At(inf.position).WorldAction(ffc, inf);
     }
     else
     {
         throw new Exception(Log.StDump(mt, inf, "unexpected"));
     }
 }
Example #3
0
        public static ForwardFunctionCall Deserialize(Stream stm, Type t)
        {
            ForwardFunctionCall ffc = new ForwardFunctionCall();

            ffc.functionName = Serializer.Deserialize <string>(stm);

            MethodInfo mb = t.GetMethod(ffc.functionName);

            ParameterInfo[] param = mb.GetParameters();
            ffc.argumemts = new object[param.Length];

            for (int i = 0; i < param.Length; ++i)
            {
                ffc.argumemts[i] = Serializer.Deserialize(stm, param[i].ParameterType);
            }

            return(ffc);
        }
Example #4
0
        IMessage HandleMethodCall(IMethodCallMessage methodCall)
        {
            if (HasAttribute <Forward>(methodCall.MethodBase))
            {
                ForwardFunctionCall ffc = new ForwardFunctionCall()
                {
                    functionName = methodCall.MethodName, argumemts = methodCall.InArgs
                };
                onCall.Invoke(ffc);
            }


            //try
            //{
            var result = methodCall.MethodBase.Invoke(obj, methodCall.InArgs);

            return(new ReturnMessage(result, null, 0, methodCall.LogicalCallContext, methodCall));
            //}
            //catch (TargetInvocationException invocationException)
            //{
            //    var exception = invocationException.InnerException;
            //    return new ReturnMessage(exception, methodCall);
            //}
        }