Add DocFX documentation.

This commit is contained in:
2024-10-14 20:01:01 +02:00
parent f68f8f4b02
commit 9397073901
118 changed files with 64687 additions and 76 deletions

View File

@@ -0,0 +1,21 @@
# Architecture
## [Game](../api/Voile.Game.yml)
Entry point for your Voile game. It provides overridable methods for all stages of the lifetime, as well as exposes systems for rendering, input and resource management.
## Systems
Individual systems are the building blocks that you can use to construct your game. Default systems accessible in [Game](../api/Voile.Game.yml) class include [RenderSystem](../api/Voile.Rendering.RenderSystem.yml) and [InputSystem](../api/Voile.Input.InputSystem.yml).
They're convenient wrappers for various libraries and/or functionality providers (ex. particle systems, physics), requiring an initialization and shutdown stage to properly create and dispose their internal resources. As an example, an [FmodAudioSystem](../api/Voile.Audio.FmodAudioSystem.yml) requires to initialize [FMOD](https://www.fmod.com/) audio engine with certain parameters in `Start` method, and release native handles in `Dispose` method.
You can create custom systems by implementing [IStartableSystem](../api/Voile.IStartableSystem.yml), and/or [IUpdatableSystem](../api/Voile.IUpdatableSystem.yml). Custom systems can later be instantiated and started in `Game`'s `Initialize` step, and disposed in `Shutdown`. For updatable systems, refer to system-specific documentation, as they may require a different or fixed timestep separate from rendering.
## Resources
Resources are non-source dependencies of your game. Textures, audio, config data (saved in TOML, JSON, YAML, etc.), and fonts are good example of resources that a game may use. For these typical resources, you can load them and manage their lifetime using the [ResourceManager](../api/Voile.Resources.ResourceManager.yml).
For advanced use, you can also create custom resources tailored for your needs by inheriting a base [Resource](../api/Voile.Resource.yml). Next step in implementing a resource requires you to create a class that implements [IResourceLoader](../api/Voile.Resources.IResourceLoader-1.yml) and register it in the [ResourceManager](../api/Voile.Resources.ResourceManager.yml) with `AddResourceLoaderAssociation<T>()`, in your `Game`'s `Initialize` step.
Each resource can be instantiated from a byte buffer, removing the need of using [ResourceManager](../api/Voile.Resources.ResourceManager.yml). This is not recommended and should only be used for corner cases where using ResourceManager is not optimal, such as loading resources from memory, network, and other places outside of the file system.

View File

@@ -0,0 +1,20 @@
# Getting Started
> [!NOTE]
> Installation process is subject to change. Currently, Voile doesn't have a dedicated NuGet package and template, so the only way to obtain it is by using it as a git submodule and referencing Voile's .csproj in your project.
## Installing Voile as a Git submodule
1. Create a new console project hosting your game with `dotnet new console`.
2. Add Voile as a Git submodule with `git submodule add <REPOSITORY PATH>`. For more information about submodules, refer to the [official manual](https://git-scm.com/book/en/v2/Git-Tools-Submodules).
3. Include Voile.csproj in your project's .csproj file. Example:
```xml
<ItemGroup>
<ProjectReference Include="../Path/To/Voile/Repository/Voile.csproj" />
</ItemGroup>
```
4. Create a new C# source file hosting your game. For an example, refer to the [Introduction](introduction.md) page.
## Shipping your game

107
Voile/docs/introduction.md Normal file
View File

@@ -0,0 +1,107 @@
# Introduction
> [!IMPORTANT]
> Voile is still work in progress and not production-ready. Expect stability and performance issues, lacking documentation, and experimental APIs.
Welcome to the documentation for Voile, a cross-platform game framework written in C#.
## Considerations
Before using Voile or any other software, its important to know if a particular engine/framework is suitable for your workflow, goals and requirements. **Here's what Voile doesn't try to be**:
- **A fully fledged game IDE with a scene editor**. Voile will have its own editors for some resources (particles, asset bundles, etc.) and a default module for a scene graph based on Entity Component architecture, but it will not provide a full blown scene editor in itself. Consider alternatives such as Godot or Unity if you require tight integration with a WYSIWYG editor.
- **A cutting edge 3D engine**. Voile will provide basic 3D functionality suitable for PSX or cartoon-styled games, but if you want to make AAA grade 3D graphics, consider Unreal or Unity.
- **A dedicated game engine**. Voile will never provide tools for a specific genre. Think of it as a collection of libraries that simplify work with rendering, input, physics, and creating your own tools for modifying your game-specific content. Entity management, order of execution, etc. is managed manually by the user.
## What's missing
Voile is still work in progress, but has a [roadmap](roadmap.md) with planned features.
## Features
- 2D rendering.
- **Minimal size and fast startups**. Voile is built with NativeAOT compatibility in mind, doesn't ship unnecessary things, and doesn't run anything without your knowledge.
- **Full control over resources and lifetime**. No default main loop behavior, implicit system initialization (more on that later), and resources instantiation.
- **Content hot-reloading**. All resources can be reloaded while the game is running, reducing iteration time.
## Minimal project example
### TestGame.cs
```csharp
using Voile;
using Voile.Resources;
using Voile.Utils;
public class TestGame : Game
{
public override string ResourceRoot => "Resources/";
// Called when it's time to initialize the subsystems, or modify default game settings or system settings.
public override void Initialize()
{
// Initializes systems with defaults.
InitializeDefault();
}
// Called when it's time to load the game's resources, such as images or sounds.
protected override void LoadResources()
{
if (!ResourceManager.TryLoad("my_sound", "sounds/test_sound.ogg", out Sound? _testSound))
{
// Handle resource load failure here.
// Display an on-screen alert, close the game, reload from a different path, etc.
}
if (!ResourceManager.TryLoad<Font>("inter_regular", "fonts/Inter-Regular.ttf", out Font? _font))
{
// Handle resource load failure here.
// Display an on-screen alert, close the game, reload from a different path, etc.
}
}
// Called when it's safe to manipulate the resources or/and systems.
// You can safely create game objects, scenes, etc. in this method.
protected override void Ready()
{
Input.AddInputMapping("play", new InputAction[] { new KeyInputAction(KeyboardKey.Spacebar) });
Input.AddInputMapping("sprint", new InputAction[] { new KeyInputAction(KeyboardKey.LeftShift) });
Input.AddInputMapping("toggle_fullscreen", new InputAction[] { new KeyInputAction(KeyboardKey.F11) });
}
// Called when everything has been readied to start the main loop.
protected override void Run()
{
while (Renderer.ShouldRun)
{
if (Input.IsActionPressed("play"))
{
_logger.Echo("Spacebar pressed!");
}
Renderer.BeginFrame();
// Sets transform for drawing at the center of the screen. We won't use transform pivot.
Renderer.SetTransform(position: Renderer.WindowSize / 2, pivot: Vector2.Zero);
Renderer.DrawCircle(radius: 16f, Color.White);
Renderer.EndFrame();
}
}
// Called when the application quits and it's safe to clean up.
public override void Shutdown()
{
// Default resource shutdown and cleanup.
ShutdownDefault();
}
private Logger _logger = new(nameof(TestGame));
}
```
### Program.cs
```csharp
// Use the default constructor for game.
var game = new TestGame();
game.Start();
```

60
Voile/docs/roadmap.md Normal file
View File

@@ -0,0 +1,60 @@
# Roadmap
## Core
- ~~Add and implement interfaces for systems (ISystem, IUpdatableSystem, etc.)~~
- Minimize amount of possible null references.
- Serialization and deserialization of Resources from and to TOML files.
- Add documentation for common classes.
- Hot reloading of resources.
## I/O
- Use GUIDs and string ID maps for fetching resources instead of string IDs alone.
- (stretch goal) Make async API for ResourceManager
- (stretch goal/1.0) Streamed resource loading
- (stretch goal) Virtual file system
## Serialization
- Serialize attribute.
- Add automatic serialization of resources through code generation and System.Text.Json.
- Provide means for fetching key/value configuration (INI? TOML?)
- Expose some sort of ConfigFile class for safe key/value configuration fetching.
## Rendering
- ~~API for drawing textured quads~~
- ~~Camera API~~
- Arbitrary mesh rendering API.
- (1.0) Create WebGPU renderer (StandardRenderer)
## Audio
- ~~Integrate FMOD~~
- 2D audio abstraction
## Misc
- ~~Asset manager~~
- ~~Separate engine and game into separate projects~~
- ~~Particle system~~
## SceneGraph module
- ~~Layers (sorting mechanism)~~
- Full overhaul using Entity Component architecture (not to be mistaken with ECS).
- Save/load scenes from file
## Input
- ~~Action system~~
- Make action system use an InputMap resource instead.
- Gamepad support
## UI
- Immediate mode API.
- Styling.
- Basic input elements (button, text field, toggle).
- Containers (vertical and horizontal).

9
Voile/docs/toc.yml Normal file
View File

@@ -0,0 +1,9 @@
- name: Basics
- href: introduction.md
- href: getting-started.md
- href: architecture.md
- name: Examples
- name: Optional Systems
- name: Scene Graph Module
- name: Other
- href: roadmap.md