You are viewing a potentially older version of this package. View all versions.
Kai09TA-REPOUpgradeAPI-1.1.0 icon

REPOUpgradeAPI

Small-scale API for manipulating player upgrade stats.

Date uploaded a week ago
Version 1.1.0
Download link Kai09TA-REPOUpgradeAPI-1.1.0.zip
Downloads 7124
Dependency string Kai09TA-REPOUpgradeAPI-1.1.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


πŸ‡ΊπŸ‡Έ REPOUpgradeAPI – Player Upgrade Sync API (Dependency Mod)

This API was originally created for my personal mod projects, but separating it as a standalone module made development easier, so I decided to publish it in case others find it useful.

If you need to reach me, I'm available in the R.E.P.O Modding Server on Discord: https://discord.gg/vPJtKhYAFe


REPOUpgradeAPI is a lightweight framework that provides a clean and safe way to synchronize player upgrades across host and clients. It handles RPC dispatching, synchronization logic, and UI refresh internally, so mods can focus only on calling simple API methods.


πŸ”§ Basic Usage

using REPOUpgradeAPI;

public class ExampleMod : BaseUnityPlugin
{
    void Start()
    {
        // Increase Jump upgrade by +1
        UpgradeAPI.Add(UpgradeType.Jump, 1);

        // Set Sprint upgrade to level 3
        UpgradeAPI.Set(UpgradeType.Sprint, 3);
    }
}

Only UpgradeAPI.Add() and UpgradeAPI.Set() are needed. All networking, syncing, and local UI updates are handled internally.


πŸ“‚ API Summary

● Add

UpgradeAPI.Add(UpgradeType type, int delta);
UpgradeAPI.Add(string typeName, int delta);
  • UpgradeType … vanilla-like safe enum (Energy, Health, Jump, …)
  • string typeName … Stat dictionary name or internal key

● Set

UpgradeAPI.Set(UpgradeType type, int level);
UpgradeAPI.Set(string typeName, int level);

🧩 Type Name / Dictionary Name Support

Besides the enum, REPOUpgradeAPI also supports direct dictionary names from StatsManager:

// Directly touch the underlying StatsManager dictionary:
UpgradeAPI.Add("playerUpgradeHealth", 1);
UpgradeAPI.Add("playerUpgradeStaminaRegen", 1);
UpgradeAPI.Add("playerUpgradeUnstableCore", 1);

Internally, the API:

  1. First tries to treat the string as a full dictionary name (StatsManager.dictionaryOfDictionaries[typeName])
  2. Then falls back to legacy short keys (e.g. "energy", "jump")
  3. Finally, it tries to dynamically map to playerUpgrade* dictionaries

This makes the API compatible with:

  • Vanilla upgrades
  • New upgrades added by game updates
  • Custom upgrades added by other mods (as long as they expose a dictionary)

πŸ§ͺ Debug / Introspection Helpers

For debugging or exploring new keys, the API can dump upgrade dictionaries:

// Log all playerUpgrade* dictionaries in StatsManager
UpgradeAPI.LogAllUpgradeDictionaries();

// Enumerate dictionary names (e.g. "playerUpgradeHealth", "playerUpgradeUnstableCore", ...)
foreach (var key in UpgradeAPI.ListUpgradeKeys())
    Logger.LogInfo($"Key: {key}");

These names can then be passed directly into UpgradeAPI.Add/Set.


βš™ Internal Features

  • UpgradeNet handles RPC and dispatch
  • UpgradeManager applies local and networked changes
  • RPC registration is done automatically via Harmony (dependency mod)
  • Works in both singleplayer (local-only) and multiplayer (via RPC)
  • Internal architecture is hidden from mod developers – you only call UpgradeAPI