Tech Tree API
Tech Tree API
Put your own upgrades in the Tech Tree. You describe the node and write the effect; Tech Tree draws it, prices it, gates it, saves it and translates it.
What this is
Tech Tree is an upgrade tree that lives as an app on the store computer in Supermarket Simulator. Since version 1.3.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 mod | Tech Tree |
|---|---|
| Names the upgrade and its icon | Draws the node, the branch and the connectors |
| Says how many levels there are | Chains the levels and enforces buying in order |
| Says what each level costs | Charges the player and handles selling back, 60% by default |
| Writes the one-line effect text | Shows it on the hover card in the player's language |
| Decides when the node unlocks | Greys it out and shows your reason until then |
| Implements the effect | Saves the level per save slot and tells you when it changes |
You never touch Il2CppInterop to use the API. Nothing in the public surface is a
Sprite, a Color or an
Il2Cpp* type - it is all plain objects and delegates.
Hello world
This is a complete, working registration. Two calls.
using BepInEx;
using BepInEx.Unity.IL2CPP;
using TechTree.Api;
[BepInPlugin("BigBoxes", "Big Boxes", "1.0.0")]
[BepInDependency(TechTreeApi.ModGuid)]
public sealed class Plugin : BasePlugin
{
public override void Load()
{
// "Big Boxes" is the label of your own sub-tab inside the Mods tab.
var tree = TechTreeApi.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 with a price in red when they cannot afford it. What it does not do is make boxes bigger - that part is yours, and Events is where it goes.
Tech 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
- The whole interface - node circles, branch colours, connector lines, hover card, hold-to-buy ring, drag, scroll and zoom.
- Buying and selling - affordability checks, the money transaction, and selling a level back for 60% of what it cost - or whatever rate your node declares.
- Per-slot saving - and levels are kept even while your mod is uninstalled, so a player who removes your mod and puts it back gets their progress back (how that works).
- Translation - into all 22 locale codes Tech Tree ships with, falling back to English and then to the raw key.
- Gating - your predicate decides, Tech Tree does the greying out, the caching and the "why is this locked" line.
What it will not do
- Create a new top-level tab. Every registered node lives in the Mods tab, in your sub-tab. See The Mods tab.
- Run your effect every frame.
Applyfires about every two seconds; for values the game rewrites constantly you patch the getter yourself. - Guess your effect from the numbers.
DescribeLevelis what the player reads, and nothing checks that it matches what your code does.