Making PDA Icon Overlays - PrimeSonic/PrimeSonicSubnauticaMods GitHub Wiki
Originally introduced in the 3.0 update and later refined in the 4.0 overhaul, MoreCyclopsUpgrades can now be used as a public API, allowing other mods to integrate their own cyclops upgrade modules and have them be fully compatible with the Auxiliary Upgrade Console.
Adding Info Overlays to your Upgrade Modules
One of the nifty new features added in the 4.0 overhaul was a simple to use system for having upgrade module icons display text when the PDA screen is open and viewing the upgrade console equipment screen.
This works for both the original engine room upgrade console or any auxiliary upgrade console.
Same as with the UpgradeHandlers and CyclopsChargers, the IconOverlays are also implement an Abstract Factory Design Pattern.
This means that MoreCyclosUpgrades will handle when your IconOverlay class will be constructed and updated.
Creating your Icon Overlay Class
Your custom icon overlay class starts by inheriting from the abstract IconOverlay class.
internal class MyOverlay : IconOverlay
{
public EngineOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule) : base(icon, upgradeModule)
{
// Constructor logic goes here
}
public override void UpdateText()
{
// This methods is where you can update the text elements provided in the base class
}
}
Remember, all text updates must happen in the UpdateText
method.
MoreCyclopsUpgrades will call this method at regular intervals while the PDA is displayed and whenever an upgrade module is added or removed.
Once the PDA is closed, the icons will be cleared away and no more update calls will be made.
You'll notice there is nothing in the
Find
APIs to locate your registered icon overlay classes.
This is intentional as these class instances are created and destroyed on demand.
They don't persist likeUpgradeHandlers
and there can even be multiple instances of the same icon over lay class if there are multiple instances of the same type of upgrade being viewed in the same upgrade console.
IconOverlay
base class gives you
What the The base IconOverlay
class creates 3 Unity Text elements and offers a simplified interface to manage them.
You can access these interfaces like this:
base.UpperText
base.MiddleText
base.LowerText
You also have access to:
- The Cyclops
SubRoot
instances where this is all taking place
base.Cyclops
- The exact
InventoryItem
that the icon represents (for accessing any additional components on the item)
base.Item
- The
TechType
of the upgrade module (for quicker access than going through the InventoryItem)
base.TechType
- The actual
uGUI_ItemIcon
element that is displaying the icon itself (for advanced users)
base.Icon
Ultimately, what you do with your icon overlay class is entirely up to you.
The base class provides you with a ton of tools to work with.
But since this is about displaying some relevant info about your custom cyclops upgrade, you might consider starting with a call to MCUServices.Find.CyclopsUpgradeHandler
to locate the UpgradeHandler
associated to this module and use that to drive what the text says.
Here's just some examples of this in action:
- Cyclops Auto Defense System
- Cyclops Bioreactor Booster
- Cyclops Engine Efficiency Modules
- Cyclops Speed Booster
And that's it. Now go make something great!