Modding Reference

Here I’m trying to collect all the information that may be useful for everyone trying to mod the game, including myself :grin: If you got something to contribute, correct errors or have any question about general knowledge about InfraSpace‘s internals, please post it here. I’ll constantly update the main post.

Distance units

InfraSpace used several measures of distance. Here we cover where they are used, how long they are and how they convert into each other.

World distance

By far the most important distance measure. This is the unit used by the world coordinate system and most things use it. Initially assume anything distance related uses world distance. Examples:

  • Map coordinates and size. The first premade map has a playable size (length of the square) of 512. The total world is 1024. The random map is twice of that in each direction.
  • Building sizes (more exact: the sizes of their collides). A habitat is 4x4 in size.
  • Radius of effects. A power pole has an electric coverage of 10.
  • If you use the object inspector of the development tool panel, most objects report their position in this unit.

1 unit very roughly corresponds to 10 meters in the real world.

Grid distance

This is the size of the grid when activated in the game. One grid cell has a world size of 2x2 world units. It’s what most players are thinking in.

  • A habitat is 2x2 grid cells in size.
  • The colossal adamantine is 23x23 in size. That name is very well chosen.

The 1:2 conversion from grid to world makes it so that the center of grid cells are always integer coordinates in world units. This has several advantages: building coordinates are always anchored to the center and road nodes are also always on the center of grid cells.

Car distance

„Infrastructure“ distance would also be an accurate name. This unit is often stored as integers and sometimes even uses integer arithmetics (for performance and maybe accuracy). One unit of world distance equals 1000 car units.

  • A car is 600 car units long.
  • A car on a concrete road travels at 60 car units per frame. That equals 3 world units per second or 1.5 grid cells per second.
  • A tier 1 train reaches a maximum speed of 150 car units per frame.
  • Roads and rails use car units to store where cars are on them and how far they still have to travel.

District units

The playable map area is divided into 4096x4096 pixels (or maybe “distrixels”?) to assign districts to each of them, since each distrixel can only belong to 1 district at a time. This sub-sampling is done for memory reasons.

  • On the random map a distrixel is 0.25x0.25 world units big.

Terraforming progress units

The whole world is divided into 64x64 pixels (“terrafoxels”?) that store terraforming progress (for performance) reasons.

  • On the premade map a terrafoxel is 8x8 world units big.

Time units

There are several ways how progress through time is tracked and calculated.

Actual time

In some places you will find Unity‘s DeltaTime. That’s where actual time is used and that’s in seconds. This is subject to the frame rate running at 60 fps. Usually this is not used for very important things like animations.

  • Antares’ laser cannon deals 1 damage per second to objects.

Simulation frames

Most of the actual time related things in the game work directly with the simulation frame discretization. 50 of such frames constitute 1 second of real time given that the computer is able to compute them this fast. Otherwise the time measured by a single frame increases and your game runs slower.

  • One simulation frame equals 20ms of actual time.
  • In one frame a truck on a concrete road can travel 60 car units.
  • In one frame the durability of high tech tools will decrease by 0.00167%, making them last 20 minutes in total.

Many actions in the game only take place every x-th frame for performance reasons. For example production progress is only updated every 10th frame for factories and similar buildings. This is spread out semi randomly across buildings, so every frame approximately 1/10 of all factories update their production.

Production ticks

Production times are using this unit. It’s tracking progress rather than time. 1 production tick is the amount of progress a factory of 1% efficiency makes in each frame. Assuming 100% efficiency and 50 frames per second we get a factor of 5000 to 1 for conversion to second.

  • A small sand mine‘s production definition has a cycle time of 25000 ticks. This equals 250 frames at 100% efficiency or 5 seconds of actual time.

Resource units

These measures are used to track the amount of something.

Goods

In most cases resources are stored and handled as integer numbers that directly denote the amount.

  • A sand mine produces 1 sand in each production cycle.
  • Trains have a maximum capacity of 200/400/600 respective per transport difficulty.
  • Each pink truck carries one worker from the spaceport to a habitat (or 0 on the way back).

Construction material

Once goods are delivered to a storehouse (small or normal size) they change from the above good denomination to the construction material denomination, which is the same value but multiplied by 100.

  • A truck carrying 1 unit of concrete will deposit 100 units of concrete construction material to your storage on arrival at a storehouse.
  • Your construction material storage of concrete and steel is displaying the actual number divided by 100 (rounded down). Same for the adamantine panel and the storehouse info panel.
  • A basic habitat costs 1000 units of concrete.
  • A stretch of gravel roads costs 10 concrete according to its definition. This price is always valid for 1 world unit. The price displayed in the construction menu is displayed for 10 world units, so that would be 100 concrete. Divided by the factor of 100. One grid cell of gravel road costs 20 concrete, or 0.2 in normal units.
3 Likes

Limitations

This section lists features that currently have no known way of achieving them with mods.

Main menu

Mods are loaded once you start a new game or a save game is loaded. It is therefore not possible to modify the game in any way before these events. You can’t change the main menu that players will interact after starting the game.

Assemblies

This is a list of the C# DLLs created by DionicGame and what you can find in them. Use this as a starting point when searching for a certain piece of code. Assemblies not listed here are from third parties and usually not relevant for modding.

Assembly-CSharp

Mostly just the main menu and some very high level „entry point“ kind of code.

InfraSpaceCore

Not as core as the name suggests. Contains some game logic like environment objects and terraforming.

old

By far the most important assembly. Contains most of the ingame logic and user interface related code. Usually you’ll need to go here first whatever your use case.

DionicGame

Contains functions that are more general to game programming like localization and is likely intended to be reused for future projects.

DionicCore

Universal helper classes and methods that may be useful in future projects as well.

Glossary of terms

An encyclopedia style list of terms used in the game (code) and their explanation. Names will often coincide with class names or typical variable and method names.

Building

A construction standing alone, that means it’s not part of a Network. Basically everything you build except roads, rails and pipes. Handles construction, location and appearance.

Car

A good that is being transported by any means other than a pipe. While on roads this will be a truck. Cars can also be loaded onto car carriers like trains and gondolas. Defined by the resource type. Also stores the amount. Holds the complete path for the transport, past and future.

CarCarrier

An intermediate container for transporting cars by means other than roads. The following are car carriers:

  • trains
  • gondolas

CarHost

Anything that can contain or guide the transportation of cars (goods). Every car must always be attached to a car host. The following car hosts exist:

  • LaneBase
  • CarCarrier
  • StationModule

Collider

A Unity Component that can be added to GameObjects. Manages the 3D space an object occupies. Relevant for space taken up by buildings and for identifying what the mouse cursor is clicking on.

ConstructionCategory/-Categories

A recursive data structure that contains either more ConstructionCategory children or a single item which will be a Building or Network (road). These are used for the building menu hierarchy at the bottom of the screen. ConstructionCategories is the topmost container class for this and represents the colorful icon buttons on the dashboard.

ConsumerProducer

A sub component of buildings that handles requests and deliveries done by this building. Also hosts the production logic.

Ghost

Not yet placed buildings. When constructing buildings, the placement preview is the ghost. In some cases there may be more than 1 ghost, e.g. with power poles and gondola stations. When building roads, rails and pipes the ghost is called SplitGhostEdge, indicating it can contain more than 1 edge.

Habitat

Two different meanings:

  • Name of the basic habitat building
  • A kind of ProductionLogic only found on the basic habitat building.

The habitat logic handles demands, consumption, upgrade and downgrade of the building.

Intersection

A road NetNode. Manages all connected roads, how their lanes are connected to each other and traffic settings. Even nodes with just 1 or 2 roads connected to it are Intersections.

IntersectionConnection

A subclass of LaneBase and the only one that can easily be visualized: these are the colorful lines in the intersection settings.

IntersectionTrafficSettings

Traffic signs and traffic lights at intersections.

Lane

Subclass of LaneBase. A single lane along the edge (not node/intersection!) of a road. Its shape is determined by the Road that contains it.

LaneBase

A track that can be followed by cars. Handles cars moving onto, along and off itself. Also manages space and position of cars it hosts. Has 3 specific sub classes:

  • Lane
  • SideroadLane
  • IntersectionConnection

NetEdge

A piece of road, rail or pipe connecting exactly 2 NetNodes of the same type. Mostly manages what nodes are attached and the shape (Bezier).

NetNode

These are the places of Network type buildings between the edges and at their ends. For roads and rails these are the blue circles visible in construction mode. For roads these are also intersections. For pipes these are the places with pipe sleeves. Mostly manages the connected edges and intersection.

Network

Sometimes abbreviated to Net. These are buildings that are connected to each other rather than stand alone. There are 3 types of networks and they can’t be mixed (interconnected): roads, rails and pipes. In particular power lines do not constitute a Network.

Network relates mostly to construction, connection logic and spatial location but not so much to the actual function (guiding cars or rails and transmitting liquids or gases).

OrderSize

How many units of a resource type are loaded into each truck (capped by transport difficulty).

ProductionDefinition

The recipe used by factories (including terraformers but excluding the spaceship factory). Contains inputs (types and amounts), outputs (types and amounts) and time in production ticks.

ProductionLogic

The general logic of a building (hosted by the building’s ConsumerProducer). Comes in many different flavors depending on the purpose of the building.

Resource

“Resource” has several meanings in the game.

  1. Resource types as defined in resources.json.
  2. Resource amounts stored in factories and set in ProductionDefinition.
  3. Resource colliders spread across the map, which are required by mines to operate.

Road

A NetEdge that represents a road type building. Manages its direction and Lanes. Mostly relevant for path planning.

Sideroad

The small gray road strip connecting most buildings to gravel and concrete roads. Contains 2 SideroadLanes.

SideroadLane

A subclass of LaneBase. Handles cars traveling on Sideroads.

StackSize

The maximum amount of a resource type that factories can store in their input and output.

Visualization

A way to render the 3D world and optionally some decals on top of it. There are 10+ special visualization, e.g. power, cars, roads, parks, industrial robots. Irrelevant parts of the world turn gray in each visualization and relevant parts are highlighted. This is mostly done by applying special materials to the game objects.

Upgrade

There are two meanings for upgrade:

  1. BuildingUpgrade, which are several upgrades buildings can receive and are displayed on their info panel. Examples include industrial robots, self cleaning solar panels and waste recycling.
  2. Buildings that need to receive a certain amount of goods to be replaced by a different version. Those are the early stages of the adamantine drill and the magnetic field generator. See UpgradeProductionLogic.