Skip to content

Upgrade System Overview

Indigocoder1 edited this page Oct 24, 2024 · 3 revisions

System Breakdown

The upgrade system in Sub Library allows you to have an upgrade console that opens the PDA with a UI similar to other upgrade consoles.

There are 3 main parts to the system:

  1. The Modded Upgrade Console
  2. The Module Functionality Handler
  3. Upgrade Modules

Upgrade Console

The ModdedUpgradeConsole, while providing some functionality out of the box, requires more input from the modder to actually be useful than some other scripts.

Out of the box, it handles module saving, module visibility (The little slot things that go into the console) and equipping and unequipping modules. What is done with the modules and what modules are allowed is up to the modder.

The console is gone into more in-depth in its own page, so make sure to check that out if you're looking for more info.

Module Functionality Handler

The module functionality handler handles (you guessed it) actually creating and removing the module functionality classes.

The way modules are handled in this library is that there is an object onto which scripts are added and removed from so they can affect systems on the sub. The next section on upgrade modules goes more into depth on how they work.

The object they are put on should have a ChildObjectIdentifier component on it, as well as a ChildObjectIdentifierFix. The fix component is because the identifier itself does not register an ID and can therefore be mixed up with other identifiers.

Upgrade Modules

Upgrade modules are left up to the modder's creation, but some common module bases are provided. These are the depth module, and charger module (I.e. thermal or solar). To create a custom module, simply make a script inheriting from MonoBehavior and IOnModuleChange, and optionally add the ModdedSubModuleAttribute attribute.

Here are some examples of custom modules on the Seal and Chameleon.

To register your mod's custom upgrade modules, you can use either ModuleFunctionalityHandler.RegisterModuleFunction or ModuleFunctionalityHandler.RegisterModuleFunctions. The former registers a single behavior and the latter searches the entire given assembly for classes with the ModdedSubModuleAttribute attribute to automatically register them.