-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28dd2cd
commit fafdfc6
Showing
10 changed files
with
898 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# ECS Documentation | ||
|
||
## Table of Contents | ||
|
||
- [Introduction](#introduction) | ||
- [Creating a Plugin](#creating-a-plugin) | ||
- [Defining IPlugin](#defining-iplugin) | ||
- [Implementing IPlugin](#implementing-iplugin) | ||
- [Adding a Plugin via PluginHandler](#adding-a-plugin-via-pluginhandler) | ||
- [Using exemple](#using-exemple) | ||
|
||
## Introduction | ||
|
||
This ECS (Entity Component System) is designed as a robust framework for building complex simulations and games. It uses a registry system implemented as a singleton that contains sparse arrays with dense data storage, ensuring efficient and fast component access patterns. | ||
|
||
Alongside the core ECS features, this system is equipped with a JSON parsing overlay, facilitating easy data manipulation and storage in a structured format. A SceneManager is present to manage different scenes or states within the application, providing seamless transitions and organized state handling. | ||
|
||
The ECS also includes a logger utility, which developers can use to track events, errors, and other significant occurrences throughout the application lifecycle, aiding in debugging and monitoring. | ||
|
||
Lastly, a clock manager is integrated into the system to handle timing, allowing for consistent updates across different systems, essential for synchronization in simulations and real-time applications. | ||
|
||
## Creating a Plugin | ||
|
||
Developers can extend the functionality of the ECS by creating plugins. A plugin is a concrete implementation of the `IPlugin` interface, which initializes specific systems and adds them to the global system management. | ||
|
||
### Defining IPlugin | ||
|
||
The `IPlugin` interface is defined as follows: | ||
|
||
```cpp | ||
class IPlugin { | ||
public: | ||
virtual ~IPlugin() = default; | ||
virtual void initPlugin() = 0; | ||
virtual std::vector<std::function<void(std::size_t, std::size_t)>> getSystems() = 0; | ||
}; | ||
``` | ||
### Implementing IPlugin | ||
To create a new plugin, one should inherit from `IPlugin` and implement the `initPlugin` and `getSystems` methods. Here is an example implementation: | ||
```cpp | ||
#include <vector> | ||
#include <functional> | ||
class ExamplePlugin : public IPlugin { | ||
public: | ||
void initPlugin() override { | ||
// Specific initialization for this plugin | ||
} | ||
std::vector<std::function<void(std::size_t, std::size_t)>> getSystems() override { | ||
// Return the list of systems as functions | ||
return { | ||
fstSystem, | ||
scdSystem | ||
}; | ||
} | ||
}; | ||
``` | ||
|
||
### Adding a Plugin via PluginHandler | ||
|
||
Once the plugin is implemented, it can be added to the ECS using the `PluginHandler` class. Here's how you might add your plugin: | ||
|
||
```cpp | ||
#include "PluginHandler.h" | ||
#include "ExamplePlugin.h" | ||
|
||
int main() { | ||
ExamplePlugin myPlugin; | ||
|
||
enum SystemManagers { MENU, GAME, PLUGIN}; | ||
PluginHandler::addNewPlugin(myPlugin, static_cast<std::size_t>(SystemManagers::PLUGIN)); | ||
|
||
// Proceed with the rest of the program | ||
} | ||
``` | ||
|
||
Using `addNewPlugin`, the plugin is initialized and the systems it provides are added to the appropriate system manager. If a `managerId` is provided, the system will be added to a specific system manager. | ||
|
||
## Using exemple | ||
|
||
This is a game using this ecs: https://github.com/X-R-G-B/R-dash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# B-luga-physics | ||
|
||
*Plugin for b-luga ECS that add some physics and life* | ||
|
||
## Hightlight | ||
|
||
- Damage/Death systems | ||
- Collision systems | ||
- Basic and advanced Movements | ||
- Some components can be created with json | ||
|
||
## Install | ||
|
||
```cmake | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
b-luga-physics | ||
URL "https://github.com/X-R-G-B/B-luga/releases/latest/download/b-luga-physics.tar" | ||
DOWNLOAD_EXTRACT_TIMESTAMP TRUE | ||
) | ||
FetchContent_MakeAvailable(b-luga-physics) | ||
target_link_libraries( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
b-luga-physics | ||
) | ||
``` | ||
|
||
This will dowload the latest version of b-luga-physics, and link it + add headers to the project with cmake | ||
|
||
## Documentation | ||
|
||
# ECS Physics Plugin Documentation | ||
|
||
This ECS (Entity-Component-System) physics plugin is designed to integrate seamlessly with your game engine to provide comprehensive physics management. This includes collision detection, damage handling, death states, and a variety of movement physics such as basic linear movement, zigzag patterns, and bouncing. | ||
|
||
## Features | ||
|
||
- **Collision Management**: Efficiently manages collisions between entities in the game world. | ||
- **Damage System**: Automates the process of applying damage to entities upon collisions or other triggers. | ||
- **Death Handling**: Provides a system for handling the destruction or deactivation of entities after reaching a death state. | ||
- **Movement Physics**: | ||
- **Basic**: Enables entities to move in straight paths. | ||
- **ZigZag**: Allows entities to move in a predefined or random zigzag pattern. | ||
- **Bounce**: Implements bounce physics upon collisions with other entities or world boundaries. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Clock Class Documentation | ||
|
||
The `Clock` class is a utility for managing multiple high-resolution timers within an application. Each timer can be individually started, measured, and manipulated in terms of its elapsed time. | ||
|
||
## Public Methods | ||
|
||
### `Clock()` | ||
|
||
- **Description:** Constructor that initializes the `Clock` instance. | ||
|
||
### `std::size_t create(bool deferStart = false)` | ||
|
||
- **Description:** Creates a new timer. This timer is added to a collection of timers and can be referenced using the returned index value. | ||
- **Parameters:** | ||
- `deferStart`: A boolean indicating whether to start the timer immediately upon creation. If `true`, the timer starts in a deferred state. | ||
- **Returns:** A `std::size_t` that serves as an identifier for the newly created timer. | ||
|
||
### `std::size_t elapsedMillisecondsSince(std::size_t id)` | ||
|
||
- **Description:** Calculates the elapsed time in milliseconds since the specified timer was started. | ||
- **Parameters:** | ||
- `id`: A `std::size_t` identifier for the timer whose elapsed time is to be calculated. | ||
- **Returns:** The elapsed time in milliseconds as a `std::size_t`. Returns -1 if the timer has not been started. | ||
|
||
### `std::size_t elapsedSecondsSince(std::size_t id)` | ||
|
||
- **Description:** Calculates the elapsed time in seconds since the specified timer was started. | ||
- **Parameters:** | ||
- `id`: A `std::size_t` identifier for the timer whose elapsed time is to be calculated. | ||
- **Returns:** The elapsed time in seconds as a `std::size_t`. Returns -1 if the timer has not been started. | ||
|
||
### `std::size_t elapsedNanosecondsSince(std::size_t id)` | ||
|
||
- **Description:** Calculates the elapsed time in nanoseconds since the specified timer was started. | ||
- **Parameters:** | ||
- `id`: A `std::size_t` identifier for the timer whose elapsed time is to be calculated. | ||
- **Returns:** The elapsed time in nanoseconds as a `std::size_t`. Returns -1 if the timer has not been started. | ||
|
||
### `void decreaseSeconds(std::size_t id, std::size_t seconds)` | ||
|
||
- **Description:** Decreases the elapsed time of the specified timer by a given number of seconds. | ||
- **Parameters:** | ||
- `id`: A `std::size_t` identifier for the timer to be manipulated. | ||
- `seconds`: The number of seconds to subtract from the timer's current elapsed time. | ||
|
||
### `void decreaseMilliseconds(std::size_t id, std::size_t milliseconds)` | ||
|
||
- **Description:** Decreases the elapsed time of the specified timer by a given number of milliseconds. | ||
- **Parameters:** | ||
- `id`: A `std::size_t` identifier for the timer to be manipulated. | ||
- `milliseconds`: The number of milliseconds to subtract from the timer's current elapsed time. | ||
|
||
### `void decreaseNanoseconds(std::size_t id, std::size_t nanoseconds)` | ||
|
||
- **Description:** Decreases the elapsed time of the specified timer by a given number of nanoseconds. | ||
- **Parameters:** | ||
- `id`: A `std::size_t` identifier for the timer to be manipulated. | ||
- `nanoseconds`: The number of nanoseconds to subtract from the timer's current elapsed time. | ||
|
||
### `void restart(std::size_t id)` | ||
|
||
- **Description:** Restarts the specified timer. The elapsed time is reset to the current time. | ||
- **Parameters:** | ||
- `id`: A `std::size_t` identifier for the timer to be restarted. | ||
|
||
## Private Members | ||
|
||
### `std::vector<std::optional<std::chrono::high_resolution_clock::time_point>> _clocks` | ||
|
||
- **Description:** A collection of optional time points representing the start times of the timers. An `std::nullopt` value indicates a timer that has been created but not started or has been invalidated. | ||
|
||
--- | ||
|
||
This documentation provides a comprehensive guide to the methods available in the `Clock` class for creating and managing timers. It is important to manage the indices returned by the `create` method as they are needed to reference the specific timers for all subsequent operations. |
Oops, something went wrong.