Skip to content
cheeeeeeeeeen edited this page Nov 13, 2020 · 26 revisions

Mod API

This wiki will contain useful API if ever a mod creator also wants their custom entities to be supported with the Options/Multiples. Just add this mod as a soft dependency, and add this mod's DLL file as a project dependency. If you have questions, contact Chen.

To start, click here to head on over to the API Documentation.

Please do not mind the page names of the wiki. Just read the contents as they are more readable. The documentation is powered by DefaultDocumentation.

References

The mod itself uses the API to implement the Beam Drone (LaserDrone1) which is a custom entity along with its custom attack (FireLaser). This custom drone also has Option Support. Use it for reference on using the API.

  • Setting up the drone using the provided DroneCatalog
myCustomDronesList = DroneCatalog.Initialize("com.awesomemod.guid", someConfigFile);
DroneCatalog.SetupAll(myCustomDronesList);
  • Creating a custom drone class by inheriting Drone
public class MyCustomDrone : Drone<MyCustomDrone>
  • Accessing the instance of the singleton drone class
// This will only work after DroneCatalog.Initialize() is done
MyCustomDrone drone = MyCustomDrone.instance;
drone.enabled; // true or false
  • Always use the base method when implementing the available virtual methods
protected override void SetupConfig()
{
    base.SetupConfig();
    // other code
}

// For PostSetup, it is ideal to call the base method last
protected override void PostSetup()
{
    // other code
    base.PostSetup();
}
  • Executing code for all the Options of a drone
GradiusOption.instance.FireForAllOptions(droneBody, (option, behavior, target) =>
{
    new BulletAttack
    {
        owner = droneBody.gameObject,
        weapon = option,
        // remember to multiply damageMultiplier so that the config option for GradiusOption is respected for your custom drone
        damage = damage * coefficient * GradiusOption.instance.damageMultiplier,
        force = force * GradiusOption.instance.damageMultiplier, // do the same for force
        // other initialization here
    }.Fire();
});
Clone this wiki locally