Skip to content

Code Architecture

Alex Pineda edited this page Sep 29, 2023 · 6 revisions

Bootup

  • Electron main/index.ts: Entry point for initializing settings and browser window. Standard Electron-based initialization.
  • titan-reactor.ts: Executes after window creation, contains core application logic.

Scene Management

  • Flow: Loading Scene -> Home Page -> Interstitial Scene -> Replay Scene or Map Scene
  • Core Logic: Centralized in stores/scene-store. Simplifies scene transitions.

Map & Replay Loading

  • Abstraction: Maps and Replays are scenes.
  • Scene Loaders: replay-scene-loader and map-scene-loader manage loading.
  • Global Events: Initiated by load-map-file and load-replay-file, managed in titan-reactor.ts. Event-driven architecture.

Game Management

  • game-scene: Common API for map and replay scenes.
  • world-composer: Engine used by game-scene. Decouples game logic from engine.

Asset Management

  • Global Assets: Managed by assets.ts for loading, game-store for read/write.
  • Map Textures: Not cached, regenerated on load.

OpenBW

  • WASM Build: Uses WebAssembly for performance.
  • Heap Mapping: Managed in openbw.ts and openbw-composer.

Global Events

  • System: Centralized in global-events.ts. Manages system-level and user-level events.

World Events

  • In-Game Events: Triggered events like unit deaths, observed by plugins and macros.

Settings

  • System: Mostly managed by settings.ts and messages passed between Configuration UI and this system
  • Data: Stored as JSON, contains app settings, macros and enabled plugins information.

Plugins & Macros

  • Plugins: External, loaded by plugin-manager.ts. Plugin settings are stored in the plugins package.json config object and not in the app settings.
  • Macros: Internal, user-created, initiated by triggers. Macros are stored in the app settings.

Plugin Runtime

  • UI: Managed by plugin-system-ui.ts.
  • Server: server.ts handles runtime loading and transpiling of JSX plugins.

Plugin Host (Native Plugins)

  • Management: plugin-system-native.ts initiates and manages native plugins.

Command Center

  • A separate window where the configuration UI is held and the user may modify settings, macros and plugins.