Skip to content

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.

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
BenefitDescription
ModularEncapsulate functionality as independent modules
ReusableUse the same plugin across multiple projects
DecoupledSeparate core framework from extensions
Hot-swappableDynamically install and uninstall at runtime
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');
}
}
import { Core } from '@esengine/ecs-framework';
Core.create({ debug: true });
// Install plugin
await Core.installPlugin(new DebugPlugin());
// Check if plugin is installed
if (Core.isPluginInstalled('debug-plugin')) {
console.log('Debug plugin is running');
}
await Core.uninstallPlugin('debug-plugin');
const plugin = Core.getPlugin('debug-plugin');
if (plugin) {
console.log(`Plugin version: ${plugin.version}`);
}