Mod API - Geocube101/Iota-Modular-Jump-Gates GitHub Wiki

This mod has a modding API for accessing the various jump gate functions and variables


The current Mod API Version is 1.0


Installing the Mod API

The mod API can be found here: "https://github.com/Geocube101/Iota-Modular-Jump-Gates/tree/ed3eff005e5f01693b977b932e3a2de1ffc8f3aa/Iota%20Modular%20Jump%20Gates/API"

This contains all the wrapper code and classes to access the API. Simply copy the entire "ModAPI" folder into your mod or project folder.

Using the Mod API

The Mod API Session

The session is the class through which all other classes, functions, and variables may be accessed. To connect the session, call MyModAPISession.Init(IMyModContext)

This will connect to this mod and return a wrapper for this mod's session component. The wrapper may be accessed through the static MyModAPISession.Instance property

The mod API does have a version system. Should the API version your using be incompatible, the session instance will remain null. The result of MyModAPISession.Init(IMyModContext) is a single boolean indicating whether your mod successfully connected to the Mod API. Should this value be false, attempting to use the Mod API will fail.

Unless its guaranteed your mod will load after mine, the best bet for properly initializing the mod API is calling MyModAPISession.Init(IMyModContext) within your session's BeforeStart method. This allows time for my mod to begin listening for API connections.

Mod API Updates

The Mod API has a system in-place to validate the used version of the API matches or is supported by this mod.

Check the log for information on whether the mod API in your mod needs to be updated along with whether your mod has successfully connected to the API.

Extra Notes

Controller Block Settings

The jump gate controller exposes a method to get the controller's block settings.

These settings can be modified normally, however, the individual setting values will not update automatically and must be written back to the controller by setting the controller's block settings property.

// Get settings
MyAPIJumpGateController.MyAPIControllerBlockSettings settings = controller.BlockSettings;

// Do some modification to settings
settings.CanAutoActivate(true);
settings.AutoActivationDelay(10);

// Write settings back to update
controller.BlockSettings = settings;

Void Jumping

The Mod API exposes two modder only features: JumpToVoid and JumpFromVoid

These methods allow deleting objects using jump gates (JumpToVoid) and spawning prefabs from jump gates (JumpFromVoid)

See: MyAPIJumpGate for more information on the Jump Gate API


Closed and Suspended Objects / NullWrappers

The various constructs, gates, and blocks this API exposes may be closed or in the case of multiplayer client, suspended.

It is imperative that you make sure the status of a block before attempting certain actions on it. This mainly applies to suspended objects as they check their closed status implicitly anyway.

Suspended objects are objects that the server has open but are outside the client's simulation distance. These objects are simply data holders holding data for a null object. For jump gate controllers, drives, and capacitors, they will be suspended if IsNullWrapper returns true. For jump gates and constructs, call IsSuspended to check its status.

Data can still be retrieved from a suspended object but be careful as certain operations may cause a NullReferenceException though this should be mostly resolved.