Go to file
2024-03-11 00:36:46 +08:00
src Update ThreadRunner.cs 2024-03-02 21:49:04 +08:00
.gitattributes Initial commit 2023-06-07 02:09:20 +08:00
.gitignore change git ignore 2023-06-12 23:01:07 +08:00
DragonECS-Threads.asmdef Initial commit 2023-06-07 21:34:12 +08:00
DragonECS-Threads.asmdef.meta Initial commit 2023-06-07 21:34:12 +08:00
LICENSE Initial commit 2023-06-07 02:09:20 +08:00
LICENSE.meta change git ignore 2023-06-12 23:01:07 +08:00
package.json Update package.json 2024-03-10 23:26:17 +08:00
package.json.meta change git ignore 2023-06-12 23:01:07 +08:00
README-RU.md Update README-RU.md 2024-03-11 00:36:46 +08:00
README-RU.md.meta change git ignore 2023-06-12 23:01:07 +08:00
README.md update readme 2024-03-11 00:12:09 +08:00
README.md.meta change git ignore 2023-06-12 23:01:07 +08:00
src.meta change git ignore 2023-06-12 23:01:07 +08:00

Version License

Classic C# Threads for DragonECS

Languages: Русский English(WIP)

Support for processing entities in multiple threads, based on classic C# threads implementation.

NOTICE: The project is a work in progress, API may change.
While the English version of the README is incomplete, you can view the Russian version.


Installation

Versioning semantics - Open

Environment

Requirements:

  • Dependency: DragonECS
  • Minimum version of C# 7.3;

Optional:

  • Support for NativeAOT
  • Game engines with C#: Unity, Godot, MonoGame, etc.

Tested with:

  • Unity: Minimum version 2020.1.0;

Unity Installation

  • Unity Package

The framework can be installed as a Unity package by adding the Git URL in the PackageManager or manually adding it to Packages/manifest.json:

https://github.com/DCFApixels/DragonECS-ClassicThreads.git
  • Source Code

The framework can also be added to the project as source code.


Parallel iteration

EcsThreadHandler _handler;
public void Run(EcsPipeline pipeline)
{
    var group = _world.Where(out Aspect a);
    void Handler(ReadOnlySpan<int> entities)
    {
        foreach (var e in entities)
        {
            a.poses.Get(e).position += a.velocities.Read(e).value * _time.DeltaTime;
        }
    }
    group.IterateParallel(_handler ??= Handler, 1000);
}

NOTICE: The smaller the minimum size of the group part when dividing, the more threads can be utilized. In some situations, too many threads can negatively impact performance.

NOTICE: Inside the handler, creating/deleting entities, adding/removing components on entities is prohibited. Only modification of data within components is allowed.