示例#1
0
        public override void    In(ByteBuffer buffer)
        {
            if (this.InResponseStatus(buffer) == true)
            {
                this.typeIndex       = buffer.ReadInt32();
                this.editableMembers = new bool[buffer.ReadInt32()];
                this.netMembers      = new NetField[this.editableMembers.Length];

                for (int i = 0; i < this.netMembers.Length; i++)
                {
                    using (SafeUnwrapByteBuffer unwrap = SafeUnwrapByteBuffer.Get(buffer, this.GetError))
                    {
                        if (unwrap.IsValid() == true)
                        {
                            try
                            {
                                this.editableMembers[i] = buffer.ReadBoolean();
                                this.netMembers[i]      = NetField.Deserialize(buffer);
                            }
                            catch (Exception ex)
                            {
                                InternalNGDebug.LogException("Inspectable type index \"" + this.typeIndex + "\" at static member #" + i + " failed.", ex);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        private NetGameObjectData(ByteBuffer buffer)
        {
            using (SafeUnwrapByteBuffer.Get(buffer, this.GetError))
            {
                this.gameObjectInstanceID = buffer.ReadInt32();
                this.tag      = buffer.ReadUnicodeString();
                this.layer    = buffer.ReadInt32();
                this.isStatic = buffer.ReadBoolean();

                int length = buffer.ReadInt32();

                this.components = new NetComponent[length];

                for (int i = 0; i < length; i++)
                {
                    try
                    {
                        this.components[i] = NetComponent.Deserialize(buffer);
                    }
                    catch (Exception ex)
                    {
                        InternalNGDebug.LogException("GameObject failed on Component " + (i + 1) + "/" + length + ".", ex);
                        throw;
                    }
                }
            }
        }
示例#3
0
        private ArrayData(ByteBuffer buffer, Type fieldType)
        {
            using (SafeUnwrapByteBuffer unwrap = SafeUnwrapByteBuffer.Get(buffer, this.GetError))
            {
                this.serverType   = fieldType;
                this.originLength = buffer.ReadInt32();

                if (this.originLength == -1)
                {
                    this.isNull = true;
                }
                else
                {
                    this.isBigArray = buffer.ReadBoolean();

                    if (this.isBigArray == false)
                    {
                        string typeHandlerType = buffer.ReadUnicodeString();

                        if (string.IsNullOrEmpty(typeHandlerType) == false)
                        {
                            TypeHandler subHandler = TypeHandlersManager.GetTypeHandler(typeHandlerType);

                            if (subHandler != null)
                            {
                                TypeSignature typeSignature = (TypeSignature)buffer.ReadByte();

                                if (typeSignature != TypeSignature.Null)
                                {
                                    Type subType = TypeHandlersManager.GetClientType(this.serverType, typeSignature);

                                    this.array = Array.CreateInstance(subHandler.type, this.originLength);

                                    for (int i = 0; i < this.originLength; i++)
                                    {
                                        try
                                        {
                                            this.array.SetValue(subHandler.Deserialize(buffer, subType), i);
                                        }
                                        catch (Exception ex)
                                        {
                                            InternalNGDebug.LogException("Array of type " + fieldType.Name + " (" + subType + ") at " + i + " failed.", ex);
                                            throw;
                                        }
                                    }
                                }
                            }
                            else                             // Client does not know how to deserialize the element.
                            {
                                unwrap.ForceFallback();
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        private ClientClass(ByteBuffer buffer)
        {
            using (SafeUnwrapByteBuffer.Get(buffer, this.GetError))
            {
                int length = buffer.ReadInt32();

                if (length > -1)
                {
                    this.fields = new Field[length];
                    for (int i = 0; i < this.fields.Length; i++)
                    {
                        this.fields[i] = new Field(NetField.Deserialize(buffer));
                    }
                }
            }
        }
示例#5
0
        private NetGameObject(ByteBuffer buffer)
        {
            using (SafeUnwrapByteBuffer.Get(buffer, this.GetError))
            {
                this.active     = buffer.ReadBoolean();
                this.name       = buffer.ReadUnicodeString();
                this.instanceID = buffer.ReadInt32();

                int length = buffer.ReadInt32();

                this.children = new NetGameObject[length];
                for (int i = 0; i < length; i++)
                {
                    this.children[i] = new NetGameObject(buffer);
                }
            }
        }
示例#6
0
        private NetComponent(ByteBuffer buffer)
        {
            using (SafeUnwrapByteBuffer.Get(buffer, this.GetError))
            {
                this.instanceID = buffer.ReadInt32();
                buffer.ReadBooleans(out this.togglable, out this.deletable);
                this.type = Type.GetType(buffer.ReadUnicodeString());
                this.name = buffer.ReadUnicodeString();

                int length = buffer.ReadInt32();

                this.fields = new NetField[length];

                for (int i = 0; i < length; i++)
                {
                    try
                    {
                        this.fields[i] = NetField.Deserialize(buffer);
                    }
                    catch (Exception ex)
                    {
                        InternalNGDebug.LogException("Component \"" + this.name + "\" failed on field " + (i + 1) + "/" + length + ".", ex);
                        throw;
                    }
                }

                length = buffer.ReadInt32();

                this.methods = new NetMethod[length];

                for (int i = 0; i < length; i++)
                {
                    try
                    {
                        this.methods[i] = NetMethod.Deserialize(buffer);
                    }
                    catch (Exception ex)
                    {
                        InternalNGDebug.LogException("Component \"" + this.name + "\" failed on method " + (i + 1) + "/" + length + ".", ex);
                        throw;
                    }
                }
            }
        }
示例#7
0
        private NetField(ByteBuffer buffer)
        {
            using (SafeUnwrapByteBuffer unwrap = SafeUnwrapByteBuffer.Get(buffer, this.GetError))
            {
                this.fieldType = Type.GetType(buffer.ReadUnicodeString());
                this.name      = buffer.ReadUnicodeString();
                this.isPublic  = buffer.ReadBoolean();

                string typeHandlerType = buffer.ReadUnicodeString();

                if (string.IsNullOrEmpty(typeHandlerType) == false)
                {
                    this.handler = TypeHandlersManager.GetTypeHandler(typeHandlerType);

                    if (this.handler != null)
                    {
                        this.typeSignature = (TypeSignature)buffer.ReadByte();
                        this.fieldType     = this.fieldType ?? TypeHandlersManager.GetClientType(this.handler.type, this.typeSignature);

                        if (this.typeSignature != TypeSignature.Null)
                        {
                            try
                            {
                                this.value = this.handler.Deserialize(buffer, this.fieldType ?? TypeHandlersManager.GetClientType(this.handler.type, this.typeSignature));
                            }
                            catch (Exception ex)
                            {
                                InternalNGDebug.LogException("Member \"" + this.name + "\" of type \"" + this.fieldType + "\" failed.", ex);
                                throw;
                            }
                        }
                    }
                    else                     // Client does not know how to deserialize this field.
                    {
                        unwrap.ForceFallback();
                    }
                }
            }
        }
示例#8
0
        private UnityObject(ByteBuffer buffer)
        {
            using (SafeUnwrapByteBuffer.Get(buffer, this.GetError))
            {
                this.type = Type.GetType(buffer.ReadUnicodeString());

                // In case of corrupted data.
                if (this.type == null)
                {
                    this.type = typeof(Object);
                }

                this.gameObjectInstanceID = buffer.ReadInt32();

                if (this.gameObjectInstanceID != -1)
                {
                    this.instanceID = buffer.ReadInt32();
                    if (this.instanceID != 0)
                    {
                        this.name = buffer.ReadUnicodeString();
                    }
                }
            }
        }