Exemple #1
0
 public void EncodeValue(GameBitBuffer buffer)
 {
     switch (Attribute.EncodingType)
     {
         case GameAttributeEncoding.Int:
             buffer.WriteInt(Attribute.BitCount, Int);
             break;
         case GameAttributeEncoding.IntMinMax:
             buffer.WriteInt(Attribute.BitCount, Int - Attribute.Min);
             break;
         case GameAttributeEncoding.Float16:
             buffer.WriteFloat16(Float);
             break;
         case GameAttributeEncoding.Float16Or32:
             if (Float >= 65536.0f || -65536.0f >= Float)
             {
                 buffer.WriteBool(false);
                 buffer.WriteFloat32(Float);
             }
             else
             {
                 buffer.WriteBool(true);
                 buffer.WriteFloat16(Float);
             }
             break;
         default:
             throw new Exception("bad voodoo");
     }
 }
        public void EncodeValue(GameBitBuffer buffer)
        {
            switch (Attribute.EncodingType)
            {
            case GameAttributeEncoding.Int:
                buffer.WriteInt(Attribute.BitCount, Int);
                break;

            case GameAttributeEncoding.IntMinMax:
                buffer.WriteInt(Attribute.BitCount, Int - Attribute.Min);
                break;

            case GameAttributeEncoding.Float16:
                buffer.WriteFloat16(Float);
                break;

            case GameAttributeEncoding.Float16Or32:
                if (Float >= 65536.0f || -65536.0f >= Float)
                {
                    buffer.WriteBool(false);
                    buffer.WriteFloat32(Float);
                }
                else
                {
                    buffer.WriteBool(true);
                    buffer.WriteFloat16(Float);
                }
                break;

            default:
                throw new Exception("bad voodoo");
            }
        }