MageAPI
An comprehensive framework for creating custom content in Mage Arena.
模組介紹 作者原文
MageAPI
MageAPI is a comprehensive BepInEx plugin that provides a powerful framework for creating custom content in Mage Arena. The API simplifies the process of adding new damageables, event subscriptions, and game mechanics while handling complex backend systems so modders can focus on design and implementation.
Features
- Entity Health Management: Robust health system with event-driven damage handling
- Collision Detection: Advanced collision system with filtering and event triggers
- Instance Management: Centralized access to game singletons and object pools
- Event System: Comprehensive event system for game lifecycle hooks
- Modular Architecture: Clean, organized structure for easy extensibility
Installation
- Prerequisites:
- Mage Arena with BepInEx 5.4.21 or newer
- Installation:
MageArena/
└── BepInEx/
└── plugins/
└── MageAPI
└── MageAPI.dll
Core Components
HealthModule
A comprehensive health management system that wraps MonoBehaviour entities with health functionality:
- Custom health field integration
- Death/respawn handling
- Event-driven health changes
- Collider management
DamageCollisionCheck
Advanced collision detection system:
- Trigger and collision event handling
- Health module integration
- Collider filtering capabilities
- Rigidbody support
InstanceManager
Centralized access to game instances:
- Singleton managers (MainMenu, Bootstrap, Coloseum, etc.)
- Object pools for all entity types
- Player and NPC instance management
Event System
Comprehensive event architecture:
- Client events
- Player events
- Game events
- Miscellaneous events
Usage Examples
Creating a Custom Entity with Health
public class CustomEntity: MonoBehaviour
{
private HealthModule _healthModule;
private void Start()
{
_healthModule = gameObject.AddComponent();
_healthModule.Setup(this, 100f, OnDeath);
}
private void OnDeath()
{
// Custom death logic
}
}
Handling Collision Events
public class DamageDealer: MonoBehaviour
{
private DamageCollisionCheck _collisionCheck;
private void Start()
{
_collisionCheck = gameObject.AddComponent();
_collisionCheck.OnEnterHealthCollider += OnDamageableHit;
}
private void OnDamageableHit(Collider collider, HealthModule health)
{
health.Health -= 10f;
}
}
Using Game Events
public class GameEventHandler
{
public GameEventHandler()
{
Events.Player.PlayerDeathEvent.After += OnPlayerDeath;
Events.Game.GameStartEvent.After += OnGameStart;
}
private void OnPlayerDeath((PlayerInstance, object?) args)
{
// Handle player death
}
private void OnGameStart()
{
// Handle game start
}
}
API Structure
Namespaces
- MageAPI.Enums: Game enumerations and types
- MageAPI.Interfaces: Core interfaces
- MageAPI.Modules: Modular systems and utilities
- MageAPI.Modules.Events: Event system architecture
- MageAPI.Mono: MonoBehaviour components and extensions
- MageAPI.Managers: Management systems and singletons
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: