KeyValues2 0.10.0
dotnet add package KeyValues2 --version 0.10.0
NuGet\Install-Package KeyValues2 -Version 0.10.0
<PackageReference Include="KeyValues2" Version="0.10.0" />
<PackageVersion Include="KeyValues2" Version="0.10.0" />
<PackageReference Include="KeyValues2" />
paket add KeyValues2 --version 0.10.0
#r "nuget: KeyValues2, 0.10.0"
#:package KeyValues2@0.10.0
#addin nuget:?package=KeyValues2&version=0.10.0
#tool nuget:?package=KeyValues2&version=0.10.0
Datamodel.NET is a library which implements the Datamodel structure and Datamodel Exchange (DMX) file format.
Datamodel is a strongly-typed generic data structure designed by Valve Corporation. It is primarily used as a developer storage format for meshes, animations, and maps.
Usage
dotnet add package KeyValues2
using Datamodel;
// Load a file with unknown layout
using var dm = Datamodel.Load("my_file.dmx");
var element = dm.Root;
var value = element.Get<string>("my_property");
// Load a file with a known layout
using var map = Datamodel.Load<CMapRootElement>("fy_pool.vmap");
var root = (CMapRootElement)map.Root;
Debug.Assert(root.IsPrefab == false);
// Layout definition
// Full implementation can be found here:
// https://github.com/ValveResourceFormat/Datamodel.NET/blob/master/Tests/ValveMap.cs
[LowercaseProperties]
class CMapRootElement : Element
{
public bool IsPrefab { get; set; }
public int EditorBuild { get; set; } = 8600;
public int EditorVersion { get; set; } = 400;
}
Features
- Support for all known versions of Valve's
binaryandkeyvalues2DMX encodings - Inline documentation
- Binary codec supports just-in-time attribute loading
- Write your own codecs with the
ICodecinterface - Serialize and deserialize support for Datamodel.Element subclasses
Serialization
var HelloWorld = new Datamodel.Datamodel("helloworld", 1); // must provide a format name (can be anything) and version
HelloWorld.Root = new Datamodel.Element(HelloWorld, "my_root");
HelloWorld.Root["Hello"] = "World"; // any supported attribute type can be assigned
var MyString = HelloWorld.Root.Get<string>("Hello");
HelloWorld.Save("hello world.dmx", "keyvalues2", 1); // must provide an encoding name and version
<--! dmx encoding keyvalues2 1 format helloworld 1>
{
"Hello" "string" "World"
}
Attributes
The following .NET types are supported as Datamodel attributes:
intfloatboolstringbytebyte[]Vector2Vector3Vector4/QuaternionMatrix4x4ulongSystem.TimeSpan
Additionally, the following Datamodel.NET types are supported:
Element(a named collection of attributes)QAngle
IList<T> collections of the above types are also supported. (This can be a bit confusing given that both byte and byte[] are valid attribute types; use the ByteArray type if you run into trouble.)
License
Datamodel.NET is licensed under the MIT License.
The sample .dmx and .vmap files under Tests/Resources are derived from Valve
Corporation game content and are included solely as test fixtures. They are not covered by the MIT
license above and remain the property of Valve Corporation. They are not distributed in the NuGet package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- KeyValues2.ElementFactoryGenerator (>= 0.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on KeyValues2:
| Package | Downloads |
|---|---|
|
ValveResourceFormat
Parser, decompiler, and exporter for Valve's Source 2 resource file formats. Supports models, textures, materials, maps, particles, and more. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on KeyValues2:
| Repository | Stars |
|---|---|
|
ValveResourceFormat/ValveResourceFormat
Source 2 Viewer is an all-in-one tool to browse VPK archives, view, extract, and decompile Source 2 assets, including maps, models, materials, textures, sounds, and more.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.10.0 | 0 | 8/24/2026 |
| 0.9.0 | 38 | 8/22/2026 |
| 0.9.0-beta | 255 | 6/5/2025 |
| 0.8.0 | 25,919 | 5/25/2025 |
| 0.7.0 | 227 | 5/24/2025 |
| 0.5.0 | 4,563 | 9/25/2024 |
| 0.5.0-beta | 6,631 | 3/11/2024 |
| 0.4.0 | 1,184 | 1/22/2024 |
| 0.3.0 | 6,921 | 6/30/2023 |
| 0.2.0 | 372 | 5/3/2023 |