Public API for DLL Users
If you are using MCE's Lite, Basic, Pro, or Online tiers, the engine is distributed as a compiled DLL without source code. This guide explains the public API surface you can use to interact with and extend MCE from your own C# scripts.
The SDK Namespace
MCE exposes its public API through the OpenMon.MCE.SDK namespace. This contains clean interfaces that provide access to the engine's subsystems without coupling your code to internal implementations.
IMonsterCaptureEngine
The main entry point. All other interfaces are accessed through this:
using OpenMon.MCE.SDK;
public class MyGameManager : MonoBehaviour
{
[Inject] private IMonsterCaptureEngine engine;
private void Start()
{
Debug.Log($"MCE Version: {engine.Version}");
Debug.Log($"Monsters in DB: {engine.Database.MonsterCount}");
Debug.Log($"Player name: {engine.Player.PlayerName}");
}
}
Properties:
| Property | Type | Description |
|---|---|---|
Database | IMonsterDatabase | Read-only access to the monster/move/item database |
Battle | IBattleSystem | Battle state and events |
Player | IPlayerData | Player's roster, money, name, badges |
SaveSystem | ISaveSystem | Save and load operations |
Version | string | MCE engine version string |
IMonsterDatabase
Query monsters, moves, abilities, items, and types:
IMonsterDatabase db = engine.Database;
// Get a monster by dex number
MonsterEntry flameleon = db.GetMonster(152);
// Get a monster by name
MonsterEntry sparkbit = db.GetMonster("Sparkbit");
// Get all monsters
IReadOnlyList<MonsterEntry> allMonsters = db.GetAllMonsters();
// Get a move
Move thunderbolt = db.GetMove("Thunderbolt");
// Get all moves
IReadOnlyList<Move> allMoves = db.GetAllMoves();
// Get type effectiveness
float effectiveness = db.GetTypeEffectiveness(
MonsterType.Electric,
MonsterType.Water
);
// Returns 2.0 (super effective)
// Get all types
IReadOnlyList<MonsterType> types = db.GetAllTypes();
// Get total count
int count = db.MonsterCount;
IBattleSystem
Monitor battle state and respond to battle events:
IBattleSystem battle = engine.Battle;
// Check if a battle is in progress
if (battle.IsInBattle)
{
// Do something during battle
}
// Subscribe to battle events
battle.OnBattleStarted += HandleBattleStarted;
battle.OnBattleEnded += HandleBattleEnded;
private void HandleBattleStarted()
{
// Battle just started - maybe pause a timer, hide UI, etc.
}
private void HandleBattleEnded(bool playerWon)
{
// Battle ended - playerWon tells you the result
if (playerWon)
{
// Update custom win counter, trigger achievement, etc.
}
}
IPlayerData
Access the player's current state:
IPlayerData player = engine.Player;
// Player's monster team
Roster roster = player.PlayerRoster;
int teamSize = roster.Count;
MonsterInstance firstMonster = roster[0];
// Player's money
int money = player.Money;
// Player's name
string name = player.PlayerName;
// Player's badge count
int badges = player.BadgeCount;
ISaveSystem
Control save and load operations:
ISaveSystem saves = engine.SaveSystem;
// Save to slot 1
saves.Save(1);
// Load from slot 1
saves.Load(1);
// Check if a slot has data
bool hasData = saves.HasSaveData(1);
// Delete save data
saves.DeleteSave(1);
// Listen for save/load events
saves.OnSaved += (slot) => Debug.Log($"Saved to slot {slot}");
saves.OnLoaded += (slot) => Debug.Log($"Loaded from slot {slot}");
Dependency Injection
MCE uses Zenject (Extenject) for dependency injection. To access SDK interfaces in your scripts, use the [Inject] attribute:
using Zenject;
using OpenMon.MCE.SDK;
public class MyCustomFeature : MonoBehaviour
{
[Inject] private IMonsterCaptureEngine engine;
[Inject] private IMonsterDatabase database;
[Inject] private IBattleSystem battle;
// Zenject will automatically inject these before Start() is called
}
If you are new to dependency injection, here is the simple version: add [Inject] above a private field of the interface type, and Zenject will fill it in automatically. You do not need to call GetComponent or FindObjectOfType. The field will be populated before Start() runs.
If your script is not a MonoBehaviour managed by Zenject, you can resolve manually:
var engine = ProjectContext.Instance.Container.Resolve<IMonsterCaptureEngine>();
Inspector-Configurable Options
Many MCE systems expose configuration through the Unity Inspector without requiring code:
ScriptableObject Configuration
| Asset | Purpose | Location |
|---|---|---|
BattleConfigurationFile | Battle speed, XP multipliers, capture rates | Runtime/Configuration/ |
MonsterEntry | Monster species data | MonsterDatabase/ |
Move | Move definitions | MonsterDatabase/Moves/ |
WildEncountersSet | Encounter tables | Per-map assets |
BattleAI | AI strategy configuration | Battle/AI/ |
Component Configuration
Most MCE components expose key settings in the Inspector:
- PlayerCharacter: Walk speed, run speed, can run, has bike.
- EncounterTile: Encounter rate, encounter set reference.
- BattleLauncher: Battle scene reference, transition settings.
- SceneInfo: Map name, BGM, region, default encounters.
UnityEvents and Callbacks
MCE exposes several UnityEvents on its components that you can wire up in the Inspector without code:
PlayerCharacter Events
| Event | Fires When |
|---|---|
OnStepTaken | Player takes a step |
OnDirectionChanged | Player changes facing direction |
OnInteraction | Player presses the interact button |
Actor Events
Actors (NPCs, objects) have callback events:
| Event | Fires When |
|---|---|
OnInteracted | Player interacts with the actor |
OnGraphCompleted | The CommandGraph finishes execution |
Wire these up in the Inspector by dragging your MonoBehaviour into the event slot and selecting the method to call.
Extending MCE Without Source Code
Pattern 1: Event Listener
Create a MonoBehaviour that listens to MCE events and triggers your own logic:
public class AchievementTracker : MonoBehaviour
{
[Inject] private IBattleSystem battle;
[Inject] private IPlayerData player;
private int battlesWon;
private void OnEnable()
{
battle.OnBattleEnded += OnBattleEnded;
}
private void OnDisable()
{
battle.OnBattleEnded -= OnBattleEnded;
}
private void OnBattleEnded(bool playerWon)
{
if (playerWon)
{
battlesWon++;
if (battlesWon >= 100)
UnlockAchievement("Battle Master");
}
}
}
Pattern 2: Database Query
Use the database API to build custom features:
public class TypeMatchupHelper : MonoBehaviour
{
[Inject] private IMonsterDatabase database;
public List<MonsterType> GetWeaknesses(MonsterType type)
{
var weaknesses = new List<MonsterType>();
foreach (var attackType in database.GetAllTypes())
{
if (database.GetTypeEffectiveness(attackType, type) > 1f)
weaknesses.Add(attackType);
}
return weaknesses;
}
}
Pattern 3: Save Integration
Hook into the save system for custom data:
public class CustomSaveData : MonoBehaviour
{
[Inject] private ISaveSystem saveSystem;
private void OnEnable()
{
saveSystem.OnSaved += OnGameSaved;
saveSystem.OnLoaded += OnGameLoaded;
}
private void OnGameSaved(int slot)
{
// Save your custom data alongside MCE's save
string json = JsonUtility.ToJson(myCustomData);
PlayerPrefs.SetString($"custom_data_slot_{slot}", json);
}
private void OnGameLoaded(int slot)
{
// Load your custom data
string json = PlayerPrefs.GetString($"custom_data_slot_{slot}");
myCustomData = JsonUtility.FromJson<MyData>(json);
}
}
Pattern 4: CommandGraph + Custom Scripts
Combine CommandGraph events with your custom MonoBehaviours:
- Create your script with a public method.
- In the CommandGraph, add an Actor event node.
- In the Inspector, wire the event to your script's method.
This lets you trigger custom C# logic from visual scripting without modifying MCE internals.
What You Cannot Do Without Source Code
| Limitation | Workaround |
|---|---|
| Modify damage formula | Use configuration multipliers in BattleConfigurationFile |
| Add new battle modules | Use the battle event API to react to battle state |
| Change movement physics | Adjust speed and collision parameters via Inspector |
| Add new CommandGraph node types | Create custom MonoBehaviours triggered by Actor events |
| Modify UI layouts | Override prefabs (if exposed) or layer your own UI on top |
If you find the public API too limiting for your project, consider upgrading to the Source tier. It includes the full C# source code and architecture documentation for deep customization.
Assembly References
To reference MCE types in your scripts, your assembly definition (.asmdef) must reference:
{
"references": [
"OpenMon.MCE.Runtime"
]
}
If you are not using assembly definitions, MCE types are available globally through the DLL.
Best Practices
- Depend on interfaces, not implementations. Use
IMonsterCaptureEngine, not concrete classes. - Unsubscribe from events. Always remove event handlers in
OnDisableorOnDestroyto prevent memory leaks. - Do not cache stale data. Query the SDK each time you need current data, especially for
IPlayerData. - Use Zenject injection. Avoid
FindObjectOfTypeor singletons for MCE access. - Check the API reference. The SDK interfaces have XML documentation on every member. Your IDE will show tooltips.