A brief overview on where you can find what you’re looking for when accessing Makinom’s data.
You can find an overview of all available classes (excluding the editor classes) in the API documentation.
When scripting for Makinom, either add the Makinom namespace (using) or implement your class in the Makinom namespace.
// add Makinom namespace using Makinom; // or use Makinom namespace namespace Makinom { }
Use only need to use one of the methods at a time, but using both doesn’t break anything. Please note that some parts of the Makinom classes are in separate namespaces, e.g. Makinom.Behaviours is used for all component classes of Makinom.
The Maki class
Everything you need is accessible through the Maki class. It holds references to all data and handlers for an easy and centralized access point.
The data you set up in the Makinom editor can be accessed through the various settings – e.g.:
- Maki.Formulas
The Formula settings, a formula can be accessed through Maki.Formulas.Get(int index). - Maki.InputKeys
The Input Key settings, a single input key can be accessed through Maki.InputKeys.Get(int index).
As you can see, the data access is straight forward, Maki.X gives access to the settings of X, to access a single instance, you can use Maki.X.Get(int index) – of course, X represents some kind of data, like Formulas, Input Keys or Machine Types.
The handlers are used to manage some part of a running game – some examples:
- Game Handler: Maki.Game
The Game Handler manages all in-game related data, e.g. the player, global variables, factions, game time, language, etc.
- Player Handler: Maki.Game.Player
The Player Handler holds the reference to the player’s game object and handles spawning the player’s prefab (if used).
The player’s game object can be accessed directly through Maki.Game.Player.GameObject. - Variable Handler: Maki.Game.Variables
This gives you access to the global variables.
The Variable Handler class is used for managing variables. - Save Games: Maki.SaveGame
The Save Game Handler manages saving and loading the game.
About Settings
All classes containing settings that are accessible and saved in the editor must be descendants of the IBaseData interface. The interface implements 2 functions, GetData and SetData, using a DataObject class to store the information in it.
It’s easiest to descend your class from the BaseData class, which already has a default implementation of the interface and handles saving/loading the data automatically.
About Save Games
Save games work similar to the settings class – instead of the IBaseData interface, you need to implement the ISaveData interface. You can find an sample implementation in the custom save data tutorial.
About Nodes
Adding custom nodes to schematics or formulas doesn’t require implementing them in a plugin – you can just add them in a script file in your Unity project. For Makinom to recognize the custom nodes, they must be in the correct namespace.
Schematic Nodes
Schematic nodes must be placed in the following namespace.
namespace Makinom.Schematics.Nodes { }
Formula Nodes
Formula nodes must be placed in the following namespace.
namespace Makinom.Formulas.Nodes { }