You are viewing a potentially older version of this package. View all versions.
Zehs-REPOLib-1.3.0 icon

REPOLib

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

Date uploaded 11 hours ago
Version 1.3.0
Download link Zehs-REPOLib-1.3.0.zip
Downloads 5112
Dependency string Zehs-REPOLib-1.3.0

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2100 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2100

README

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 custom chat /commands
    • Built-in dev mode commands: Spawn Valuable, Spawn Item
  • Registering features without code using the REPOLib-Sdk.

Usage

Click to expand

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
{
    // ...
}
Network prefabs

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);
    }
}
Valuables

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);
    }
}
Items

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);
    }
}
Enemies

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);
    }
}
Chat commands

Registering a chat /command.

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)
    {
        // ...
    }
}

[!NOTE] Registering valuables, items, and enemies automatically registers their prefabs as a network prefab.

[!IMPORTANT] You should only register network prefabs and features from your plugin's awake function.

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

[!TIP] You can enable developer mode in the config settings to get access to the /spawnvaluable <name> and /spawnitem <name> chat commands (/sv and /si for short). HOST ONLY!

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.

Developer Contact

Report bugs, suggest features, or provide feedback:

kofi

CHANGELOG

v1.3.0

  • Added more validation when registering features to prevent conflicts and errors.
  • Added support for registering custom chat /commands. (#5)
    • Added some built-in dev mode commands: /spawnvaluable <name>, /spawnitem <name> (/sv and /si for short)
      • You must enable DeveloperMode mode in the config settings to use dev mode commands.
      • Note: Dev mode commands are host-only!

v1.2.0

  • Added support for registering items.
  • Added support for registering enemies. (#2)
  • Added support for registering features without code using the REPOLib-Sdk. (#3)
  • Features now register network prefabs to have their prefabId match the Resources folder structure.
  • You can no longer manually pass in a prefabId when registering a valuable.

v1.1.0

  • You can now register valuables to specific levels. (#1)
    • Valuables Presets: Valuables - Generic, Valuables - Wizard, Valuables - Manor, Valuables - Arctic

v1.0.2

v1.0.1

  • Updated mod icon.

v1.0.0

  • Initial release.