Skip to content

Using the Upgrade System

Indigocoder1 edited this page Oct 24, 2024 · 1 revision

The upgrade console requires you to do a few things that might not be obvious at first, so here's a list of what needs to be done to get the system working.

Ensuring the Correct Data Type

The data type you are using in your serialization manager should inherit from ModuleDataClass, unless you override the save methods with your own upgrade console class.

This is to ensure the baked-in save system has something to go off of to save the modules.

Initializing Slot Mapping

To make sure your equipment actually works and only accepts the upgrades you want, you need to setup the equipment slotmapping in your plugin class.

To do this, you must first create an EquipmentType. I usually set this as a static property in my plugin class, but you can set it up however you want. Here's some example code for that:

public static EquipmentType MyCoolUpgradeModuleType { get; } = EnumHandler.AddEntry<EquipmentType>("MyCoolModule");

Once you've done that, you need to initialize the slotmapping with this EquipmentType, and the names of your equipment slots. Here's an example of how to do that:

private void InitializeSlotMapping()
{
    Equipment.slotMapping.Add("SubUpgrade1", MyCoolUpgradeModuleType );
    Equipment.slotMapping.Add("SubUpgrade2", MyCoolUpgradeModuleType );
    Equipment.slotMapping.Add("SubUpgrade3", MyCoolUpgradeModuleType );
    Equipment.slotMapping.Add("SubUpgrade4", MyCoolUpgradeModuleType );
}

Your equipment is now setup to actually work, after you've finished setting up the UI.

Setting up the Slot UI

To set up your equipment for the PDA UI, you will need to use ModuleUIHandler.RegisterEquipmentData, and pass in your EquipmentData. The struct has documentation available via intellisense or the repo, but I'll list it out here as well.

  • Base Module Name - The name for your equipment slot in the PDA UI hierarchy. Doesn't really matter, but good practice to name it after your sub.
  • Number of Modules - How many modules slots to put in. Can't be greater than 4, since the modules are copied from the Seamoth.
  • On Modify Background Image - A callback that allows you to swap out the background image of the slot UI.