-
Notifications
You must be signed in to change notification settings - Fork 79
Registering your Icon Overlay
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.
Now that you've defined how your class works and how it updates, the last step is to simply register your icon overlay.
You'll find this very similar to the way UpgadeHandlers are registered.
Since you're probably already familiar with that, we'll just dive right into the examples.
This form takes in a TechType
and a CreateIconOverlay
delegate method as its one parameter.
The CreateIconOverlay
delegate defines this pattern:
IconOverlay CreateIconOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule);
This means that method to be used here.
- Must take in one
ItemIcon
and oneInventoryItem
as its only parameters (in that order) - Must return an object that is or inherits from
IconOverlay
.
It is expected that you will pass the
ItemIcon
andInventoryItem
parameters to your Icon Overlay constructor.
public static class QPatch
{
private static TechType myCyclopsUpgrade;
public static void Patch()
{
// Your patching code
....
// In this pattern, you can pass the method by name
MCUServices.Register.PdaIconOverlay(myCyclopsUpgrade, CreateMyUpgradeHandlerMethod);
}
private static CreateMyIconOverlayMethod(uGUI_ItemIcon icon, InventoryItem upgradeModule)
{
return new MyIconOverlay(icon, upgradeModule);
}
}
This can also be done using anonymous methods.
As long as the anonymous method follows the same requirements, it doesn't have to have a name.
public static class QPatch
{
private static TechType myCyclopsUpgrade;
public static void Patch()
{
// Your patching code
....
// In this pattern, you can pass the method by name
MCUServices.Register.PdaIconOverlay(myCyclopsUpgrade, (uGUI_ItemIcon icon, InventoryItem upgradeModule) =>
{
return new MyIconOverlay(icon, upgradeModule);
});
}
Option 2 - Using a class that implements the IIconOverlayCreator
interface
If passing methods as a parameter feels a little too weird to you, this alternative might serve you better.
This interface requires a class to implement a method named CreateIconOverlay
.
Just as before, this CreateIconOverlay
method
- Must take in one
ItemIcon
and oneInventoryItem
as its only parameters (in that order) - Must return an object that is or inherits from
IconOverlay
.
It is expected that you will pass the
ItemIcon
andInventoryItem
parameters to your Icon Overlay constructor.
public static class QPatch
{
private static TechType myCyclopsUpgrade;
public static void Patch()
{
// Your patching code
....
var myMaker = new MyUpgradeHandlerMaker()
MCUServices.Register.PdaIconOverlay(myCyclopsUpgrade, myMaker);
}
}
internal class MyUpgradeHandlerMaker : IIconOverlayCreator
{
public IconOverlay CreateIconOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule)
{
return new MyIconOverlay(icon, upgradeModule);
}
}
And that's it. Once registered, your custom Icon Overlay will be used and updated whenever it comes up.
CbItem Patching.dll
Text Pack Patching.txt
The Cyclops Upgrade Cycle
Single UpgradeHandlers
Grouped UpgradeHandlers
Registering UpgradeHandlers
Finding UpgradeHandlers
Creating Icon Overlays
Registering Icon Overlays
The Cyclops Charge Cycle
Creating Cyclops Chargers
Registering Cyclops Chargers
Finding Cyclops Chargers
Origin Story
Cyclops Manager Promises
Creating Your Manager
Registering Your Managers
Finding Auxiliary Managers