Zehs.REPOLib 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Zehs.REPOLib --version 2.0.0
                    
NuGet\Install-Package Zehs.REPOLib -Version 2.0.0
                    
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="Zehs.REPOLib" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zehs.REPOLib" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Zehs.REPOLib" />
                    
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 Zehs.REPOLib --version 2.0.0
                    
#r "nuget: Zehs.REPOLib, 2.0.0"
                    
#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 Zehs.REPOLib@2.0.0
                    
#: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=Zehs.REPOLib&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Zehs.REPOLib&version=2.0.0
                    
Install as a Cake Tool

REPOLib

GitHub Thunderstore Version Thunderstore Downloads NuGet Version

Library for adding content to R.E.P.O.

Features

  • Registering network prefabs.
  • Registering valuables.
  • Registering items.
  • Registering enemies.
  • Registering levels.
  • ResourcesHelper to help get network prefab IDs.
  • Method to spawn network prefabs. (Which works in both multiplayer and singleplayer)
  • Methods to get valuables and spawn valuables.
  • Methods to get items and spawn items.
  • Methods to get enemies and spawn enemies.
  • Registering custom chat /commands
    • Built-in dev mode commands: Spawn Valuable, Spawn Item, Spawn Enemy
  • Fixing audio mixer groups.
  • Making networked events.
  • Registering features without code using the REPOLib-Sdk.

Usage

<details><summary>Click to expand</summary><br>

Reference REPOLib in your project's .csproj file.

<ItemGroup>
  <PackageReference Include="Zehs.REPOLib" Version="1.*" />
</ItemGroup>

Add REPOLib as a dependency to your plugin class.

[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...
}

<details><summary>Network prefabs</summary><br>

Registering a network prefab.

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    private void Awake()
    {
        // ...

        AssetBundle assetBundle = AssetBundle.LoadFromFile("your_assetbundle_file_path");
        GameObject prefab = assetBundle.LoadAsset<GameObject>("your_network_prefab");

        // Register a network prefab.
        REPOLib.Modules.NetworkPrefabs.RegisterNetworkPrefab(prefab);
    }
}

</details>

<details><summary>Valuables</summary><br>

Registering a valuable.

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    private void Awake()
    {
        // ...

        AssetBundle assetBundle = AssetBundle.LoadFromFile("your_assetbundle_file_path");
        GameObject prefab = assetBundle.LoadAsset<GameObject>("your_valuable_prefab");

        // Register a valuable.
        REPOLib.Modules.Valuables.RegisterValuable(prefab);
    }
}

Registering a valuable to a specific level.

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    private void Awake()
    {
        // ...

        AssetBundle assetBundle = AssetBundle.LoadFromFile("your_assetbundle_file_path");
        GameObject prefab = assetBundle.LoadAsset<GameObject>("your_valuable_prefab");

        // Valuables Presets:
        // "Valuables - Generic"
        // "Valuables - Wizard"
        // "Valuables - Manor"
        // "Valuables - Arctic"

        List<string> presets = new List<string> { "Valuables - Wizard" };

        // Register a valuable.
        REPOLib.Modules.Valuables.RegisterValuable(prefab, presets);
    }
}

</details>

<details><summary>Items</summary><br>

Registering an item.

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    private void Awake()
    {
        // ...

        AssetBundle assetBundle = AssetBundle.LoadFromFile("your_assetbundle_file_path");
        Item item = assetBundle.LoadAsset<Item>("your_item");

        // Register an item.
        REPOLib.Modules.Items.RegisterItem(item);
    }
}

</details>

<details><summary>Enemies</summary><br>

Registering an enemy.

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    private void Awake()
    {
        // ...

        AssetBundle assetBundle = AssetBundle.LoadFromFile("your_assetbundle_file_path");
        EnemySetup enemy = assetBundle.LoadAsset<EnemySetup>("your_enemy_setup");

        // Register an enemy.
        REPOLib.Modules.Enemies.RegisterEnemy(enemy);
    }
}

</details>

<details><summary>Levels</summary><br>

Registering a level.

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    private void Awake()
    {
        // ...

        AssetBundle assetBundle = AssetBundle.LoadFromFile("your_assetbundle_file_path");
        Level level = assetBundle.LoadAsset<Level>("your_level");

        // Register a level.
        REPOLib.Modules.Levels.RegisterLevel(level);
    }
}

</details>

<details><summary>Chat commands</summary><br>

Registering a chat /command.

using REPOLib.Commands;

public static class YourCommand
{
    // ...

    [CommandInitializer]
    public static void Initialize()
    {
        // Perform any setup or caching
    }

    [CommandExecution(
        "Your Command Name",
        "Description of what the command does and how to use it.",
        enabledByDefault: true,
        requiresDeveloperMode: false
        )]
    [CommandAlias("yourcommand")]
    [CommandAlias("yourcmd")]
    public static void Execute(string args)
    {
        // ...
    }
}

</details>

<details><summary>Fixing audio mixer groups</summary><br>

Fixing audio mixer groups on a prefab and their children.

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    private void Awake()
    {
        // ...

        AssetBundle assetBundle = AssetBundle.LoadFromFile("your_assetbundle_file_path");
        GameObject prefab = assetBundle.LoadAsset<GameObject>("your_prefab");

        // Fix the audio mixer groups on a prefab and their children.
        REPOLib.Modules.Utilities.FixAudioMixerGroups(prefab);
    }
}

Registering any features will automatically fix their prefabs audio mixer groups. </details>

<details><summary>Networked events</summary><br>

Creating a networked event.

using ExitGames.Client.Photon;
using REPOLib.Modules;

[BepInPlugin("You.YourMod", "YourMod", "1.0.0")]
[BepInDependency(REPOLib.MyPluginInfo.PLUGIN_GUID, BepInDependency.DependencyFlags.HardDependency)]
public class YourMod : BaseUnityPlugin
{
    // ...

    public static NetworkedEvent ExampleEvent;

    private void Awake()
    {
        // ...

        ExampleEvent = new NetworkedEvent("My Example Event", HandleExampleEvent);
    }

    // EventData is from ExitGames.Client.Photon
    private static void HandleExampleEvent(EventData eventData)
    {
        string message = (string)eventData.CustomData;
        Debug.Log($"Received message from example event: {message}");
    }
}

Calling a networked event.

// The data you are sending through your networked event.
string message = "Hello World!";

// Call networked event on everyone. (This works in singleplayer)
ExampleEvent.RaiseEvent(message, REPOLib.Modules.NetworkingEvents.RaiseAll, SendOptions.SendReliable);

// Call networked event on everyone but yourself. (This works in singleplayer)
ExampleEvent.RaiseEvent(message, REPOLib.Modules.NetworkingEvents.RaiseOthers, SendOptions.SendReliable);

// Call networked event on the master client. (This works in singleplayer)
ExampleEvent.RaiseEvent(message, REPOLib.Modules.NetworkingEvents.RaiseMasterClient, SendOptions.SendReliable);

</details> </details>

Registering features (Valuables, Items, Enemies, etc...) automatically registers their prefabs as a network prefab.

Registering features (Valuables, Items, Enemies, etc...) automatically fixes their prefabs audio mixer groups.

You can enable extended logging in the config settings to get more info about features being registered, custom network prefabs being spawned, and more.

Chat Commands

You must enable DeveloperMode in the config settings to use developer mode commands.

Chat commands currently only work in multiplayer since you need access to the in-game chat to use commands.

This mod comes with a few built-in chat commands:

1. Spawn Valuable /spawnvaluable <name>

This command will spawn a valuable in front of you.
Replace <name> with the name of the valuable prefab.
Names are not case-sensitive.
Example usage: /spawnvaluable diamond
This command has multiple aliases: /spawnval, /sv
<ins>This command requires developer mode to be enabled.</ins>
<ins>This command is host-only!</ins>

2. Spawn Item /spawnitem <name>

This command will spawn an item in front of you.
Replace <name> with the name of the item or item prefab.
Names are not case-sensitive.
Example usage: /spawnitem gun
This command has one alias: /si
<ins>This command requires developer mode to be enabled.</ins>
<ins>This command is host-only!</ins>

3. Spawn Enemy /spawnenemy <name>

This command will spawn an enemy on top of you after a few seconds.
Replace <name> with the name of the enemy or enemy prefab.
Names are not case-sensitive.
Example usage: /spawnenemy huntsman
This command has one alias: /se
<ins>This command requires developer mode to be enabled.</ins>
<ins>This command is host-only!</ins>

Commands can be enabled/disabled in the config settings.

If you are a mod developer and want to add your own custom chat commands to your mod, check the Usage > Chat commands section.

Contribute

Anyone is free to contribute.

https://github.com/ZehsTeam/REPOLib

To set up the project, copy the REPOLib.csproj.user.example file to REPOLib.csproj.user. If needed, change the settings found in that file.

Bundle Loading

REPOLib loads any bundles under the plugins folder with the .repobundle extension. These bundles are then scanned for Mod and Content assets, which allows codeless registration of features in tandem with REPOLib-Sdk.

Bundles are loaded asynchronously, which enables other mods to do their initialization while files are being read from disk, which in turn leads to shorter startup times. Hence, using this system is the preferred way to use this library, even if you're already writing your own plugin code.

If you're writing a mod that interacts with modded content, remember that all REPOLib content may not be registered by game start because of async bundle loading.

To work around this, either do your initialization at a later stage (for example when joining a lobby) or subscribe to the REPOLib.BundleLoader.OnAllBundlesLoaded event (however this requires a dependency on REPOLib).

If you want more control over the loading of bundles, you can use the public APIs from REPOLib.BundleLoader.

using REPOLib;
using UnityEngine;
using System.Collections;

BundleLoader.LoadBundle(
    "/path/to/bundle",
    // Callback when the bundle has finished loading, which is guaranteed to happen before the player joins a lobby.
    // Note that this needs to return an IEnumerator.
    OnBundleLoaded,
    // If this is true, REPOLib will load and register all Content assets from the bundle, as if it was loaded automatically.
    // Defaults to false.
    loadContents: true
);

IEnumerator OnBundleLoaded(AssetBundle bundle) {
    Debug.Log("My bundle was loaded!");
    
    // Do some more (asynchronous) setup logic,
    // or, if loadContents is false, load and register your content
    
    yield break;
}

If you are loading bundles manually, do not give them the .repobundle extension, as that will make them load twice.

Developer Contact

Report bugs, suggest features, or provide feedback:

Discord Server Forum Post
R.E.P.O. Modding Server #released-mods REPOLib

kofi

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Zehs.REPOLib:

Package Downloads
ImperiumRepo

Imperium is a powerful and highly performant all-in-one debugging tool to test and explore game mechanics and functionality in REPO.

PaintedUtils

Utility Mod for REPO

REPOShopLib

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 868 4/28/2025
2.0.1 555 4/6/2025
2.0.0 213 4/1/2025
1.5.0 663 3/24/2025
1.4.2 139 3/15/2025
1.4.1 66 3/15/2025
1.4.0 59 3/15/2025
1.3.1 140 3/13/2025
1.3.0 154 3/12/2025
1.2.0 157 3/10/2025
1.1.0 185 3/8/2025
1.0.2 248 3/3/2025
1.0.1 168 3/3/2025
1.0.0 120 3/3/2025