Plugin System
The plugin system allows you to extend ECS Framework functionality in a modular way. Through plugins, you can encapsulate specific features (like network sync, physics engines, debug tools) and reuse them across multiple projects.
What is a Plugin
Section titled “What is a Plugin”A plugin is a class that implements the IPlugin interface and can be dynamically installed into the framework at runtime. Plugins can:
- Register custom services to the service container
- Add systems to scenes
- Register custom components
- Extend framework functionality
Plugin Benefits
Section titled “Plugin Benefits”| Benefit | Description |
|---|---|
| Modular | Encapsulate functionality as independent modules |
| Reusable | Use the same plugin across multiple projects |
| Decoupled | Separate core framework from extensions |
| Hot-swappable | Dynamically install and uninstall at runtime |
Quick Start
Section titled “Quick Start”Create a Plugin
Section titled “Create a Plugin”import { IPlugin, Core, ServiceContainer } from '@esengine/ecs-framework';
class DebugPlugin implements IPlugin { readonly name = 'debug-plugin'; readonly version = '1.0.0';
install(core: Core, services: ServiceContainer): void { console.log('Debug plugin installed'); }
uninstall(): void { console.log('Debug plugin uninstalled'); }}Install a Plugin
Section titled “Install a Plugin”import { Core } from '@esengine/ecs-framework';
Core.create({ debug: true });
// Install pluginawait Core.installPlugin(new DebugPlugin());
// Check if plugin is installedif (Core.isPluginInstalled('debug-plugin')) { console.log('Debug plugin is running');}Uninstall a Plugin
Section titled “Uninstall a Plugin”await Core.uninstallPlugin('debug-plugin');Get Plugin Instance
Section titled “Get Plugin Instance”const plugin = Core.getPlugin('debug-plugin');if (plugin) { console.log(`Plugin version: ${plugin.version}`);}Next Steps
Section titled “Next Steps”- Development - IPlugin interface and lifecycle
- Services & Systems - Register services and add systems
- Dependencies - Declare and check dependencies
- Management - Manage via Core and PluginManager
- Examples - Complete examples
- Best Practices - Design guidelines