protected override void OnSerializeBinaryModel(PacketMemoryStream stream, Coop_Model_Base model)
    {
        Type modelType = ((PACKET_TYPE)model.c).GetModelType();
        IMessagePackSingleObjectSerializer serializer = context.GetSerializer(modelType);

        serializer.Pack(stream, model);
    }
Ejemplo n.º 2
0
    private void Test4()
    {
        //IL_0050: Unknown result type (might be due to invalid IL or missing references)
        //IL_0055: Unknown result type (might be due to invalid IL or missing references)
        MemoryStream memoryStream = new MemoryStream();
        Coop_Model_EnemyTargetShotEvent coop_Model_EnemyTargetShotEvent = new Coop_Model_EnemyTargetShotEvent();

        int[] array = new int[3]
        {
            1,
            12,
            123
        };
        int[] array2 = array;
        foreach (int num in array2)
        {
            Enemy.RandomShotInfo.TargetInfo targetInfo = new Enemy.RandomShotInfo.TargetInfo();
            targetInfo.rot      = new Quaternion((float)num, (float)(num * 2), (float)(num * 3), (float)(num * 4));
            targetInfo.targetId = num;
            coop_Model_EnemyTargetShotEvent.targets.Add(targetInfo);
        }
        string log = string.Empty;

        log = string.Empty;
        coop_Model_EnemyTargetShotEvent.targets.ForEach(delegate(Enemy.RandomShotInfo.TargetInfo r)
        {
            //IL_001d: Unknown result type (might be due to invalid IL or missing references)
            string text2 = log;
            log          = text2 + "[" + r.rot + "," + r.targetId + "],";
        });
        Log("before target:" + log);
        Type typeFromHandle = typeof(Coop_Model_EnemyTargetShotEvent);
        IMessagePackSingleObjectSerializer serializer = context.GetSerializer(typeFromHandle);

        serializer.Pack(memoryStream, coop_Model_EnemyTargetShotEvent);
        memoryStream.Position = 0L;
        Coop_Model_EnemyTargetShotEvent coop_Model_EnemyTargetShotEvent2 = (Coop_Model_EnemyTargetShotEvent)serializer.Unpack(memoryStream);

        log = string.Empty;
        coop_Model_EnemyTargetShotEvent2.targets.ForEach(delegate(Enemy.RandomShotInfo.TargetInfo r)
        {
            //IL_001d: Unknown result type (might be due to invalid IL or missing references)
            string text = log;
            log         = text + "[" + r.rot + "," + r.targetId + "],";
        });
        Log("after target:" + log);
        string str = JSONSerializer.Serialize(coop_Model_EnemyTargetShotEvent, typeFromHandle);

        Log("json stream:" + str);
    }
Ejemplo n.º 3
0
    private void MsgPack(Type type)
    {
        MemoryStream memoryStream = new MemoryStream();
        object       obj          = Activator.CreateInstance(type);

        Log($"MsgPack:     {obj.GetType().FullName}\nValue:    {obj.ToString()}\nHashCode: {obj.GetHashCode()}\n");
        IMessagePackSingleObjectSerializer serializer = context.GetSerializer(type);

        serializer.Pack(memoryStream, obj);
        Log($"MsgPacked:     {obj.GetType().FullName}\nValue:    {obj.ToString()}\nHashCode: {obj.GetHashCode()}\n");
        memoryStream.Position = 0L;
        object obj2 = serializer.Unpack(memoryStream);

        Log($"MsgUnpack:     {obj2.GetType().FullName}\nValue:    {obj2.ToString()}\nHashCode: {obj2.GetHashCode()}\n");
    }
Ejemplo n.º 4
0
    private void Test2()
    {
        //IL_0043: Unknown result type (might be due to invalid IL or missing references)
        //IL_0095: Unknown result type (might be due to invalid IL or missing references)
        MemoryStream memoryStream = new MemoryStream();
        Coop_Model_ObjectAttackedHitFix coop_Model_ObjectAttackedHitFix = new Coop_Model_ObjectAttackedHitFix();

        coop_Model_ObjectAttackedHitFix.hitPos.x = 1f;
        coop_Model_ObjectAttackedHitFix.hitPos.y = 2.3f;
        coop_Model_ObjectAttackedHitFix.hitPos.z = 3.45f;
        Log("before pos=" + coop_Model_ObjectAttackedHitFix.hitPos);
        Type typeFromHandle = typeof(Coop_Model_ObjectAttackedHitFix);
        IMessagePackSingleObjectSerializer serializer = context.GetSerializer(typeFromHandle);

        serializer.Pack(memoryStream, coop_Model_ObjectAttackedHitFix);
        memoryStream.Position = 0L;
        Coop_Model_ObjectAttackedHitFix coop_Model_ObjectAttackedHitFix2 = (Coop_Model_ObjectAttackedHitFix)serializer.Unpack(memoryStream);

        Log("after pos=" + coop_Model_ObjectAttackedHitFix2.hitPos);
        string str = JSONSerializer.Serialize(coop_Model_ObjectAttackedHitFix, typeFromHandle);

        Log("json stream:" + str);
    }