Skip to main content

Engine design document

This is a rough sketch of the final engine. Treat this as some type of "this is how a 1.0 will look". The current iteration of the engine does not match this, but features will be indicated with symbols: βœ”πŸ› βŒ.

Entries marked with βœ” are mostly or fully complete (are used widely throughout the engine and plugins), ❌ means not started yet, and πŸ›  means this area is a work in progress. These markers will be updated periodically.

Overall architecture​

There are generally 3 layers:

  • Application βœ” - This is game/application logic, leveraging the engine's subsystems.
  • Application framework πŸ›  - Takes care of launching all the engine's subsystems needed for a particular application type. There should be a couple templates to minimise bloat:
    • CLI tool - Uses a few basic subsystems (logging, plugin system, virtual filesystem, asset system).
    • Application - Utilises all engine subsystems (e.g. rendering and audio on top of prior ones) to run games or desktop GUI tools.
    • Game - Like Application, but it launches a moddable game, so it initialises a little differently.
  • Launcher βœ” - A concrete executable that launches the application framework with one of the aforementioned templates.

Modules are organised into a few categories:

  • Core modules
  • Addon modules
  • System modules
  • Plugins

Core libraries​

Most of these libraries are designed to be engine-agnostic, meaning you can use these outside of Elegy.

  • Elegy.Common - Utility library βœ”
  • Elegy.Framework - Engine core, handles engine configuration etc. πŸ› 
    • CLI tool template ❌
    • Application template ❌
    • Game template βœ”
  • Elegy.ECS - Eventful entity component system library πŸ› 
  • Elegy.Scripting - C# scripting library ❌
  • Elegy.RenderBackend - Veldrid/Vulkan utilities βœ”

Addon libraries​

These are optional libraries you can use within an Elegy application. Unlike plugins that are loaded dynamically at runtime, addons are used by developers at design time.

  • Elegy.Avalonia πŸ› 
    • Integration with Avalonia for building desktop GUI apps ❌
    • In-game Avalonia UI πŸ› 
  • Elegy.VirtualReality ❌
    • VR support powered by OpenXR
    • Full body tracking support via SteamVR

System modules​

These libraries implement engine subsystems, but are mostly independent (❌) of each other.

  • Elegy.AssetSystem βœ”
    • Quake 3-style materials βœ”
    • Data-driven shaders βœ”
    • Model asset loading (plugin-based) βœ”
    • Texture asset loading (plugin-based) βœ”
    • Level loading (plugin-based) βœ”
  • Elegy.AudioSystem (plugin-based) ❌
    • Sound sources, listener
    • Sound FX
    • Geometric acoustics
  • Elegy.CommandSystem πŸ› 
    • Note: currently called Elegy.ConsoleSystem
    • Console frontends βœ”
      • External developer console πŸ› 
    • Console commands βœ”
    • CVars ❌
  • Elegy.FileSystem
    • Mounting game/mod paths βœ”
    • Mounting addon paths πŸ› 
  • Elegy.Input
    • Keyboard, mouse input βœ”
    • Gamepad & joysticks πŸ› 
  • Elegy.LogSystem
    • Note: currently part of Elegy.ConsoleSystem
    • Logging, warnings, errors βœ”
    • Tagged logging βœ”
    • File logger ❌
  • Elegy.NetworkSystem ❌
    • Utility layer on top of ENet or similar
  • Elegy.PlatformSystem
    • Windowing (injected) βœ”
    • Fundamental engine configuration, e.g. headless mode βœ”
  • Elegy.PluginSystem
    • Flexible plugin system βœ”
    • Plugin dependencies πŸ› 
    • Plugin reloading πŸ› 
    • Plugin versioning πŸ› 
  • Elegy.RenderSystem πŸ› 
    • Slang-based shader system πŸ› 
    • Renderable objects:
      • Mesh entities βœ”
      • Batches ❌
      • Volumes ❌
      • Lights ❌
    • Views & rendering into windows βœ”
    • Debug rendering πŸ› 
    • Render styles (plugin-based) πŸ› 
      • Style99 - Lightmapped 90s style shading πŸ› 
      • StyleModern - Physically-based shading, POM, reflections etc. ❌

Legend:

  • Plugin-based: implemented in a plugin, engine just provides API
  • Injected: implemented externally (e.g. in a launcher), engine just sees API

Game SDK​

  • AI ❌
    • Goal-oriented action planning
    • Use Recast/DotRecast
  • Animation ❌
    • Animation playback and management
    • Animation blending
    • Animation channels
    • Inverse kinematics
  • Client πŸ› 
    • Client controllers (handle input and interaction with the game world) βœ”
    • Keybind system ❌
    • View bobbing and viewport management ❌
  • Entity system βœ”
    • Reactive ECS βœ”
    • Source-style IO βœ”
    • Scripting ❌
  • Game sessions βœ”
    • Menu state, loading state, playing state, paused state etc. βœ”
    • Linking a client into the game βœ”
  • Gamemodes ❌
    • Campaign, deathmatch, team deathmatch, co-op etc.
  • Netcode πŸ› 
    • Mainly intended for LAN co-op
    • Quake-style client-server with prediction and rollback ❌
    • Singleplayer bridge βœ”
  • Particles ❌
  • Physics πŸ› 
    • Rigid bodies πŸ› 
    • Constraints ❌
  • Save-load system ❌
  • UI ❌
    • ImGui for quick'n'easy stuff
    • Custom game UI system for everything else

Tools​

Every engine needs good tooling. Elegy would come with these:

  • Elegy.Librarian - Plugin-based game data editor. Used to edit e.g. vehicle configs, NPC profiles, difficulty settings and so on. Editing tools provided by plugins. ❌
  • Elegy.MagicWand - Manages projects and Elegy Engine installations. ❌
  • Elegy.MapCompiler - EMC for short, it compiles levels. πŸ› 
    • Utilises the plugin system to bake game-specific or render-style-specific data. ❌
    • Usable with TrenchBroom. βœ”
  • Elegy.ModelEditor - Based on Elegy.Librarian, a tool for importing models, fixing them up and editing game-specific metadata. Or just viewing them. ❌
  • Elegy.ShaderTool - Compiles Slang shaders and generates extra data for the render system. πŸ› 

A custom map editor may be a possibility, but that would be way after v1.0.

Workflow and features​

Overall:​

  • Quake-style workflow.
  • There’s an engine executable in the root folder, accompanied by game folders and an engine folder.
  • The engine folder contains base engine assets, e.g. a β€œmissing model” model, a β€œmissing texture” texture and whatnot.
  • Each game/mod folder contains a configuration file that describes it as well as its plugins and dependencies.

Mapping:​

  • You’d use an external level editor like TrenchBroom, J.A.C.K. or NetRadiant-custom.
  • You’d also use a map compiler, either as part of your level editor’s compile config, or through a console command.

Modelling:​

  • You’d use a model editor like Blender.
  • Export GLTF for basic props, import via custom tool for extra attributes for complex models.

Texturing, sound design and other trivial asset types:​

  • Quite simply place your PNGs/WAVs/FLACs into a textures/sounds folder, it’s just there.

UI:​

  • Declarative C# UI files sitting in a directory.

Scripting:​

  • Naked C# scripts, S&box-style.
  • Level scripts
  • UI scripts
  • NPC scripts?
  • Weapon scripts?
  • Vehicle scripts?