marchc1 / Source.NET
An open-source Source Engine replica, written in C#, capable of joining real Garry's Mod servers to some extent (very much so an alpha right now)
View on GitHubAI Architecture Analysis
This repository is indexed by RepoMind. By analyzing marchc1/Source.NET in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewSource.NET Join our Discord Table of Contents > What is this? > Goals > Credits & Thanks > Structure >> Stage 0: External Dependencies + Global Usings >> Stage 1: Engine Common + Tier Libraries >> Stage 2: Pre-Engine Components >> Stage 3: Engine Main >> Stage 4: Post-Engine Components >> Stage 5: Game Realms >> Stage 6: Executables > API Notes > Future Plans What is this? This is an open source clone of the Source Engine, based on RaphaelIT7's Source Engine branch, written in C#. It aims to be as compatible as possible with Source Engine's formats and protocols, more specifically targetting Garry's Mod compatibility. It can currently connect to real Garry's Mod servers. Development is currently done by connecting to a local Garry's Mod SRCDS instance - if you wish to contribute, you can set one up relatively easily with these instructions. Note that most entities aren't implemented yet - your best luck is a vanilla, -noworkshop -noaddons SRCDS server on gm_flatgrass. Goals I originally started this project mostly to learn more about the Source Engine, but due to public interest I've made it open-sourced in the case that it helps others and could be further worked on by people smarter than I (especially in the graphics department). In an ideal world, it could serve as a playable Garry's Mod client - but that is a herculean task (and even that feels like an understatement) - and would require a lot more hands than just me to even be remotely feasible. Credits & Thanks • Valve for obvious reasons • RaphaelIT7 for various contributions & unintentionally getting me down the rabbit-hole of Source Engine tomfoolery in the first place • maddnias for his work on SharpVPK, and antim0118 for his changes which fixed some incompatibilities • Leystryku for his work on leysourceengineclient - which has served as a very good baseline for networking implementations when I was struggling Building You need the following: • A C#-compatible IDE obviously (Visual Studio 2022 is what I use for now, although I'm sure it would work fine on Rider or VS Code) • The .NET 9.0 SDK • A license for Garry's Mod on Steam You will also need to symlink the Half Life 2/Garry's Mod vpk files or copy them directly. A Powershell file is provided in Game.Assets to automatically symlink the necessary VPK's and map files - if someone wants to write an equivalent Linux script for doing this, that would be very appreciated. Structure The engine is very similar to Source, with various deviations where I saw fit, to better match .NET/C# implementation details. Things like UtlVector/UtlMap/UtlLinkedList are replaced with their C# equivalents. Each "stage" described here builds on each other incrementally - ie. stage 3 can include stage 2 and stage 1 libraries, stage 2 can include stage 1 libraries, but stage 1 cannot include stage 2 libraries, etc. Libraries can include other libraries within their own stage if needed - but is done only in a few cases (VTF including Common and Bitmap, for example.) There are currently seven stages. The Solution is organized via Solution Folders as well in this order. > [!NOTE] > AppFramework in Source is instead replaced by Microsoft.Extensions.DependencyInjection. --- Stage 0: External Dependencies + Global Usings Various external dependencies & components, along with various non-project-specific C# files, which allow defining global using statements for a project. For example, almost every library uses this in its .csproj file to add the various type definitions/global static methods/constants: --- Stage 1: Engine Common + Tier Libraries The Source SDK provides a "public" folder which contains the vast majority of engine interfaces, enumerations, etc. These are statically linked at compile time. There are also dynamic libraries (tier0) and static libraries (tier1, tier2) which various components use shared functionality from. In Source.NET, these are all merged into one single common dynamic library, since C# doesn't support static linking. > [!NOTE] > A future goal is to further separate these files - tier0 and tier1 being their own individual projects, for example, rather than tier0 and tier1 functionality being contained within the Source.Common dll. > [!NOTE] > This stage also includes a couple other libraries, such as bitmap/common - which also are static libraries in C++, but in our case, are dynamic libraries. Libraries • ##### Bitmap • Bitmap processing • Image format utilities • ##### Common • Public interfaces and enumerations • Various helper components • Tier0 functionality - Dbg, Spew, Asserts, etc • Tier1 functionality - ConVars, implementation of ICVar happens here instead of a vstdlib equiv • ##### VTF • VTF texture parsing • Implementation of IVTFTexture • ##### VPK • A fork of SharpVPK with changes from antim0118's branch • Parses VPK files, only really used by the filesystem implementation --- Stage 2: Pre-Engine Components These are components of the engine which the engine includes directly. This is a rare case as most things are implemented in the post-engine stage, but things like VGUI and VGUI controls have to be in this stage. Libraries • ##### GUI • Defines Panel : IPanel, which is the root of all elements • Implementation of IVGui • Implementation of IVGuiInput • Implementation of ISchemeManager • Implementation of ILocalize • ##### GUI.Controls • Defines the various GUI controls • Also defines AnimationControllers, BuildGroups, NavGroups, etc. --- Stage 3: Engine Main This is only the engine core. Everything else beyond this point are extensions which are included by the launcher/dedicated projects. Libraries • ##### Engine • Core engine logic • Cbuf, Cmd, Key, ModelLoader, Render, Scr, Sound, Sys, View, etc. • Implementation of ICommandLine • Datatable encoding definitions • Implementation of IEngineAPI and EngineBuilder to build one --- Stage 4: Post-Engine Components These are the implementations of various systems the engine uses. A lot of d…