-
Notifications
You must be signed in to change notification settings - Fork 80
Finding Auxiliary Cyclops Managers
After you've registered your auxiliary manager and the Cyclops has loaded, you can now proceed to Find
it.
This process is almost exactly the same as it is for finding UpgradeHandlers, with an added option we'll look at as we go.
The Find
services offer you two methods for finding your auxiliary manager.
/// <summary>
/// Gets the typed <see cref="IAuxCyclopsManager"/> at the specified Cyclops sub with the given <seealso cref="IAuxCyclopsManager.Name"/>.
/// </summary>
/// <typeparam name="T">The class you created that implements <see cref="IAuxCyclopsManager"/>.</typeparam>
/// <param name="cyclops">The cyclops to search in.</param>
/// <returns>A type casted <see cref="IAuxCyclopsManager"/> if found; Otherwise returns null if not found.</returns>
/// <seealso cref="CreateAuxCyclopsManager"/>
T AuxCyclopsManager<T>(SubRoot cyclops) where T : class, IAuxCyclopsManager;
In these examples, T
is a Generic Parameter that you will replace with your auxiliary manager's Type.
Calling this method will return the auxiliary manager associated to the cyclops instance you're looking at.
// Assuming you have a reference to the Cyclops SubRoot instance
SubRoot cyclops;
// You can fetch the manager for that Cyclops
MyAuxManager mgr = MCUServices.Find.AuxCyclopsManager<MyAuxManager>(cyclops));
Remember: your auxiliary manager's Initialize method will only be invoked once by MoreCyclopsUpgrades and only the first time that your mod requests that auxiliary manager using
Find.AuxCyclopsManager
orFind.AllAuxCyclopsManagers
to locate it.
/// <summary>
/// Gets all typed <see cref="IAuxCyclopsManager"/>s across all Cyclops subs with the given <seealso cref="IAuxCyclopsManager.Name"/>.
/// </summary>
/// <typeparam name="T">The class you created that implements <see cref="IAuxCyclopsManager"/>.</typeparam>
/// <returns>A type casted enumeration of all <see cref="IAuxCyclopsManager"/>s found across all Cyclops subs, identified by name.</returns>
IEnumerable<T> AllAuxCyclopsManagers<T>() where T : class, IAuxCyclopsManager;
Calling this method will let you iterate over all your auxiliary managers across all Cyclops instances in the game world.
IEnumerable<MyAuxManager> myManagers = MCUServices.Find.AllAuxCyclopsManagers<MyAuxManager>();
foreach (MyAuxManager mgr in myManagers)
{
}
Reasons you might want to use this:
- You need to execute code across all Cyclops instances
- Your Buildable component inside the Cyclops isn't able to locate the
SubRoot
in its parent components. See Origin Story
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