Skip to main content
  • Powerful
  • Data-Oriented
  • Event-Driven
  • Turing-Complete
  • Approved by PJB1
  • Powered by Graph Theory and AI Pathfinding
  • Coded by the same nerd who brought you atmos and botany :^)

TODO Index

  • Introduction to Construction Graphs
    • Explain the concept of graphs, nodes, edges and steps.
  • Writing and Designing Construction Graphs
    • Explain how to actually write and design a good graph.
  • List of Steps, Actions and Conditions.
  • Writing Initial Constructions.
    • Explain limitations.
  • How to Add Custom Steps
  • Construction System Internals
    • General overview on how construction works internally.

The construction graph

This construction system is built upon the belief that any complex construction in the game can be defined as a graph of interconnected states, or nodes. The goal of this system is to ease the design and creation of new complex interactions (constructions) between entities, while drastically reducing the amount of code needed to be written to allow for them. Graphs consist of nodes and the links, called edges, between them. The “Girder” construction graph

Nodes

Nodes represent the current state of an entity. An entity that has a construction graph will always be at one of the nodes, and can move between them under certain circumstances, as defined by edges.

Nodes and entity prototypes

Nodes can specify an entity prototype ID. An entity that arrives at a node that specifies a prototype different than the one it has will be deleted, and the specified entity prototype will be spawned at its place instead. When this happens, every container owned by the entity’s ConstructionComponent will be transferred to the new entity.
The specified entity prototype MUST have a ConstructionComponent with the correct graph and node.

Actions

You can specify actions that will be executed when an entity arrives at a node (whether it arrives by an edge, or is spawned while already at the node). To create a new one, you must simply create a C# class that implements IGraphAction. Actions can do anything, from spawning a different prototype to deleting the entity itself.

Edges

Edges are the links or transitions between nodes. They specify the interactions required for an entity to change from a specific node to another one.

Completed actions

You can specify actions that will be executed when an edge is completed, right before the entity reaches the new node. This uses the same classes as node actions, using IGraphAction. You can create new ones by implementing this interface in a new C# class.

Conditions

You can also specify conditions that must be satisfied for the edge to be available. These will all be checked before starting and during an edge. You can create custom actions by creating a new C# class that implements IEdgeCondition.

Steps

Steps are the interactions required for an entity to go from one node to another in an edge. An edge can specify as many steps needed as required.
Tool step
This step requires you to use a tool with the right quality on the entity.
Material step
This step requires you to insert an arbitrary amount of a material to an entity. It works by splitting material stacks.
Component step
This step requires you to insert an entity with a specific component. Using this step isn’t discouraged, but using tags instead is recommended in most cases.
Tag step
This step requires you to insert an entity with a specific tag.
Multiple Tags step
This step requires you to insert an entity with a number of tags as specified by allTags and anyTags. allTags acts as an AND gate, while anyTags acts as an OR gate. You will only be able to insert entities that fulfills both requirements. You can specify only one of the two, or specify both at once.

Containers

Any step that needs the user to introduce an item to the construction (material, prototype and component steps) can store the introduced item in a named container on the entity. When the entity changes due to reaching a node with a different entity prototype, all those containers will be transferred to the new entity. The construction system allows you to use this stored item for any purpose, such as retrieving data in a component of the stored item for different effects (See the computer construction graph) or simply to “keep” and later return the same exact item an user introduced.

The construction graph Prototype

Below you’ll find an example construction graph, documented to teach how to write graphs. For real-world examples, refer to the graph prototypes in the game’s code.
TODO: List and explain all graph actions/conditions in a list somewhere.

The construction recipe prototype

To specify construction/crafting recipes in the construction menu, you need to write construction prototypes.

Initial construction

What happens when you attempt to craft an item, or start building a construction ghost? The construction system will try to find a path from the starting node to the target node. This first step in construction is very special. It has some limitations that regular edges don’t have. For example, tool steps aren’t allowed, and edge conditions are not checked. For this reason, you should design your starting node so it has clear, simple edges without these disallowed features. Completed step and edge actions are, however, allowed. They will all execute at once when the construction succeeds. TODO: Move this to construction menu explanation.

Construction conditions

Construction conditions must be C# classes in the Shared content project. They implement IConstructionCondition. TODO: List all current construction conditions.

Construction menu

TODO: Move construction prototype explanation here. TODO: Explain the “start” node and use glass sheet graph example.

Construction ghosts

TODO: Explain initial construction properly.

Crafting

TODO: Explain how item crafting graphs work.

Footnotes

  1. PJB is really stinky.
Last modified on June 20, 2026