Built-in Services
Core automatically registers the following built-in services during initialization:
TimerManager
Section titled “TimerManager”Timer manager responsible for managing all game timers:
const timerManager = Core.services.resolve(TimerManager);
// Create a timertimerManager.schedule(1.0, false, null, (timer) => { console.log('Executed after 1 second');});PerformanceMonitor
Section titled “PerformanceMonitor”Performance monitor for tracking game performance:
const monitor = Core.services.resolve(PerformanceMonitor);
// Enable performance monitoringmonitor.enable();
// Get performance dataconst fps = monitor.getFPS();SceneManager
Section titled “SceneManager”Scene manager for single-scene application lifecycle:
const sceneManager = Core.services.resolve(SceneManager);
// Set current scenesceneManager.setScene(new GameScene());
// Get current sceneconst currentScene = sceneManager.currentScene;
// Delayed scene switchsceneManager.loadScene(new MenuScene());WorldManager
Section titled “WorldManager”World manager for managing multiple independent World instances (advanced use case):
const worldManager = Core.services.resolve(WorldManager);
// Create independent game worldsconst gameWorld = worldManager.createWorld('game_room_001', { name: 'GameRoom', maxScenes: 5});
// Create scene in Worldconst scene = gameWorld.createScene('battle', new BattleScene());gameWorld.setSceneActive('battle', true);
// Update all WorldsworldManager.updateAll();Use Cases:
- SceneManager: Suitable for 95% of games (single-player, simple multiplayer)
- WorldManager: Suitable for MMO servers, game room systems requiring complete isolation
PoolManager
Section titled “PoolManager”Object pool manager:
const poolManager = Core.services.resolve(PoolManager);
// Create object poolconst bulletPool = poolManager.createPool('bullets', () => new Bullet(), 100);PluginManager
Section titled “PluginManager”Plugin manager for installing and uninstalling plugins:
const pluginManager = Core.services.resolve(PluginManager);
// Get all installed pluginsconst plugins = pluginManager.getAllPlugins();