/// <summary> /// /// </summary> /// <param name="field"></param> /// <param name="value"></param> /// <returns></returns> protected Packet GetFieldUpdatePacket( UpdateFieldId updateFieldId, EntityId value ) { UpdatePacket packet = new UpdatePacket(); packet.WriterStream.Write( (byte)UpdateTypes.Values ); EntityId entityId = new EntityId( this.Serial ); entityId.WritePacked( packet ); int iBlocks = ( ( updateFieldId.RawId + 1 ) >> 5 ) + 1; packet.WriterStream.Write( (int)iBlocks ); int iBlocksCheck = ( updateFieldId.RawId >> 5 ) + 1; if ( iBlocks > 1 && iBlocksCheck != iBlocks ) { packet.WriterStream.Fill( 0x00, ( iBlocks - 2 ) * 4 ); packet.WriterStream.Write( (uint)0x80000000 ); packet.WriterStream.Write( (uint)0x00000001 ); } else { packet.WriterStream.Fill( 0x00, ( iBlocks - 1 ) * 4 ); uint uiValue = (uint)( 1 << ( updateFieldId.RawId & 31 ) ); uiValue |= (uint)( uiValue << 1 ); packet.WriterStream.Write( (uint)uiValue ); } packet.WriterStream.Write( value ); packet.EndWrite( 1 ); // Update Count return packet; }
/// <summary> /// /// </summary> public void SendUpdates() { ReaderWriterLockSlimEx.EnterWriteLock( m_LockUpdatePacket ); { m_UpdatePacket.EndWrite( m_UpdateCount ); m_UpdateCount = 0; base.NetState.Send( m_UpdatePacket ); m_UpdatePacket = new UpdatePacket(); } ReaderWriterLockSlimEx.ExitWriteLock( m_LockUpdatePacket ); }
/// <summary> /// /// </summary> /// <param name="field"></param> /// <param name="value"></param> /// <returns></returns> protected Packet GetFieldUpdatePacket( UpdateFieldId updateFieldId, uint value ) { UpdatePacket packet = new UpdatePacket(); packet.WriterStream.Write( (byte)UpdateTypes.Values ); EntityId entityId = new EntityId( this.Serial ); entityId.WritePacked( packet ); int iBlocks = ( updateFieldId.RawId >> 5 ) + 1; packet.WriterStream.Write( (int)iBlocks ); packet.WriterStream.Fill( 0x00, ( iBlocks - 1 ) * 4 ); packet.WriterStream.Write( (uint)( 1 << ( updateFieldId.RawId & 31 ) ) ); packet.WriterStream.Write( (uint)value ); packet.EndWrite( 1 ); // Update Count return packet; }