Research
Register a tree to add prerequisites, item costs, and part unlocks. SSLib handles the layout.
Extend the tutorial's tree
Replace its existing RegisterResearchTree call:
csharp
content.RegisterResearchTree(new ResearchTreeDefinition
{
Id = "technology",
Nodes = new[]
{
new ResearchNodeDefinition { Id = "basics", Name = "First Mod Basics" },
new ResearchNodeDefinition
{
Id = "controllers",
Name = "Controller Technology",
Prerequisites = new[] { ResearchRef.Mod(content.Key("basics")) },
Costs = new[]
{
new ItemCost
{
Item = ItemRef.Native(Items.Model.ItemsConstants.IronItemId),
Quantity = 1
}
},
UnlockedParts = new[] { PartRef.Mod(content.Key("controller")) }
}
}
});Unlock First Mod Basics, then spend one iron on Controller Technology to unlock the controller.
References and IDs
| Target | Reference |
|---|---|
| This mod's node | ResearchRef.Mod(content.Key("basics")) |
| Another mod's node | ResearchRef.Mod("other.mod:basics") |
| Native research | ResearchRef.Native(actualResearchId) |
Node IDs are unique across all trees in your mod. basics is example.firstmod:basics, regardless of the tree name.
Empty prerequisites create a root; empty costs make it free. Missing references and cycles fail world loading. Cross-mod references require that mod to be installed.
Property defaults are in Research definitions.