Skip to content

Creating Auxiliary Cyclops Managers

PrimeSonic edited this page Oct 6, 2020 · 4 revisions

Creating Auxiliary Cyclops Managers

If the Cyclops Manager looks like a useful tool to you, then taking advantage of these tools is very simple.

The only real requirement for an Auxiliary Cyclops Manager is that it be a class that implements the IAuxCyclopsManager interface.
That's it! The rest is up to you to decide what you need.

internal class MyAuxManager : IAuxCyclopsManager
{
    public bool Initialize(SubRoot cyclops)
    {
        // Additional setup logic goes here
    }
}

The Initialize{SubRoot} method will be called the first time the aux manager is needed,
giving you an extra change to perform any additional setup.
This happens the first time the MCUServices.Find.AuxCyclopsManager method is invoked by your mod.

Your auxiliary cyclops manager can be a Unity Monobehavior or a plain class, it might inherit from another class or not.
It can be what you need it to be.


Free to copy aux manager pattern

One use case for these managers is for finding and performing actions on certain buildables aboard the Cyclops.
You are free to copy and use this pattern if you find it helpful.
It uses an Auxiliary Cyclops Manager that implements BuildableManager and that the Monobehavior of the buildable implement ICyclopsBuildable.

You don't need to reference this this code from another DLL. Just copy it and adjust it to your needs. If you use this base class as is, your resulting might look something like this.

Clone this wiki locally
  翻译: