示例#1
0
 public override void Read(NetBuffer msg)
 {
     worldZoneId     = msg.ReadUInt64();
     sceneBuildIndex = msg.ReadInt32();
     ip   = msg.ReadString();
     port = msg.ReadInt32();
 }
        private void ReadFieldState(NetBuffer msg, Field field)
        {
            int bitsForPlayerIndex = NetUtility.BitsToHoldUInt((uint)(field.GetPlayers().GetCount() - 1));

            FieldCellSlot[] slots = field.GetCells().slots;
            for (int i = 0; i < slots.Length; ++i)
            {
                FieldCellSlot slot = slots[i];

                bool hasStaticCell = msg.ReadBoolean();
                if (hasStaticCell)
                {
                    byte type = msg.ReadByte(BITS_FOR_STATIC_CELL);
                    switch (type)
                    {
                    case CELL_BRICK:
                    {
                        Debug.Assert(slot.ContainsBrick());
                        break;
                    }

                    case CELL_POWERUP:
                    {
                        int powerup = msg.ReadInt32(BITS_FOR_POWERUP);
                        if (slot.staticCell == null)
                        {
                            field.AddCell(new PowerupCell(powerup, slot.cx, slot.cy));
                        }
                        else if (!slot.staticCell.IsPowerup())
                        {
                            field.RemoveCell(slot.staticCell);
                            field.AddCell(new PowerupCell(powerup, slot.cx, slot.cy));
                        }
                        break;
                    }

                    case CELL_FLAME:
                    {
                        int playerIndex = msg.ReadInt32(bitsForPlayerIndex);
                        if (slot.staticCell == null)
                        {
                            Player player = field.GetPlayers().Get(playerIndex);
                            field.AddCell(new FlameCell(player, slot.cx, slot.cy));
                        }
                        else if (!slot.staticCell.IsFlame())
                        {
                            Player player = field.GetPlayers().Get(playerIndex);
                            field.RemoveCell(slot.staticCell);
                            field.AddCell(new FlameCell(player, slot.cx, slot.cy));
                        }
                        break;
                    }
                    }
                }
                else if (slot.staticCell != null && !slot.staticCell.IsSolid())
                {
                    field.RemoveCell(slot.staticCell);
                }
            }
        }
示例#3
0
        public void Unpack(NetBuffer netBuffer)
        {
            Client.ServiceLocator.GetService <LightManagerService>().Component.Lights.Clear();

            this.Dark = netBuffer.ReadBoolean();

            if (this.Dark)
            {
                Client.ServiceLocator.GetService <LightManagerService>().Component.AmbientColor = new Color(100, 100, 100, 20);
            }
            else
            {
                Client.ServiceLocator.GetService <LightManagerService>().Component.AmbientColor = Color.White;
            }

            int layerCount = netBuffer.ReadInt32();

            for (int i = 0; i < layerCount; i++)
            {
                string layerName = netBuffer.ReadString();
                int    lIndex    = netBuffer.ReadInt32();
                var    layer     = new Layer(this.Dimensions, lIndex, layerName);
                layer.Unpack(netBuffer);
                _layers.Add(layerName, layer);
            }
        }
示例#4
0
 public void Read(NetBuffer buffer)
 {
     SendTime   = buffer.ReadSingle();
     CurrentRTT = buffer.ReadInt32();
     RemoteTime = buffer.ReadSingle();
     RemoteTick = buffer.ReadInt32();
 }
        public static Point ReadPoint32(this NetBuffer buffer)
        {
            int x = buffer.ReadInt32();
            int y = buffer.ReadInt32();

            return(new Point(x, y));
        }
示例#6
0
        public static Point3D ReadPoint3D(this NetBuffer msg)
        {
            int x = msg.ReadInt32();
            int y = msg.ReadInt32();
            int z = msg.ReadInt32();

            return(new Point3D(x, y, z));
        }
示例#7
0
 public void Read(NetBuffer buffer)
 {
     Scope          = (ChatScope)buffer.ReadByte();
     Message        = buffer.ReadString();
     Name           = buffer.ReadString();
     ClientIndex    = buffer.ReadInt32();
     SupporterLevel = buffer.ReadInt32();
 }
示例#8
0
 public void Read(NetBuffer buffer)
 {
     EntityId     = buffer.ReadInt32();
     EntityTypeId = buffer.ReadByte();
     ChangedTick  = buffer.ReadInt32();
     ChangedTime  = buffer.ReadSingle();
     PropDataSize = buffer.ReadInt32();
     PropData     = buffer.ReadBytes(PropDataSize);
 }
        /* the server reads data from a client */
        protected ClientPacket ReadClientPacket(NetBuffer msg)
        {
            ClientPacket packet;

            packet.id = msg.ReadInt32();
            packet.lastAckServerPacketId = msg.ReadInt32();
            packet.actions = msg.ReadInt32((int)PlayerAction.Count);

            return(packet);
        }
示例#10
0
        public override void Read(NetBuffer im)
        {
            base.Read(im);
            int c = im.ReadInt32();

            for (int i = 0; i < c; ++i)
            {
                int id = im.ReadInt32();
                FollowerId.Add(id);
            }
        }
示例#11
0
        public void Read(NetBuffer im)
        {
            MessagePacketId = im.ReadInt64();
            Number          = im.ReadInt32();
            int length = im.ReadInt32();

            if (length != 0)
            {
                Bytes = im.ReadBytes(length);
            }
        }
示例#12
0
        public static MapObject Unpack(NetBuffer netBuffer)
        {
            // can we view it?
            if (!netBuffer.ReadBoolean())
            {
                return(null);
            }

            var   textureName     = Path.ChangeExtension(netBuffer.ReadString(), null);
            var   sourceRectangle = new Rectangle(netBuffer.ReadInt32(), netBuffer.ReadInt32(), netBuffer.ReadInt32(), netBuffer.ReadInt32());
            var   color           = new Color(new Vector4(netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte()));
            var   position        = new Vector2(netBuffer.ReadFloat(), netBuffer.ReadFloat());
            var   animated        = netBuffer.ReadBoolean();
            float zIndex          = netBuffer.ReadSingle();
            var   frameTime       = netBuffer.ReadInt32();

            var sprite =
                new AnimatedSprite(Client.ServiceLocator.GetService <ContentManagerService>().ContentManager.LoadTexture2D(
                                       Constants.FILEPATH_ROOT + textureName))
            {
                SourceRectangle = sourceRectangle,
                Color           = color,
                Position        = position,
                LayerDepth      = zIndex
            };

            var mapObject = new MapObject(sprite, animated)
            {
                FrameTime = frameTime
            };


            // is it a light source?
            if (netBuffer.ReadBoolean() == true)
            {
                var lightColor = new Color(new Vector4(netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte(), netBuffer.ReadByte()));
                var radius     = netBuffer.ReadFloat();

                PointLight pointLight = new PointLight
                {
                    Position  = position,
                    Scale     = new Vector2(radius),
                    Color     = lightColor,
                    Intensity = .7f,
                };

                Client.ServiceLocator.GetService <LightManagerService>().Component.Lights.Add(pointLight);

                mapObject.Light = pointLight;
            }

            return(mapObject);
        }
示例#13
0
        public override void Read(NetBuffer im)
        {
            base.Read(im);
            int c = im.ReadInt32();

            for (int i = 0; i < c; ++i)
            {
                int objId = im.ReadInt32();
                int folId = im.ReadInt32();
                Followers.Add(new KeyValuePair <int, int>(objId, folId));
            }
        }
示例#14
0
 public void Read(NetBuffer buffer)
 {
     Fields.HostTime      = buffer.ReadSingle();
     Fields.PacketId      = buffer.ReadInt32();
     Fields.ClientIndex   = buffer.ReadInt32();
     Fields.Buttons       = (InputActions)buffer.ReadInt32();
     Fields.Origin        = buffer.ReadVector3();
     Fields.Angles        = buffer.ReadVector3();
     Fields.Velocity      = buffer.ReadVector3();
     Fields.BaseVelocity  = buffer.ReadVector3();
     Fields.MousePosition = buffer.ReadVector3();
     Fields.HoveredEntity = buffer.ReadInt32();
 }
示例#15
0
 public void Read(NetBuffer buffer)
 {
     DamageInfo.WeaponId         = buffer.ReadInt32();
     DamageInfo.AttackerEntityId = buffer.ReadInt32();
     DamageInfo.VictimEntityId   = buffer.ReadInt32();
     DamageInfo.Amount           = buffer.ReadInt32();
     DamageInfo.ResultedInDeath  = buffer.ReadBoolean();
     DamageInfo.HitNormal        = buffer.ReadVector3();
     DamageInfo.HitPoint         = buffer.ReadVector3();
     DamageInfo.Viewpunch        = buffer.ReadSingle();
     DamageInfo.HitArea          = (HitboxArea)buffer.ReadByte();
     DamageInfo.DamageType       = (DamageType)buffer.ReadByte();
 }
示例#16
0
        public void Read(NetBuffer buffer)
        {
            Files.Clear();
            SyncType = (FileSyncType)buffer.ReadByte();

            if (SyncType == FileSyncType.Manifest)
            {
                DownloadUrl = buffer.ReadString();
            }

            if (SyncType == FileSyncType.Manifest ||
                SyncType == FileSyncType.Request)
            {
                var fileCount = buffer.ReadInt32();
                for (int i = 0; i < fileCount; i++)
                {
                    var fi = new FSFileInfo();
                    fi.RelativePath = buffer.ReadString();
                    fi.WorkshopId   = buffer.ReadUInt64();

                    if (SyncType == FileSyncType.Manifest)
                    {
                        fi.Hash = buffer.ReadBytes(16);
                    }
                    Files.Add(fi);
                }
            }
        }
 public void Deserialize(NetBuffer pPacketReader)
 {
     name     = pPacketReader.ReadString();
     subspace = pPacketReader.ReadInt32();
     clock    = pPacketReader.ReadDouble();
     unk      = pPacketReader.ReadBool();
 }
示例#18
0
        public void Read(NetBuffer buffer)
        {
            EventType   = (PlayerEventType)buffer.ReadByte();
            ClientIndex = buffer.ReadInt32();
            TeamNumber  = buffer.ReadByte();
            Latency     = buffer.ReadInt32();
            DisplayName = buffer.ReadString();
            SteamID     = buffer.ReadUInt64();

            switch (EventType)
            {
            case PlayerEventType.Spectate:
                SpecTarget = buffer.ReadInt32();
                break;
            }
        }
示例#19
0
        public void Read(NetBuffer im)
        {
            MetaData = im.ReadString();
            int l = im.ReadInt32();

            Data = im.ReadBytes(l);
        }
示例#20
0
        private static Relation _ReadRelation(NetBuffer buffer)
        {
            RelationFlags flags = (RelationFlags)buffer.ReadByte();
            int           value = (flags != RelationFlags.Any) ? buffer.ReadInt32() : 0;

            return(new Relation(flags, value));
        }
示例#21
0
 public override void Read(NetBuffer m)
 {
     netid             = m.ReadUInt64();
     netComponentId    = m.ReadByte();
     originalMessageId = m.ReadInt32();
     messageData       = NetSerialize.ReadBytes(m);
 }
示例#22
0
 public void Read(NetBuffer buffer)
 {
     File        = buffer.ReadString().ToLower();
     TotalLength = buffer.ReadInt64();
     ChunkLength = buffer.ReadInt32();
     Data        = buffer.ReadBytes(ChunkLength);
     Temporary   = buffer.ReadBoolean();
 }
示例#23
0
 internal LocalHostData(NetBuffer buffer)
 {
     gameType          = buffer.ReadString();
     gameName          = buffer.ReadString();
     gameMode          = buffer.ReadString();
     gameLevel         = buffer.ReadString();
     connectedPlayers  = buffer.ReadInt32();
     playerLimit       = buffer.ReadInt32();
     passwordProtected = (buffer.ReadByte() == 1);
     dedicatedServer   = (buffer.ReadByte() == 1);
     useNat            = (buffer.ReadByte() == 1);
     useProxy          = (buffer.ReadByte() == 1);
     comment           = buffer.ReadString();
     platform          = buffer.ReadString();
     timestamp         = DateTime.FromBinary(buffer.ReadInt64());
     internalEndpoint  = buffer.ReadEndPoint();
 }
示例#24
0
        public void Read(NetBuffer buffer)
        {
            DataEntries.Clear();

            Label = buffer.ReadString();
            byte entryCount = buffer.ReadByte();

            for (int i = 0; i < entryCount; i++)
            {
                var entry = new DataEntry();
                entry.Type = (DataType)buffer.ReadByte();
                switch (entry.Type)
                {
                case DataType.Bool:
                    entry.BoolValue = buffer.ReadBoolean();
                    break;

                case DataType.Int:
                    entry.IntValue = buffer.ReadInt32();
                    break;

                case DataType.Float:
                    entry.FloatValue = buffer.ReadSingle();
                    break;

                case DataType.Byte:
                    entry.ByteValue = buffer.ReadByte();
                    break;

                case DataType.String:
                    entry.StringValue = buffer.ReadString();
                    break;

                case DataType.Vector3:
                    entry.Vector3Value = buffer.ReadVector3();
                    break;

                case DataType.Bytes:
                    var byteCount = buffer.ReadInt32();
                    entry.BytesValue = buffer.ReadBytes(byteCount);
                    break;
                }

                DataEntries.Add(entry);
            }
        }
示例#25
0
文件: PushMessage.cs 项目: sgww/cozy
        public override void Read(NetBuffer im)
        {
            base.Read(im);
            int c = im.ReadInt32();

            for (int i = 0; i < c; ++i)
            {
                var objid      = im.ReadInt32();
                var followerid = im.ReadInt32();
                FollowerList.Add(new KeyValuePair <int, int>(objid, followerid));
            }
            c = im.ReadInt32();
            for (int i = 0; i < c; ++i)
            {
                var follower = im.ReadInt32();
                FightFollowerList.Add(follower);
            }
        }
示例#26
0
        /// <inheritdoc />
        public void ReadFromBuffer(NetBuffer buffer)
        {
            RoomId        = buffer.ReadString();
            YourPlayer    = buffer.ReadInt32();
            CurrentPlayer = new Guid(buffer.ReadBytes(16));

            Players = new Player[buffer.ReadInt32()];
            for (var i = 0; i < Players.Length; i++)
            {
                Players[i] = buffer.ReadClass <Player>();
            }

            Board = new GamePiece[buffer.ReadInt32()];
            for (var i = 0; i < Board.Length; i++)
            {
                Board[i] = buffer.ReadClass <GamePiece>();
            }
        }
示例#27
0
        public static int ReadEntityLight(this NetBuffer message, ref CBody cBody, ref CTransform ctransform,
                                          ref string modelname, ref bool isPlayer)
        {
            int id = message.ReadInt32();

            cBody.Velocity      = message.ReadVector3();
            ctransform.Position = message.ReadVector3();
            ctransform.Rotation = message.ReadMatrix();
            return(id);
        }
 /// <summary>
 /// Reads a <see cref="TimeSpan"/> value from the <see cref="NetBuffer"/>.
 /// </summary>
 /// <param name="message">The buffer to write to</param>
 /// <param name="highPrecision">
 /// Indicates whether the <see cref="TimeSpan"/> will be read using high precision (ticks) or not (milliseconds)
 /// </param>
 /// <remarks>
 /// High precision allows full <see cref="TimeSpan"/> range, otherwise it will be limited to "+-24.20:31:23.647"
 /// (+-24 days, 20 hours, 31 minutes, 23 seconds and 647 milliseconds)
 /// </remarks>
 /// <returns>A <see cref="TimeSpan"/> value</returns>
 public static TimeSpan ReadTimeSpan(this NetBuffer message, bool highPrecision)
 {
     if (highPrecision)
     {
         return(TimeSpan.FromTicks(message.ReadInt64()));
     }
     else
     {
         return(TimeSpan.FromMilliseconds(message.ReadInt32()));
     }
 }
示例#29
0
        public static int ReadEntity(this NetBuffer message, ref CBody cBody, ref CTransform ctransform,
                                     ref string modelname, ref bool isPlayer)
        {
            int id = message.ReadInt32();

            isPlayer   = message.ReadBoolean();
            cBody      = ReadCBody(message);
            ctransform = ReadCTransform(message);
            modelname  = message.ReadString();
            return(id);
        }
示例#30
0
        public static byte[] ReadBytes(NetBuffer buffer)
        {
            byte[] data = null;
            int    len  = buffer.ReadInt32();

            if (len > 0)
            {
                data = buffer.ReadBytes(len);
            }

            return(data);
        }
		/// <summary>
		/// Read a Point
		/// </summary>
		public static Point ReadPoint(NetBuffer buffer)
		{
			return new Point(buffer.ReadInt32(), buffer.ReadInt32());
		}