Skip to content

Blazing fast cross-platform demo parser library for Counter-Strike 2, written in C#.

License

Notifications You must be signed in to change notification settings

SurgeODDR/demofile-net

 
 

Repository files navigation

DemoFile.Net NuGet Build status

DemoFile.Net is a blazing fast demo parser library for Counter-Strike 2, written in C#. It is cross platform, and can be used from Windows, Mac or Linux.

Screenshot of DemoFile.Net

Easy discoverability of available data through your IDE's inbuilt autocompletion:

Features

Feature Availability
CSTV / GOTV demos ✅ Full support
POV demos ➖ Support planned
Game events (e.g. player_death) ✅ Full support
Entity updates (player positions, grenades, etc.) ✅ Full support
Seeking forwards/backwards through the demo ✅ Full support

Examples

Note: This library is still under heavy development and the API is likely to change significantly before v1.0

using DemoFile;

internal class Program
{
    public static async Task Main(string[] args)
    {
        var path = args.SingleOrDefault() ?? throw new Exception("Expected a single argument: <path to .dem>");

        var demo = new DemoParser();
        demo.Source1GameEvents.PlayerDeath += e =>
        {
            Console.WriteLine($"{e.Attacker?.PlayerName} [{e.Weapon}] {e.Player?.PlayerName}");
        };

        await demo.ReadAllAsync(File.OpenRead(path));

        Console.WriteLine("\nFinished!");
    }
}

See also the examples/ folder.

Benchmarks

On an M1 MacBook Pro, DemoFile.Net can read a full competitive game (just under 1 hour of game time) in 1.5 seconds. This includes parsing all entity data (player positions, velocities, weapon tracking, grenades, etc).

Method Runtime Mean Error StdDev
ParseDemo .NET 8.0 1.501 s 0.0047 s 0.0042 s

Author and acknowledgements

DemoFile.Net is developed by Saul Rennison. The development of this library would not have been possible without demoparser by LaihoE and Manta by Dotabuff, the latter of which depends on the efforts of a number of people:

A modified version of Source2Gen by neverlosecc is used to statically generate the game schema classes and enums.

See ACKNOWLEDGEMENTS for license information.

About

Blazing fast cross-platform demo parser library for Counter-Strike 2, written in C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%