Mega Tree API

Mega Tree API

Put your own upgrades in the Mega Tree. You describe the node and write the effect; Mega Tree draws it, prices it, gates it, saves it and translates it.

What this is

Mega Tree is an upgrade tree that lives as an app on the store computer in Megastore Simulator. Since version 1.1.0 it is also a host: any BepInEx mod can register its own upgrade lines and they appear in the tree alongside the built-in ones.

The split is deliberate and it is the whole point of the API:

Your modMega Tree
Names the upgrade and its iconDraws the node, the branch and the connectors
Says how many levels there areChains the levels and enforces buying in order
Says what each level costsCharges the player and handles selling back, 50% by default
Writes the one-line effect textShows it on the hover card
Decides when the node unlocksGreys it out and shows your reason until then
Implements the effectSaves the level per save slot and tells you when it changes
Megastore is Mono, so this is BepInEx 5

If you have modded Supermarket Simulator, everything you know about the API carries over and everything you know about the platform does not. There is no Il2CppInterop here, no ClassInjector, no (IntPtr ptr) constructor - a MonoBehaviour is just a MonoBehaviour, and writing a static field does not crash the game.

The one thing that bites everyone: BepInEx 5, not 6. The wrong one fails silently. Project setup has the csproj that works.

Hello world

This is a complete, working registration. Two calls.

csharp
using BepInEx;
using MegaTree.Api;

[BepInPlugin("BigBoxes", "Big Boxes", "1.0.0")]
[BepInDependency(MegaTreeApi.ModGuid)]
public sealed class Plugin : BaseUnityPlugin
{
    private void Awake()
    {
        // "Big Boxes" is the label of your own sub-tab inside the Mods tab.
        var tree = MegaTreeApi.ForPlugin("BigBoxes", "Big Boxes");

        tree.Register(new UpgradeDefinition
        {
            Id            = "bigboxes.capacity",
            DisplayName   = "Bigger Boxes",
            MaxLevel      = 3,
            BaseCost      = 1500,
            Icon          = UpgradeIcon.Builtin("package"),
            DescribeLevel = lvl => $"+{lvl * 2} items per box",
        });
    }
}

That gives the player a three-level line, priced 1500 / 2700 / 4860, saved per save slot, sellable, and greyed out when they cannot afford it. What it does not do is make boxes bigger - that part is yours, and Events is where it goes.

The effect is always yours

Mega Tree stores a number and tells you when it changes. It has no idea what "bigger boxes" means. Every node in the Mods tab works this way, including the ones in the example mod.

What you get for free

What it will not do

Where to next