ReadDouble() public method

Reads a 64 bit floating point value written using Write(Double)
public ReadDouble ( ) : double
return double
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt32();
     this.MessageTime = im.ReadDouble();
     this.Health = im.ReadFloat();
     this.MaxHealth = im.ReadFloat();
 }
 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
     this.Id = im.ReadInt32();
     this.OldPosition = im.ReadInt32();
     this.NewPosition = im.ReadInt32();
 }
 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
     this.Id = im.ReadInt32();
     this.EquipmentPosition = im.ReadInt32();
     this.InventoryPosition = im.ReadInt32();
 }
 public void Decode(NetIncomingMessage im)
 {
     Id = im.ReadInt64();
     MessageTime = im.ReadDouble();
     /*this.Position = im.ReadVector3();
     this.Velocity = im.ReadVector3();*/
     Rotation = im.ReadSingle();
 }
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt32();
     this.MessageTime = im.ReadDouble();
     this.MoveUp = im.ReadBoolean();
     this.MoveDown = im.ReadBoolean();
     this.MoveLeft = im.ReadBoolean();
     this.MoveRight = im.ReadBoolean();
 }
Example #6
0
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt32();
     this.MessageTime = im.ReadDouble();
     this.Position = im.ReadVector3();
     /*this.MoveUp = im.ReadBoolean();
     this.MoveDown = im.ReadBoolean();
     this.MoveLeft = im.ReadBoolean();
     this.MoveRight = im.ReadBoolean();*/
     this.Object = Utility.Serializer.DeserializeObjectFromString<Model.Object.Object>(im.ReadString());
 }
Example #7
0
 public void Decode(NetIncomingMessage im)
 {
     this.ServerName = im.ReadString();
     this.Description = im.ReadString();
     this.Intro = im.ReadString();
     this.Online = im.ReadByte();
     int roomsLength = im.ReadByte();
     for (int i = 0; i < roomsLength; i++)
     {
         Rooms.Add(new LobbySaveData(im.ReadString(), im.ReadInt16(), im.ReadString(), im.ReadByte(), im.ReadInt16(), im.ReadDouble()));
     }
 }
Example #8
0
        public void Decode(NetIncomingMessage im)
        {
            this.Id = im.ReadInt32();
            this.MessageTime = im.ReadDouble();

            //this.Region = Utility.Serializer.DeserializeObjectFromString<Model.Map.Region.Region>(im.ReadString());
            //this.Region.Parent = Model.Map.World.World.world;

            this.Position = im.ReadVector3();

            this.RegionEnum = (Model.Map.Region.RegionEnum)im.ReadInt32();
        }
        public void Decode(NetIncomingMessage im)
        {
            this.MessageTime = im.ReadDouble();
            int var_CountFactions = im.ReadInt32();

            this.factions = new List<Model.Behaviour.Member.Faction>();
            for (int i = 0; i < var_CountFactions; i++)
            {
                this.factions.Add(Utility.Serializer.DeserializeObjectFromString<Model.Behaviour.Member.Faction>(im.ReadString()));
            }
            this.value = new int[var_CountFactions, var_CountFactions];
            for (int y = 0; y < var_CountFactions; y++)
            {
                for (int x = 0; x < var_CountFactions; x++)
                {
                    this.value[y, x] = im.ReadInt32();
                    this.factions[y].BehaviourMember.Add(new BehaviourItem<Model.Behaviour.Member.Faction>(this.factions[x], this.value[y, x]));
                }
            }
        }
Example #10
0
        public void Decode(NetIncomingMessage im)
        {
            this.Id = im.ReadInt32();
            this.MessageTime = im.ReadDouble();
            this.RegionId = im.ReadInt32();

            //this.Chunk = Utility.Serializer.DeserializeObjectFromString<Model.Map.Chunk.Chunk>(im.ReadString());
            //this.Chunk.Parent = Model.Map.World.World.world.getRegion(this.RegionId);
            //this.Chunk.setAllNeighboursOfBlocks();

            this.Position = im.ReadVector3();

            Model.Map.Chunk.Chunk var_Chunk =  Model.Map.World.World.world.getChunkAtPosition(Position);

            if (var_Chunk != null)
            {
                if (var_Chunk.IsRequested)
                {
                    var_Chunk.IsRequested = false;
                }
            }
        }
Example #11
0
        public void Decode(NetIncomingMessage im)
        {
            this.MessageTime = im.ReadDouble();
            this.ChunkId = im.ReadInt32();

            Microsoft.Xna.Framework.Vector3 var_Position = im.ReadVector3();

            this.Block = GameLibrary.Model.Map.World.World.world.getBlockAtCoordinate(var_Position);

            int var_Size = Enum.GetValues(typeof(GameLibrary.Model.Map.Block.BlockLayerEnum)).Length;

            if (this.Block != null)
            {
                if (this.Block.IsRequested)
                {
                    for (int i = 0; i < var_Size; i++)
                    {
                        this.Block.Layer[i] = (Model.Map.Block.BlockEnum)im.ReadInt32();
                    }
                }
                this.Block.IsRequested = false;
            }
        }
 /// <summary>
 /// Handles an incoming entity component message
 /// </summary>
 /// <param name="message">Raw network message</param>
 /// <returns>An IncomingEntityComponentMessage object</returns>
 public IncomingEntityComponentMessage HandleEntityComponentNetworkMessage(NetIncomingMessage message)
 {
     var componentFamily = (ComponentFamily) message.ReadByte();
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_bool:
                 messageParams.Add(message.ReadBoolean());
                 break;
             case NetworkDataType.d_byte:
                 messageParams.Add(message.ReadByte());
                 break;
             case NetworkDataType.d_sbyte:
                 messageParams.Add(message.ReadSByte());
                 break;
             case NetworkDataType.d_ushort:
                 messageParams.Add(message.ReadUInt16());
                 break;
             case NetworkDataType.d_short:
                 messageParams.Add(message.ReadInt16());
                 break;
             case NetworkDataType.d_int:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_uint:
                 messageParams.Add(message.ReadUInt32());
                 break;
             case NetworkDataType.d_ulong:
                 messageParams.Add(message.ReadUInt64());
                 break;
             case NetworkDataType.d_long:
                 messageParams.Add(message.ReadInt64());
                 break;
             case NetworkDataType.d_float:
                 messageParams.Add(message.ReadFloat());
                 break;
             case NetworkDataType.d_double:
                 messageParams.Add(message.ReadDouble());
                 break;
             case NetworkDataType.d_string:
                 messageParams.Add(message.ReadString());
                 break;
             case NetworkDataType.d_byteArray:
                 int length = message.ReadInt32();
                 messageParams.Add(message.ReadBytes(length));
                 break;
         }
     }
     return new IncomingEntityComponentMessage(componentFamily, messageParams);
 }
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt64();
     this.CardIndex = im.ReadInt16();
     this.MessageTime = im.ReadDouble();
 }
Example #14
0
 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
     this.Position = im.ReadVector3();
 }
 private List<object> UnPackParams(NetIncomingMessage message)
 {
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32()); //Cast from int, because enums are ints.
                 break;
             case NetworkDataType.d_bool:
                 messageParams.Add(message.ReadBoolean());
                 break;
             case NetworkDataType.d_byte:
                 messageParams.Add(message.ReadByte());
                 break;
             case NetworkDataType.d_sbyte:
                 messageParams.Add(message.ReadSByte());
                 break;
             case NetworkDataType.d_ushort:
                 messageParams.Add(message.ReadUInt16());
                 break;
             case NetworkDataType.d_short:
                 messageParams.Add(message.ReadInt16());
                 break;
             case NetworkDataType.d_int:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_uint:
                 messageParams.Add(message.ReadUInt32());
                 break;
             case NetworkDataType.d_ulong:
                 messageParams.Add(message.ReadUInt64());
                 break;
             case NetworkDataType.d_long:
                 messageParams.Add(message.ReadInt64());
                 break;
             case NetworkDataType.d_float:
                 messageParams.Add(message.ReadFloat());
                 break;
             case NetworkDataType.d_double:
                 messageParams.Add(message.ReadDouble());
                 break;
             case NetworkDataType.d_string:
                 messageParams.Add(message.ReadString());
                 break;
             case NetworkDataType.d_byteArray:
                 int length = message.ReadInt32();
                 messageParams.Add(message.ReadBytes(length));
                 break;
         }
     }
     return messageParams;
 }
 /// <summary>
 /// The decode.
 /// </summary>
 /// <param name="im">
 /// The im.
 /// </param>
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt64();
     this.MessageTime = im.ReadDouble();
     this.Position = im.ReadVector2();
     this.Velocity = im.ReadVector2();
     this.Rotation = im.ReadSingle();
     this.Path = im.ReadInt32();
 }
Example #17
0
            private static Object ReadValue(NetIncomingMessage packet, TypeCode typeCode)
            {
                Object value;

                switch (typeCode)
                {
                    case TypeCode.Empty:
                        throw new NotSupportedException("Empty is not a supported type for variables");

                    case TypeCode.Object:
                        throw new NotSupportedException("Object is not a supported type for variables");

                    case TypeCode.DBNull:
                        throw new NotSupportedException("DBNull is not a supported type for variables");

                    case TypeCode.Boolean:
                        value = packet.ReadBoolean();
                        break;

                    case TypeCode.Char:
                        throw new NotSupportedException("Char is not a supported type for variables");

                    case TypeCode.SByte:
                        value = packet.ReadSByte();
                        break;

                    case TypeCode.Byte:
                        value = packet.ReadByte();
                        break;

                    case TypeCode.Int16:
                        value = packet.ReadInt16();
                        break;

                    case TypeCode.UInt16:
                        value = packet.ReadUInt16();
                        break;

                    case TypeCode.Int32:
                        value = packet.ReadInt32();
                        break;

                    case TypeCode.UInt32:
                        value = packet.ReadUInt32();
                        break;

                    case TypeCode.Int64:
                        value = packet.ReadInt64();
                        break;

                    case TypeCode.UInt64:
                        value = packet.ReadUInt64();
                        break;

                    case TypeCode.Single:
                        value = packet.ReadSingle();
                        break;

                    case TypeCode.Double:
                        value = packet.ReadDouble();
                        break;

                    case TypeCode.Decimal:
                        throw new NotSupportedException("Decimal is not a supported type for variables");

                    case TypeCode.DateTime:
                        throw new NotSupportedException("DateTime is not a supported type for variables");

                    case TypeCode.String:
                        value = packet.ReadString();
                        break;

                    default:
                        throw new NotSupportedException(String.Format("Unknown type {0} is not a supported type for variables", typeCode));
                }

                return value;
            }
Example #18
0
 /// <summary>
 /// Handles a single incoming data packet from a client.
 /// </summary>
 /// <param name="msg">The packet to handle.</param>
 private void HandleDataPacket( NetIncomingMessage msg )
 {
     MsgType type = (MsgType)msg.PeekByte();
     switch ( type )
     {
         case MsgType.Debug:
             msg.ReadByte();
             string output = "[Dbg Msg From " + NetUtility.ToHexString( msg.SenderConnection.RemoteUniqueIdentifier ) + "]: "
                 + msg.ReadString();
             WriteConsoleMessage( output );
             break;
         case MsgType.ReqLobbyList:
             SendLobbyList( msg.SenderConnection );
             break;
         case MsgType.ReqJoinLobby:
             msg.ReadByte();
             int lobbyID = msg.ReadByte();
             string playerName = msg.ReadString();
             MsgErrorCode err;
             if ( ! AddPlayerToLobby( msg.SenderConnection, lobbyID, playerName, out err ) )
             {
                 NetOutgoingMessage errMsg = server.CreateMessage();
                 errMsg.Write( (byte)MsgType.Error );
                 errMsg.Write( (byte)err );
                 server.SendMessage( errMsg, msg.SenderConnection, NetDeliveryMethod.Unreliable );
             }
             else
             {
                 playerLobbies[msg.SenderConnection.RemoteUniqueIdentifier] = lobbyID;
             }
             break;
         case MsgType.ReqLeaveLobby:
             if ( playerLobbies.ContainsKey( msg.SenderConnection.RemoteUniqueIdentifier ) )
             {
                 int playerLobby = playerLobbies[msg.SenderConnection.RemoteUniqueIdentifier];
                 if ( playerLobby != NO_LOBBY )
                 {
                     lock ( lobbyLock )
                     {
                         lobbies[playerLobby].RemovePlayer( msg.SenderConnection );
                     }
                 }
             }
             break;
         case MsgType.ReqCreateLobby:
             msg.ReadByte();
             string lName = msg.ReadString();
             int maxCap = msg.ReadInt32();
             double matchDur = msg.ReadDouble();
             string pName = msg.ReadString();
             ServiceLobbyCreateRequest( msg.SenderConnection, lName, pName, maxCap, matchDur );
             break;
         default:
             int pLobby = playerLobbies[msg.SenderConnection.RemoteUniqueIdentifier];
             if ( pLobby != NO_LOBBY )
             {
                 lobbies[pLobby].messageQueue.Enqueue( msg );
             }
             break;
     }
 }
Example #19
0
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt32();
     this.MessageTime = im.ReadDouble();
     this.ECommandType = (Commands.ECommandType) im.ReadInt32();
 }
 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
     this.Id = im.ReadInt32();
     this.Body = Utility.Serializer.DeserializeObjectFromString<Body>(im.ReadString());
 }
 /// <summary>
 /// The decode.
 /// </summary>
 /// <param name="im">
 /// The im.
 /// </param>
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt64();
     this.MessageTime = im.ReadDouble();
     this.Position = im.ReadVector2();
     this.Velocity = im.ReadVector2();
     this.FiredByPlayer = im.ReadBoolean();
     this.FiredById = im.ReadInt64();
 }
Example #22
0
 public void Decode(NetIncomingMessage im)
 {
     this.PlayerObject = Utility.Serializer.DeserializeObjectFromString<PlayerObject>(im.ReadString());
     this.MessageTime = im.ReadDouble();
 }
Example #23
0
        public void UpdateFromPacket( NetIncomingMessage packet )
        {
            // Update the towers
            for ( int i = 0; i < Towers.Length; ++i )
            {
                Towers[i].UpdateFromPacket( packet );
            }

            // Update the active characters
            int index = -1;
            int charCount = packet.ReadByte();
            for ( int i = 0, lastIndex = 0; i < charCount; ++i )
            {
                index = packet.ReadByte();

                // Set characters between active chars to inactive
                for ( int j = lastIndex ; j != index; ++j )
                {
                    characters[j].Active = false;
                }
                characters[index].Active = true;
                characters[index].UpdateFromPacket( packet );
                lastIndex = index + 1;
            }

            // Set the rest of the characters (past the last active index) to inactive
            for ( int i = index + 1; i < characters.Length; ++i )
            {
                characters[i].Active = false;
            }

            // Update the active spells
            index = -1;
            int spellCount = packet.ReadInt32();
            for ( int i = 0, lastIndex = 0; i < spellCount; ++i )
            {
                index = packet.ReadInt32();
                for ( int j = lastIndex; j != index; ++j )
                {
                    spells[j].Active = false;
                }
                spells[index].Active = true;
                spells[index].UpdateFromPacket( packet );
                lastIndex = index + 1;
            }

            // Set the rest of the spells (past the last active index) to inactive
            for ( int i = index + 1; i < spells.Length; ++i )
            {
                spells[i].Active = false;
            }

            // Update the active pickups
            index = -1;
            int pickupCount = packet.ReadInt32();
            for ( int i = 0, lastIndex = 0; i < pickupCount; ++i )
            {
                index = packet.ReadInt32();
                for ( int j = lastIndex; j != index; ++j )
                {
                    pickups[j].Active = false;
                }
                pickups[index].Active = true;
                pickups[index].UpdateFromPacket( packet );
                lastIndex = index + 1;
            }

            // Set the rest of the pickups (past the last active index) to inactive
            for ( int i = index + 1; i < pickups.Length; ++i )
            {
                pickups[i].Active = false;
            }

            // Read the round clock from the packet
            roundClock = TimeSpan.FromMilliseconds( packet.ReadDouble() );

            // Read the scores
            for ( int i = 0; i < scores.Length; ++i )
            {
                scores[i] = packet.ReadInt32();
            }
        }
Example #24
0
 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
 }