コード例 #1
0
        public void Pack(Packer stream, object obj)
        {
            var v = (Vector2Int)obj;

            Int32Serializer.PackDirect(stream, v.x);
            Int32Serializer.PackDirect(stream, v.y);
        }
コード例 #2
0
        public void Pack(Packer packer, object obj)
        {
            var meta = (Packer.MetaType)obj;

            Int32Serializer.PackDirect(packer, meta.id);
            StringSerializer.PackDirect(packer, meta.type);
        }
コード例 #3
0
 public static void PackDirect(Packer packer, Packer.MetaType[] meta)
 {
     Int32Serializer.PackDirect(packer, meta.Length);
     for (int i = 0; i < meta.Length; ++i)
     {
         MetaTypeSerializer.PackDirect(packer, meta[i]);
     }
 }
コード例 #4
0
        public void Pack(Packer packer, object obj)
        {
            var rootType = obj.GetType();
            var typeId   = packer.GetMetaTypeId(rootType);

            Int32Serializer.PackDirect(packer, typeId);

            this.Pack(packer, obj, rootType);
        }
コード例 #5
0
        public void Pack(Packer packer, object obj)
        {
            var meta = (Packer.MetaType[])obj;

            Int32Serializer.PackDirect(packer, meta.Length);
            for (int i = 0; i < meta.Length; ++i)
            {
                packer.PackInternal(meta[i]);
            }
        }
コード例 #6
0
        public static void PackDirect(Packer packer, string obj)
        {
            var length = obj.Length;

            Int32Serializer.PackDirect(packer, length);
            for (int i = 0; i < obj.Length; ++i)
            {
                CharSerializer.PackDirect(packer, obj[i]);
            }
        }
コード例 #7
0
        public void Pack(Packer packer, object obj)
        {
            var arr = (System.Array)obj;

            Int32Serializer.PackDirect(packer, arr.Length);

            for (int i = 0; i < arr.Length; ++i)
            {
                packer.PackInternal(arr.GetValue(i));
            }
        }
コード例 #8
0
        public void Pack(Packer packer, object obj)
        {
            var sentinel = (IDisposeSentinel)obj;
            var type     = sentinel.GetType();

            Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(type.GetGenericTypeDefinition()));
            Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(type.GenericTypeArguments[0]));
            Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(type.GenericTypeArguments[1]));

            packer.PackInternal(sentinel.GetData());
            Int64Serializer.PackDirect(packer, sentinel.GetTick());
        }
コード例 #9
0
        public void Pack(Packer packer, object obj)
        {
            var dict = (ME.ECS.Collections.IDictionaryInt)obj;
            var type = dict.GetType();

            Int32Serializer.PackDirect(packer, dict.Count);

            Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(type.GenericTypeArguments[0]));
            Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(type.GetGenericTypeDefinition()));

            foreach (DictionaryEntry entry in dict)
            {
                packer.PackInternal(entry.Key);
                packer.PackInternal(entry.Value);
            }
        }
コード例 #10
0
        public void Pack(Packer packer, object obj)
        {
            var pack = (ME.ECS.StatesHistory.HistoryEvent)obj;

            Int64Serializer.PackDirect(packer, pack.tick);
            Int32Serializer.PackDirect(packer, pack.order);
            Int32Serializer.PackDirect(packer, pack.rpcId);
            Int32Serializer.PackDirect(packer, pack.localOrder);
            Int32Serializer.PackDirect(packer, pack.objId);
            Int32Serializer.PackDirect(packer, pack.groupId);
            BooleanSerializer.PackDirect(packer, pack.storeInHistory);

            if (pack.parameters != null)
            {
                packer.WriteByte(1);
                var serializer = new ObjectArraySerializer();
                serializer.Pack(packer, pack.parameters);
            }
            else
            {
                packer.WriteByte(0);
            }
        }
コード例 #11
0
 public static void PackDirect(Packer packer, byte[] arr)
 {
     Int32Serializer.PackDirect(packer, arr.Length);
     packer.WriteBytes(arr);
 }
コード例 #12
0
        public void Pack(Packer packer, object obj)
        {
            var arr  = (IList)obj;
            var type = arr.GetType();

            Int32Serializer.PackDirect(packer, arr.Count);

            if (type.IsArray == true)
            {
                var rank = type.GetArrayRank();
                if (rank > 1)
                {
                    packer.WriteByte(2);
                }
                else
                {
                    packer.WriteByte(1);
                }

                Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(type.GetElementType()));

                if (rank > 1)
                {
                    Int32Serializer.PackDirect(packer, rank);
                    var arrData = (System.Array)arr;

                    for (int j = 0; j < rank; ++j)
                    {
                        Int32Serializer.PackDirect(packer, arrData.GetLength(j));
                    }

                    void WrapDimension(int[] ids, int currentDimension)
                    {
                        if (currentDimension == rank)
                        {
                            packer.PackInternal(arrData.GetValue(ids));
                        }
                        else
                        {
                            for (int i = 0, length = arrData.GetLength(currentDimension); i < length; i++)
                            {
                                ids[currentDimension] = i;
                                WrapDimension(ids, currentDimension + 1);
                            }
                        }
                    }

                    WrapDimension(new int[rank], 0);
                }
                else
                {
                    for (int i = 0; i < arr.Count; ++i)
                    {
                        packer.PackInternal(arr[i]);
                    }
                }
            }
            else
            {
                packer.WriteByte(0);
                Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(arr.GetType().GenericTypeArguments[0]));
                Int32Serializer.PackDirect(packer, packer.GetMetaTypeId(arr.GetType().GetGenericTypeDefinition()));

                for (int i = 0; i < arr.Count; ++i)
                {
                    packer.PackInternal(arr[i]);
                }
            }
        }
コード例 #13
0
 public void Pack(Packer packer, object obj)
 {
     Int32Serializer.PackDirect(packer, (RPCId)obj);
 }
コード例 #14
0
 public static void PackDirect(Packer packer, Packer.MetaType meta)
 {
     Int32Serializer.PackDirect(packer, meta.id);
     StringSerializer.PackDirect(packer, meta.type);
 }