EcsRx 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EcsRx --version 0.1.0
NuGet\Install-Package EcsRx -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EcsRx" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EcsRx --version 0.1.0
#r "nuget: EcsRx, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EcsRx as a Cake Addin
#addin nuget:?package=EcsRx&version=0.1.0

// Install EcsRx as a Cake Tool
#tool nuget:?package=EcsRx&version=0.1.0

EcsRx

EcsRx is a reactive take on the common ECS pattern with a well separated design using rx and adhering to IoC and other sensible design patterns.

Build Status Join Gitter Chat

New Info!

This is the future core library for ecsrx, the previous unity version will become a unity flavour of the ecsrx framework.

We have split this out and the unity version is available @ grofit/ecsrx.unity

Features

  • Simple ECS interfaces to follow
  • Fully reactive architecture
  • Favours composition over inheritance
  • Adheres to inversion of control
  • Lightweight codebase
  • Built in support for events (raise your own and react to them)
  • Built in support for pooling (easy to add your own implementation or wrap 3rd party pooling tools)
  • Built in support for plugins (wrap up your own components/systems/events and share them with others)

The core framework is meant to be used primarily by .net applications/games, there is a unity specific version here

Installation

The library was built to support .net standard 2.0, so you can just reference the assembly, and include a compatible rx implementation.

Quick Start

It is advised to look at the examples, which show the bare bones required setup, this is jus an example and we will look at having more support for specific frameworks going forward.

If you are using unity it is recommended you just ignore everything here and use the instructions on the ecsrx.unity repository.

Simple components

public class HealthComponent : IComponent
{
    public int CurrentHealth { get; set; }
    public int MaxHealth { get; set; }
}

You implement the IComponent interface which marks the class as a component, and you can optionally implement IDisposable if you want to dispose stuff like so:

public class HealthComponent : IComponent, IDisposable
{
    public ReactiveProperty<int> CurrentHealth { get; set; }
    public int MaxHealth { get; set; }
    
    public HealthComponent() 
    { CurrentHealth = new ReactiveProperty<int>(); }
    
    public void Dispose() 
    { CurrentHealth.Dispose; }
}

Any component which is marked with IDisposable will be auto disposed of by entities.

Simple systems

public class CheckForDeathSystem : IReactToEntitySystem
{
    public IGroup TargetGroup => new Group(typeof(HealthComponent)); // Get any entities with health component

    public IObservable<IEntity> ReactToEntity(IEntity entity) // Explain when you want to execute
    {
        var healthComponent = entity.GetComponent<HealthComponent>();
        return healthComponent.CurrentHealth.Where(x => x <= 0).Select(x => entity);
    }
    
    public void Execute(IEntity entity) // Logic run whenever the above reaction occurs
    {
        entity.RemoveComponent<HealthComponent>();
        entity.AddComponent<IsDeadComponent>();
    }
}

Systems are conventional, so there are many built in types like IReactToEntitySystem, IReactToGroupSystem, IManualSystem and many others, but you can read about them in the docs/systems, you can add your own conventional systems by extending ISystem and systems are handled for you by the ISystemExecutor.

Check the examples for more use cases, and the unity flavour of ecsrx which has more examples and demo projects, and drop into the gitter channel to ask any questions.

Running Examples

If you want to run the examples then just clone it and open examples project in the src folder, then run the examples, I will try to add to as the library matures.

There are also a suite of tests which are being expanded as the project grows, it was written with testability in mind.

Docs

See the docs folder for more information. (This will grow)

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on EcsRx:

Package Downloads
EcsRx.Infrastructure

A set of convention based classes to speed up the setup of projects using EcsRx

EcsRx.Plugins.ReactiveSystems

A set of convention based systems to speed up the setup of projects using EcsRx

EcsRx.Plugins.Views

A set of view based conventions to assist with separating view from logic/data

EcsRx.Plugins.Computeds

EcsRx plugin to add the notion of computeds to the system

EcsRx.Plugins.Batching

EcsRx plugin to allow batching of components in systems

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.158 125 3/26/2024
6.1.156 2,628 1/26/2023
6.1.151 3,023 11/28/2022
6.1.148 2,868 11/23/2022
6.1.145 2,802 11/22/2022
6.1.142 2,794 11/21/2022
6.0.131 3,935 5/5/2022
5.1.116 2,372 12/21/2021
5.0.110 2,665 7/15/2021
5.0.108 2,620 7/15/2021
5.0.101 2,577 6/28/2021
4.1.99 2,767 6/28/2021
4.1.97 2,790 6/5/2021
4.0.95 2,662 5/26/2021
4.0.93 2,790 5/22/2021
4.0.87 2,950 5/2/2021
4.0.80 2,922 4/30/2021
3.12.77 2,843 2/9/2021
3.12.73 2,692 12/16/2020
3.11.68 4,145 3/26/2020
3.10.65 2,901 3/24/2020
3.9.62 2,753 3/11/2020
3.9.60 2,682 3/11/2020
3.9.57 3,029 3/11/2020
3.8.54 3,062 3/11/2020
3.8.52 2,719 3/11/2020
3.7.50 2,792 3/3/2020
3.6.48 2,684 3/3/2020
3.6.45 2,598 3/3/2020
3.6.44 2,553 3/3/2020
3.5.41 2,845 12/16/2019
3.5.40 2,805 12/16/2019
3.5.39 2,752 12/16/2019
3.5.36 2,837 11/24/2019
3.5.34 3,127 4/8/2019
3.5.33 2,988 4/8/2019
3.4.32 3,429 4/3/2019
3.4.31 3,002 4/3/2019
3.3.30 3,043 4/3/2019
3.3.29 2,965 4/3/2019
3.3.28 3,075 3/19/2019
3.3.26 3,037 3/18/2019
3.3.23 2,986 3/15/2019
3.3.22 3,090 3/12/2019
3.3.21 3,034 3/12/2019
3.3.20 3,114 1/29/2019
3.3.19 3,103 1/29/2019
3.2.18 3,178 1/25/2019
3.2.17 3,096 1/25/2019
3.1.16 3,130 1/25/2019
3.1.15 3,074 1/25/2019
3.1.14 3,156 1/18/2019
3.1.13 3,124 1/18/2019
3.0.12 3,251 1/18/2019
3.0.11 3,146 1/18/2019
3.0.10 1,801 1/18/2019
3.0.8 1,781 1/18/2019
3.0.7 1,942 1/18/2019
3.0.0 3,228 1/18/2019
2.0.6 1,803 11/29/2018
2.0.4 1,896 10/3/2018
2.0.3 1,842 9/25/2018
2.0.2 1,857 9/25/2018
2.0.0 1,831 9/25/2018
1.2.3 1,881 9/18/2018
1.2.2 1,863 9/18/2018
1.2.0 1,874 9/17/2018
1.0.0 1,938 8/23/2018
0.4.0 1,725 7/30/2018
0.3.0 1,667 7/27/2018
0.2.0 1,885 7/25/2018
0.1.0 1,440 2/19/2018

Initial release