ProjectLiberator.NetGen 1.0.0-rc1

This is a prerelease version of ProjectLiberator.NetGen.
dotnet add package ProjectLiberator.NetGen --version 1.0.0-rc1
                    
NuGet\Install-Package ProjectLiberator.NetGen -Version 1.0.0-rc1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProjectLiberator.NetGen" Version="1.0.0-rc1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProjectLiberator.NetGen" Version="1.0.0-rc1" />
                    
Directory.Packages.props
<PackageReference Include="ProjectLiberator.NetGen">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProjectLiberator.NetGen --version 1.0.0-rc1
                    
#r "nuget: ProjectLiberator.NetGen, 1.0.0-rc1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProjectLiberator.NetGen@1.0.0-rc1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProjectLiberator.NetGen&version=1.0.0-rc1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=ProjectLiberator.NetGen&version=1.0.0-rc1&prerelease
                    
Install as a Cake Tool

UCS NetGen

This source generator replaces the "Net Gen" tool from the Unturned 3 SDK for modules that want to use Unturned's networking.

Enums

Enums decorated with the [NetEnum] attribute will cause extension methods to be generated for NetPakReader and NetPakWriter for reading and writing the enum from a binary buffer.

This enum...

[NetEnum]
public enum PlayerMode
{
    Walking,
    Running,
    Eating,
    Driving,
    Drinking
}

will result in the following extension methods:

reader.ReadEnum(out PlayerMode mode);
writer.WriteEnum(PlayerMode.Driving);

These methods are generated in the hidden PlayerMode_NetEnum class.

SteamCalls (Receivers)

Methods decorated with the [SteamCall(...)] attribute will cause a method to generate read and write methods for invoking it.

For example, this method...

public static class MyMethods
{
    [SteamCall(ESteamCallValidation.ONLY_FROM_SERVER)]
    public static void Method(int param1, Vector3 param2) { }
}

Will generate a read and write method in the MyMethods_NetMethods class:

[NetInvokableGeneratedMethodAttribute(
    nameof(MyMethods.Method),
    ENetInvokableGeneratedMethodPurpose.Read
)]
public static void Method_Read(in ClientInvocationContext context)
{
    NetPakReader reader = context.reader;

    // read param1, param2

    MyMethods.Method(param1, param2);
}

[NetInvokableGeneratedMethodAttribute(
    nameof(MyMethods.Method),
    ENetInvokableGeneratedMethodPurpose.Write
)]
public static void Method_Write(NetPakWriter writer, int param1, Vector3 param2)
{
    // write param1, param2
}

Extensions

The source generator supports extension blocks or classic extension methods to extend in-game classes with instance methods.

public static class PlayerExtensions
{
    private static readonly ServerStaticMethod<string> SendAddPlayer
        = ServerStaticMethod<string>.Get(ReceiveAddPlayer);
    
    private static readonly ServerInstanceMethod<float> SendFlyRequest
        = ServerInstanceMethod<float>.Get(typeof(PlayerExtensions), nameof(ReceiveFlyRequest));
    
    extension(Player player)
    {
        public void ClientRequestFly(float speed)
        {
            SendFlyRequest.Invoke(player.GetNetId(), ENetReliability.Unreliable, speed);
        }

        [SteamCall(ESteamCallValidation.ONLY_FROM_OWNER)]
        public void ReceiveFlyRequest(float speed)
        {
            player.StartFlying(flySpeed: speed);
        }
        
        public static void ClientAddPlayer(string name)
        {
            SendAddPlayer.Invoke(ENetReliability.Reliable, name);
        }

        [SteamCall(ESteamCallValidation.SERVERSIDE)]
        public static void ReceiveAddPlayer(string name)
        {
            Provider.clients.Add(new Player(name));
        }
    }
}

For a type to be an instance, it must be registered with a NetId.

To support ONLY_FROM_OWNER validation, it must also either derive from SteamCaller or define an accessible SteamChannel channel property or field.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ProjectLiberator.NetGen:

Package Downloads
DanielWillett.UnturnedStandardModuleNetworking

Code and analyzers for USMN.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-rc1 107 7/10/2026

Initial release.