EcsRx.Infrastructure 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EcsRx.Infrastructure --version 0.2.0                
NuGet\Install-Package EcsRx.Infrastructure -Version 0.2.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.Infrastructure" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EcsRx.Infrastructure --version 0.2.0                
#r "nuget: EcsRx.Infrastructure, 0.2.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.Infrastructure as a Cake Addin
#addin nuget:?package=EcsRx.Infrastructure&version=0.2.0

// Install EcsRx.Infrastructure as a Cake Tool
#tool nuget:?package=EcsRx.Infrastructure&version=0.2.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 just an example which uses a console based application, in the real world you will probably be targetting Unity or Monogame or maybe even Godot etc, but all that differs is your EcsRxApplication implementation (assuming you are using the pre-made infrastructure module).

If you are using unity it is recommended you just ignore everything here and use the instructions on the ecsrx.unity repository as that has not been fully mapped over to use this core version yet so is its own eco system until that jump is made.

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.

Note on infrastructure/view namespaces and going forward

This library started out as a unity specific project but has moved to a generic .net library, due to this the movement of functionality from the unity layer down into the core has been incremental.

We are now at a point where the underlying infrastructure module (mainly for EcsRxApplication and dependency injection notions) has been added, and the generic view module has been moved here. While both of these libraries offer a stepping stone to get up and running quicker they unfortunately are not as easy as just including and off you go.

The examples folder shows examples on how to create your own application implementations, but hopefully once things have been ironed out in the whole Rx world this area will improve more as we start to add another layer which will let you just drop in and go (like the unity version).

If you want to know more about this drop into the gitter chat and we can discuss more.

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 net46 is compatible.  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 (11)

Showing the top 5 NuGet packages that depend on EcsRx.Infrastructure:

Package Downloads
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.Infrastructure.Ninject

Ninject dependency wrapper for use with infrastructure projects

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 (1)

Showing the top 1 popular GitHub repositories that depend on EcsRx.Infrastructure:

Repository Stars
EcsRx/ecsrx.unity
A simple framework for unity using the ECS paradigm but with unirx for fully reactive systems.
Version Downloads Last updated
8.0.184 282 6/12/2024
7.1.181 348 5/4/2024
7.1.179 313 5/4/2024
7.1.176 289 5/2/2024
7.1.174 299 5/1/2024
7.0.171 318 5/1/2024
7.0.169 337 4/26/2024
7.0.167 311 4/25/2024
7.0.164 377 3/30/2024
7.0.162 349 3/30/2024
7.0.160 329 3/30/2024
7.0.158 404 3/26/2024
6.1.156 2,393 1/26/2023
6.1.151 2,717 11/28/2022
6.1.148 2,568 11/23/2022
6.1.145 2,547 11/22/2022
6.1.142 2,532 11/21/2022
6.0.131 3,550 5/5/2022
5.1.116 2,036 12/21/2021
5.0.110 2,362 7/15/2021
5.0.108 2,298 7/15/2021
5.0.101 2,185 6/28/2021
4.1.99 2,463 6/28/2021
4.1.97 2,434 6/5/2021
4.0.95 2,302 5/26/2021
4.0.93 2,421 5/22/2021
4.0.87 2,621 5/2/2021
4.0.80 2,656 4/30/2021
3.12.77 2,537 2/9/2021
3.12.73 2,392 12/16/2020
3.11.68 3,873 3/26/2020
3.10.65 2,610 3/24/2020
3.9.62 2,413 3/11/2020
3.9.60 2,328 3/11/2020
3.9.57 2,687 3/11/2020
3.8.54 2,768 3/11/2020
3.8.52 2,360 3/11/2020
3.7.50 2,421 3/3/2020
3.6.48 2,334 3/3/2020
3.6.45 2,250 3/3/2020
3.6.44 2,135 3/3/2020
3.5.41 2,521 12/16/2019
3.5.40 2,450 12/16/2019
3.5.39 2,454 12/16/2019
3.5.36 2,504 11/24/2019
3.5.34 2,556 4/8/2019
3.5.33 2,381 4/8/2019
3.4.32 2,903 4/3/2019
3.4.31 2,458 4/3/2019
3.3.30 2,444 4/3/2019
3.3.29 2,450 4/3/2019
3.3.28 2,512 3/19/2019
3.3.26 2,445 3/18/2019
3.3.23 2,432 3/15/2019
3.3.22 2,519 3/12/2019
3.3.21 2,431 3/12/2019
3.3.20 2,560 1/29/2019
3.3.19 2,489 1/29/2019
3.2.18 2,570 1/25/2019
3.2.17 2,497 1/25/2019
3.1.16 2,520 1/25/2019
3.1.15 2,458 1/25/2019
3.1.14 2,547 1/18/2019
3.1.13 2,547 1/18/2019
3.0.12 2,636 1/18/2019
3.0.11 2,582 1/18/2019
3.0.10 931 1/18/2019
3.0.8 961 1/18/2019
3.0.7 1,109 1/18/2019
3.0.0 2,600 1/18/2019
2.0.6 939 11/29/2018
2.0.4 1,068 10/3/2018
2.0.3 1,014 9/25/2018
2.0.2 1,022 9/25/2018
2.0.0 977 9/25/2018
1.2.3 1,030 9/18/2018
1.2.2 1,013 9/18/2018
1.2.0 1,033 9/17/2018
1.0.0 1,071 8/23/2018
0.4.0 940 7/30/2018
0.3.0 863 7/27/2018
0.2.0 1,063 7/25/2018