The BinaryKV3 class represents a binary KeyValues3 data block.
Properties
Gets the deserialized KeyValues3 data.
Gets the encoding identifier for this KV3 data.
Gets the format identifier for this KV3 data.
Methods
GetKV3File
Gets the KeyValues3 data as a KV3File object.
A KV3File object containing the data and format.
IsBinaryKV3 (static)
Checks if the given magic number represents a binary KV3 format.
The magic number to check.
True if the magic number is a valid binary KV3 format.
ConvertBinaryKV3ToText (static)
Converts binary KV3 data to text format. This method is exposed for unmanaged callers.
Pointer to the binary KV3 data.
Length of the binary data.
Pointer to the text representation of the KV3 data.
Constants
Magic number for VKV3 format.
Magic number for KV3 version 1.
Magic number for KV3 version 2.
Magic number for KV3 version 3.
Magic number for KV3 version 4.
Magic number for KV3 version 5.
Usage Example
var resource = new Resource();
var binaryKV3 = resource.DataBlock as BinaryKV3;
if (binaryKV3 != null)
{
Console.WriteLine($"Format: {binaryKV3.Format}");
Console.WriteLine($"Encoding: {binaryKV3.Encoding}");
// Access the data
var data = binaryKV3.Data;
Console.WriteLine($"Root properties: {data.Properties.Count}");
// Iterate through properties
foreach (var property in data.Properties)
{
Console.WriteLine($"{property.Key}: {property.Value}");
}
// Get specific properties
if (data.ContainsKey("m_name"))
{
var name = data.GetProperty<string>("m_name");
Console.WriteLine($"Name: {name}");
}
// Get arrays
var arrayData = data.GetArray("m_someArray");
foreach (var item in arrayData)
{
Console.WriteLine($"Array item: {item}");
}
// Convert to KV3File for text output
var kv3File = binaryKV3.GetKV3File();
using var writer = new StringWriter();
kv3File.WriteText(new IndentedTextWriter(writer));
Console.WriteLine(writer.ToString());
}
// Check if data is binary KV3
using var stream = File.OpenRead("data.vdata_c");
using var reader = new BinaryReader(stream);
var magic = reader.ReadUInt32();
if (BinaryKV3.IsBinaryKV3(magic))
{
Console.WriteLine("This is a binary KV3 file");
}