Open Source · LGPL v3+

Investycoon Core SDK

Modular SDK to create custom plugins in the Investycoon ecosystem.

Install dotnet add package InvestycoonCore

Overview

InvestycoonCore lets you write content plugins: company types, items and their specifications, machines and recipes. The game loads plugins when the server starts. The package targets .NET 10 (version 2.9.0); its only dependency is JetBrains.Annotations (attributes).

  • Custom company types
  • Custom items and specifications
  • Machines, recipes and trade vocabulary

Installation

The package is published on the GitLab project's public registry (no account needed). Add the source once, then reference the package:

dotnet nuget add source "https://gitlab.com/api/v4/projects/71905736/packages/nuget/index.json" --name investycoon
dotnet add package InvestycoonCore --version 2.9.0

Or download the .nupkg file from the official registry.

Compatibility: the game ships its own copy of the SDK. A plugin built against a newer SDK than the server's is refused at startup (PluginIncompatibleException): pin the SDK version to the one the server runs.

Minimal Plugin class example:

public class CustomPlugin : Plugin
{
    public override string Code => "custom-plugin";
    public override string Version => "1.0";
    public override string Name => "Custom Plugin";
    public override string Explanation => "This is a custom plugin";
    public override ResourceManager MainResourceManager => Resources.Resources.ResourceManager;
}

The class exposes the Code, Version, Name, Explanation and MainResourceManager properties to customise.

Member reference

The abstract Plugin class exposes the following members. Code, Name, Version, Explanation and MainResourceManager are required. The others are optional and return false or an empty list by default.

Member Type Description
Code string Unique plugin identifier, used internally.
Name string Name displayed in the admin interface.
Version string Plugin version, shown in InvestycoonSky.
Explanation string Description shown to administrators.
MainResourceManager ResourceManager Resource manager for label localisation.
ItemIgnoreVanilla bool If true, vanilla game items are removed. Default: false.
CompanyTypeIgnoreVanilla bool If true, vanilla company types are removed. Default: false.
Items() List<Item> Returns the list of items provided by the plugin.
CompanyTypes() List<CompanyType> Returns the list of company types.
ItemSpecificationTypes() List<ItemSpecificationType> Returns the list of specification types (quality, etc.).
OnLoading(IServiceProvider) Task Called once when the game loads the plugin. Default: does nothing.

Full plugin example:

public sealed class MyPlugin : Plugin
{
    public override string Code        => "my-plugin";
    public override string Version     => "1.0";
    public override string Name        => "My Plugin";
    public override string Explanation => "Plugin description.";
    public override ResourceManager MainResourceManager
        => Resources.Resources.ResourceManager;

    public override bool ItemIgnoreVanilla        => true;
    public override bool CompanyTypeIgnoreVanilla => true;

    public override List<Item> Items() =>
    [
        new ItemResource(1, "lithium", 20_00).SetMass(25f).SetItemGroup("resource"),
        new Item(2, "battery", 2, 10_00).SetMass(0.1f).SetItemGroup("refined"),
    ];

    public override List<CompanyType> CompanyTypes() =>
    [
        new(1, "tech-company",
            nameof(Resources.Resources.TechCompany_Label),
            nameof(Resources.Resources.TechCompany_Desc))
    ];

    public override List<ItemSpecificationType> ItemSpecificationTypes() =>
    [
        new(1, "quality", ItemSpecificationTypeEnum.Quality, [10])
    ];
}

Ids: the id passed to a constructor is only a local label. The game replaces it with a stable id computed from the plugin code and the entity name: plugins need no coordination, but renaming an item, a company type or a specification breaks existing games. Prices are integers in hundredths of the game currency (20_00 = 20).

Item types

Choose the type that matches the nature of your item:

Item

Base product: component, manufactured good. Accepts a tier (1–5) that influences rarity and game progressions.

new Item(id: 1, name: "battery", tier: 2, defaultPrice: 10_00)
    .SetMass(0.1f)
    .SetVolume(0.0001f)
    .SetItemGroup("refined");

ItemResource

Natural extractable resource. Automatically sets tier=1, IsDivisible=true and IsStackable=true. The optional SetRarity() and SetWorldGeneration() methods configure rarity and map generation.

new ItemResource(id: 1, name: "lithium", price: 20_00)
    .SetRarity(ItemRarity.GetByName("ordinary")!)
    .SetMass(25f);

ItemFuel

Consumable energy source. Set its capacity with SetEnergy().

new ItemFuel(id: 1, name: "atomic-battery", defaultPrice: 300_00)
    .SetEnergy(1_000)
    .SetMass(1f);

ItemNonPhysical

Digital or intangible item (software, data). No mass or volume.

new ItemNonPhysical(id: 1, name: "program", price: 0);

MachineTransformer

Production machine with input/output recipes. Add recipes with AddRecipe().

new MachineTransformer(id: 1, name: "factory", price: 10_000_00)
    .SetNbInput(2)
    .SetNbOutput(1)
    .SetDelayBuild(TimeSpan.FromHours(1))
    .SetMaxWorkers(3)
    .AddRecipe(new MachineRecipe(
        name: "my-recipe", mainCompany: "company-type-code", nbStep: 4,
        inputs:  [new RecipeProduct("lithium", 2)],
        outputs: [new RecipeProduct("battery", 10)]
    ))
    .SetItemGroup("advanced-machine");

Localisation

Every text shown in the game is read from .resx files. The neutral Resources/Resources.resx is used when no translation matches; add Resources.fr.resx, Resources.en.resx… for other languages.

Configure your .csproj to generate the static accessor class:

<ItemGroup>
  <EmbeddedResource Update="Resources\Resources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
</ItemGroup>

Then reference the ResourceManager in your plugin:

public override ResourceManager MainResourceManager => Resources.Resources.ResourceManager;

Expected keys (a missing required key stops the server at startup with a ResourceCompilingException naming it):

EntityKeys
Item (required when enabled)Item_{name}_Label, Item_{name}_Desc
RecipeMachineRecipe_{name}_Label
SpecificationItemSpecification_{name}_Label
Company typethe two keys given to its constructor

Machine vocabulary

A machine may give its own words, so that the game speaks the language of the business it simulates (a shop rather than a factory). Every key is optional; when missing, the game keeps its generic wording.

KeyDescription
Item_{name}_Shortshort name with its article, used in sentences
Example (distribution warehouse): the warehouse
Item_{name}_Worker / Item_{name}_Workersone employee / several employees
Example (distribution warehouse): picker / pickers
Item_{name}_Activitytitle of the activity, instead of "Process"
Example (distribution warehouse): Shelving
Item_{name}_Energyenergy consumed, without article (the app then counts energy in cycles, not MJ)
Example (distribution warehouse): electricity

Installing the plugin on a server

The plugin is installed by the game server's administrator: you do not have to manage any infrastructure.

1. Build in Release and hand over the plugin .dll with its language folders (en/MyPlugin.resources.dll…), without the SDK, which the game provides:

dotnet build -c Release

2. The administrator copies them into the Plugins folder of the game instance, keeping the language sub-folders, then restarts the game API: plugins are loaded at startup only.

Once the server has restarted, InvestycoonSky shows the name and version of each loaded plugin on the server's page.

Illustrations

Every enabled item and every company type needs a PNG image embedded in the plugin assembly.

Place images in the following folders inside your plugin project:

Resources/
└── Images/
    ├── Items/
    │   ├── lithium.png
    │   └── battery.png
    └── CompanyTypes/
        └── tech-company.png

Declare them as embedded resources in your .csproj:

<ItemGroup>
  <EmbeddedResource Include="Resources\Images\**\*" />
</ItemGroup>

The file name must match the Name of the item or CompanyType exactly (case-sensitive). At startup, a ResourceCompilingException is thrown when an item's image is missing.

License

Distributed under the LGPL v3+ license.

Credits

Developed by Alan Bretelle.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.