Skip to content

Built-in Services

Core automatically registers the following built-in services during initialization:

Timer manager responsible for managing all game timers:

const timerManager = Core.services.resolve(TimerManager);
// Create a timer
timerManager.schedule(1.0, false, null, (timer) => {
console.log('Executed after 1 second');
});

Performance monitor for tracking game performance:

const monitor = Core.services.resolve(PerformanceMonitor);
// Enable performance monitoring
monitor.enable();
// Get performance data
const fps = monitor.getFPS();

Scene manager for single-scene application lifecycle:

const sceneManager = Core.services.resolve(SceneManager);
// Set current scene
sceneManager.setScene(new GameScene());
// Get current scene
const currentScene = sceneManager.currentScene;
// Delayed scene switch
sceneManager.loadScene(new MenuScene());

World manager for managing multiple independent World instances (advanced use case):

const worldManager = Core.services.resolve(WorldManager);
// Create independent game worlds
const gameWorld = worldManager.createWorld('game_room_001', {
name: 'GameRoom',
maxScenes: 5
});
// Create scene in World
const scene = gameWorld.createScene('battle', new BattleScene());
gameWorld.setSceneActive('battle', true);
// Update all Worlds
worldManager.updateAll();

Use Cases:

  • SceneManager: Suitable for 95% of games (single-player, simple multiplayer)
  • WorldManager: Suitable for MMO servers, game room systems requiring complete isolation

Object pool manager:

const poolManager = Core.services.resolve(PoolManager);
// Create object pool
const bulletPool = poolManager.createPool('bullets', () => new Bullet(), 100);

Plugin manager for installing and uninstalling plugins:

const pluginManager = Core.services.resolve(PluginManager);
// Get all installed plugins
const plugins = pluginManager.getAllPlugins();