跳到主要内容

SDK API Overview

The MCE SDK provides a clean, stable public API surface for interacting with the engine from your game code. All SDK interfaces live in the OpenMon.MCE.SDK namespace.

设计原则

  • Interface-based: All public APIs are exposed as interfaces, not concrete classes. This allows the implementation to evolve without breaking your code.
  • Read-heavy: Most SDK methods are read-only queries. Mutations happen through the engine's internal systems (CommandGraph, Inspector, etc.).
  • Event-driven: Key state changes are communicated through C# events.
  • Zenject-injected: Access SDK interfaces via [Inject] attribute.

入口点

The main entry point is IMonsterCaptureEngine:

[Inject] private IMonsterCaptureEngine engine;

From this interface, you access all subsystems:

PropertyInterfacePurpose
engine.DatabaseIMonsterDatabaseQuery monsters, moves, items, types
engine.BattleIBattleSystemBattle state and events
engine.PlayerIPlayerDataPlayer roster, money, name, badges
engine.SaveSystemISaveSystemSave/load operations
engine.VersionstringEngine version string

快速示例

using OpenMon.MCE.SDK;
using Zenject;

public class GameDashboard : MonoBehaviour
{
[Inject] private IMonsterCaptureEngine engine;

private void Start()
{
// Query database
var allMonsters = engine.Database.GetAllMonsters();
Debug.Log($"Database has {allMonsters.Count} monster species");

// Check player state
Debug.Log($"Player: {engine.Player.PlayerName}");
Debug.Log($"Team size: {engine.Player.PlayerRoster.Count}");
Debug.Log($"Money: {engine.Player.Money}");
Debug.Log($"Badges: {engine.Player.BadgeCount}");

// Listen to battle events
engine.Battle.OnBattleStarted += () => Debug.Log("Battle!");
engine.Battle.OnBattleEnded += (won) => Debug.Log($"Won: {won}");

// Save/load
if (engine.SaveSystem.HasSaveData(0))
Debug.Log("Save slot 0 has data");
}
}

See the individual API pages for detailed documentation of each interface.