diff --git a/Ragon.Client/Sources/Utils/CompressorExtension.cs b/Ragon.Client/Sources/Utils/CompressorExtension.cs new file mode 100644 index 0000000..3b3fcfc --- /dev/null +++ b/Ragon.Client/Sources/Utils/CompressorExtension.cs @@ -0,0 +1,27 @@ +using Ragon.Client.Compressor; +using Ragon.Protocol; + +namespace Ragon.Client.Utils; + +public static class CompressorExtension +{ + public static float Read(this FloatCompressor compressor, RagonBuffer buffer) + { + return compressor.Decompress(buffer.Read(compressor.RequiredBits)); + } + + public static void Write(this FloatCompressor compressor, RagonBuffer buffer, float value) + { + buffer.Write(compressor.Compress(value), compressor.RequiredBits); + } + + public static float Read(this IntCompressor compressor, RagonBuffer buffer) + { + return compressor.Decompress(buffer.Read(compressor.RequiredBits)); + } + + public static void Write(this IntCompressor compressor, RagonBuffer buffer, int value) + { + buffer.Write(compressor.Compress(value), compressor.RequiredBits); + } +} \ No newline at end of file