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,40 @@
using Voile;
namespace Voile.Audio;
public abstract class AudioSystem : IStartableSystem, IUpdatableSystem, IDisposable
{
public void Start() => Initialize();
public void Update(double deltaTime) => Update();
public void Dispose()
{
Shutdown();
GC.SuppressFinalize(this);
}
protected abstract void Initialize();
protected abstract void Update();
protected abstract void Shutdown();
// BUS
public abstract void CreateBus(string busName);
public abstract void SetBusVolume(string busName, float volume);
public abstract float GetBusVolume(string busName);
// SOUND
public abstract void PlaySound(Sound sound, float pitch, float volume, string bus = "Master");
public void PlaySound(Sound sound, string bus = "Master") => PlaySound(sound, 1.0f, 1.0f, bus);
public SoundInstance CreateInstance(Sound sound)
{
var instance = new SoundInstance(this, sound);
return instance;
}
// EFFECTS
public abstract void AddBusEffect<T>(T effect, string bus = "Master") where T : AudioEffect;
private LehmerRandom _random = new LehmerRandom();
}

View File

@@ -1,3 +1,4 @@
using Voile.Input;
using Voile.Rendering;
using Voile.Resources;
@@ -34,6 +35,9 @@ namespace Voile
/// </summary>
public virtual string Name => "";
/// <summary>
/// Default game constructor.
/// </summary>
public Game()
{
ResourceManager = new ResourceManager();
@@ -41,6 +45,19 @@ namespace Voile
Renderer = new RaylibRenderSystem();
}
/// <summary>
/// Game constructor with custom systems.
/// </summary>
/// <param name="resourceManager"></param>
/// <param name="inputSystem"></param>
/// <param name="renderSystem"></param>
public Game(ResourceManager resourceManager, InputSystem inputSystem, RenderSystem renderSystem)
{
ResourceManager = resourceManager;
Input = inputSystem;
Renderer = renderSystem;
}
/// <summary>
/// Starts the game application.
/// This involves initializing the required subsystems, loading resources from the disk, and then preparing the subsystems for running in the main loop.
@@ -77,7 +94,7 @@ namespace Voile
}
/// <summary>
/// Called when it's time to initialize the subsystems, or modify default game settings or systems.
/// Called when it's time to initialize the subsystems, or modify default game settings or system settings.
/// </summary>
public abstract void Initialize();
/// <summary>
@@ -85,7 +102,7 @@ namespace Voile
/// </summary>
protected abstract void LoadResources();
/// <summary>
/// Called when it's safe to manipulate with the resources or/and systems.
/// Called when it's safe to manipulate the resources or/and systems.
/// You can safely create game objects, scenes, etc. in this method.
/// </summary>
protected abstract void Ready();

View File

@@ -1,4 +1,4 @@
namespace Voile
namespace Voile.Input
{
public abstract class InputAction
{

View File

@@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Voile.Utils;
namespace Voile
namespace Voile.Input
{
/// <summary>
/// A system providing means for collecting user input, as well as defining custom <see cref="InputAction"/> list.

View File

@@ -1,10 +1,10 @@
using System.Numerics;
using Raylib_cs;
namespace Voile
namespace Voile.Input
{
/// <summary>
/// An input system implemented using Raylib's API. Used by default together with <see cref="RaylibRenderer"/>.
/// An input system implemented using Raylib's API. Used by default together with <see cref="RaylibRenderSystem"/>.
/// </summary>
public class RaylibInputSystem : InputSystem
{

View File

@@ -165,7 +165,7 @@ namespace Voile.Rendering
y = transformPosition.Y,
width = size.X,
height = size.Y
}, transformOffset, transformRotation, VoileColorToRaylibColor(color));
}, transformPivot, transformRotation, VoileColorToRaylibColor(color));
}
public override void DrawDebugText(string text, int fontSize, Color color)
@@ -211,7 +211,7 @@ namespace Voile.Rendering
}
var rayFont = _fontPool[font.Handle];
Raylib.DrawTextPro(rayFont, text, transformPosition, transformOffset, transformRotation, font.Size, 0.0f, VoileColorToRaylibColor(color));
Raylib.DrawTextPro(rayFont, text, transformPosition, transformPivot, transformRotation, font.Size, 0.0f, VoileColorToRaylibColor(color));
}
protected override int GetMonitorWidth(int monitorId)

View File

@@ -94,7 +94,7 @@ namespace Voile.Rendering
public void ResetTransform()
{
transformPosition = Vector2.Zero;
transformOffset = Vector2.Zero;
transformPivot = Vector2.Zero;
transformRotation = 0.0f;
}
@@ -102,12 +102,12 @@ namespace Voile.Rendering
/// Sets transforms for the next draw operation.
/// </summary>
/// <param name="position">Global transform position.</param>
/// <param name="offset">Local offset point around which shapes will rotate.</param>
/// <param name="pivot">Local offset point around which shapes will rotate.</param>
/// <param name="rotation">Rotation.</param>
public void SetTransform(Vector2 position, Vector2 offset, float rotation = 0.0f)
public void SetTransform(Vector2 position, Vector2 pivot, float rotation = 0.0f)
{
transformPosition = position;
transformOffset = offset;
transformPivot = pivot;
transformRotation = rotation;
}
/// <summary>
@@ -153,7 +153,7 @@ namespace Voile.Rendering
public abstract void DrawTexture(Texture2d texture, Color tint);
protected Vector2 transformPosition, transformOffset;
protected Vector2 transformPosition, transformPivot;
protected float transformRotation;
}

View File

@@ -8,9 +8,10 @@ namespace Voile.Resources
{
public string ResourceRoot { get; set; } = "Resources/";
public bool TryLoad<T>(string resourceId, string path) where T : Resource
public bool TryLoad<T>(string resourceId, string path, [NotNullWhen(true)] out T? result) where T : Resource
{
T? resource = null;
T? resource = default;
result = null;
var fullPath = Path.Combine(ResourceRoot, path);
@@ -46,6 +47,7 @@ namespace Voile.Resources
_logger.Info($"\"{resourceId}\" was loaded successfully.");
result = loadedResource;
return true;
}

View File

@@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using Voile.Audio;
using Voile.Input;
using Voile.Rendering;
namespace Voile.SceneGraph

View File

@@ -1,6 +1,7 @@
using Voile.Resources;
using Voile.Rendering;
using System.Text.Json.Serialization;
using Voile.Input;
namespace Voile.SceneGraph
{

View File

@@ -1,5 +1,6 @@
using System.Text.Json;
using Voile.Audio;
using Voile.Input;
using Voile.Rendering;
using Voile.Resources;

View File

@@ -1,39 +0,0 @@
namespace Voile.Audio
{
public abstract class AudioSystem : IStartableSystem, IUpdatableSystem, IDisposable
{
public void Start() => Initialize();
public void Update(double deltaTime) => Update();
public void Dispose()
{
Shutdown();
GC.SuppressFinalize(this);
}
protected abstract void Initialize();
protected abstract void Update();
protected abstract void Shutdown();
// BUS
public abstract void CreateBus(string busName);
public abstract void SetBusVolume(string busName, float volume);
public abstract float GetBusVolume(string busName);
// SOUND
public abstract void PlaySound(Sound sound, float pitch, float volume, string bus = "Master");
public void PlaySound(Sound sound, string bus = "Master") => PlaySound(sound, 1.0f, 1.0f, bus);
public SoundInstance CreateInstance(Sound sound)
{
var instance = new SoundInstance(this, sound);
return instance;
}
// EFFECTS
public abstract void AddBusEffect<T>(T effect, string bus = "Master") where T : AudioEffect;
private LehmerRandom _random = new LehmerRandom();
}
}

View File

@@ -1,3 +1,5 @@
namespace Voile;
public interface IStartableSystem
{
void Start();

View File

@@ -1,8 +1,10 @@
using System.Numerics;
using ImGuiNET;
using Raylib_cs;
using Voile.Input;
using Voile.Rendering;
using KeyboardKey = Voile.Input.KeyboardKey;
using MouseButton = Voile.Input.MouseButton;
namespace Voile.SceneGraph
{
@@ -24,7 +26,7 @@ namespace Voile.SceneGraph
protected override void OnUpdate(double dt)
{
_controller.Update(dt, Input);
// _controller.Update(dt, Input);
}
protected override void OnBeginDraw(RenderSystem renderer)