-
Notifications
You must be signed in to change notification settings - Fork 36
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
Showing
86 changed files
with
937 additions
and
864 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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
set version=0.3.0 | ||
set version=1.0.0 | ||
dotnet pack ../src/EcsRx.MicroRx -c Release -o ../../_dist /p:version=%version% | ||
dotnet pack ../src/EcsRx -c Release -o ../../_dist /p:version=%version% | ||
dotnet pack ../src/EcsRx.Systems -c Release -o ../../_dist /p:version=%version% | ||
dotnet pack ../src/EcsRx.Views -c Release -o ../../_dist /p:version=%version% | ||
dotnet pack ../src/EcsRx.Infrastructure -c Release -o ../../_dist /p:version=%version% | ||
dotnet pack ../src/EcsRx.Infrastructure -c Release -o ../../_dist /p:version=%version% | ||
dotnet pack ../src/EcsRx.Infrastructure.Ninject -c Release -o ../../_dist /p:version=%version% | ||
dotnet pack ../src/EcsRx.ReactiveData -c Release -o ../../_dist /p:version=%version% |
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,42 @@ | ||
# MicroRx .... wtf is that? | ||
|
||
## tldr; | ||
|
||
Both rx.net and unirx have problems on different engines/platforms so EcsRx core cannot depend on either, so it depends on this TINY rx implementation so it can work with either. | ||
|
||
## Why? | ||
|
||
So in .net currently there are 2 main rx implementations: | ||
|
||
- `System.Reactive` (aka `dotnet reactive` or `rx.net`) | ||
- `UniRx` (a unity specific rx implementation) | ||
|
||
Herein lies the problem, so this library was first created as a unity project, then it was split off into a generic .net framework agnostic of engines and frameworks, with a unity layer (and other engine specific layers) which would sit on top of this. | ||
|
||
## The ACTUAL problem | ||
|
||
Unity and a lot of other engines/frameworks (Monogame, Godot, Xenko etc) support modern .net syntax and libraries, and they allow you to release to different platforms, and this is where the problem rears its head. | ||
|
||
As certain platforms don't support JIT and require AOT compilation, which the normal `System.Reactive` framework doesn't support. There were however some discussions on the work needed to allow it to work in AOT scenarios, but no solid work seems to have resulted from that yet. | ||
|
||
This then means that if you want to target iOS for example you cannot use `System.Reactive` out the box, so for unity its not really possible to use it due to IL2CPP and certain platform constraints. | ||
|
||
## UNIRX THEN? SURELY THAT WORKS? | ||
|
||
If you are in Unity then yes, UniRx will work in all of those scenarios (with some tweaks). HOWEVER, UniRx is not really maintained that well these days as the maintainer drops in every now and again and then vanishes and no one else has been able to assist in maintaining the project. | ||
|
||
This also means that if you are not using Unity you cannot really use UniRx. While there is a nuget package for it, it has not been updated in years and given the lack of communication on the main releases of unirx to the asset store and github I would not hold my breath for a new version of that any time soon (Believe me, I wont stop pestering the maintainer of it). | ||
|
||
## So you made your own Rx? | ||
|
||
Kinda, so EcsRx originally made use of fancy rx linq stuff and some other fancy rx bits, but I couldn't have a dependency on `rx.net` as then the unity layer would fail, and I couldnt have a dependency on `UniRx` as its nuget package is wildly outdated and the other part cannot be used outside of unity. | ||
|
||
So because of these problems I decided to make a TINY rx implementation, which is pretty much a rip off and simplification of parts of `UniRx`. This allows EcsRx to internally be able to make use of basic rx paradigms like `Subject` and `CompositeDisposable` (and a few other bits) but has very little else, i.e no Linq stuff, no scheduler, no async stuffs. | ||
|
||
This makes it a very small library and very specific in its usecase, so as EcsRx uses `IObservable` as its contract which is a part of .net it means the stuff inside `MicroRx` should be compatible with unity and/or any other framework/engine, and place nicely with other more feature rich rx implementations, so you get to decide if you want to use `rx.net` or `unirx` (or any other rx implementation) in your consuming project, while the EcsRx core is blissfully unaware of what you are using. | ||
|
||
## Going forward | ||
|
||
I don't really want to have a micro rx implementation, I would much rather depend on a better, more maintained version of rx, but until `rx.net` works in unity on all platforms, or `UniRx` starts releasing maintained nuget packages which can be consumed on any platform I am going to need to rely upon this to polyfill those needs and stay agnostic of implementation. | ||
|
||
Really you dont need to worry about this and dont even really need to care about `MicroRx`'s existence, although I would say DONT USE IT FOR ANYTHING MAJOR, its only really there to polyfill the internal EcsRx libs. |
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
3 changes: 0 additions & 3 deletions
3
src/EcsRx.Examples/ExampleApps/ComputedGroupExample/Systems/DisplayLowestHealthSystem.cs
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
2 changes: 1 addition & 1 deletion
2
src/EcsRx.Examples/ExampleApps/HealthExample/Blueprints/EnemyBlueprint.cs
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
1 change: 1 addition & 0 deletions
1
src/EcsRx.Examples/ExampleApps/HealthExample/Components/HealthComponent.cs
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
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
21 changes: 21 additions & 0 deletions
21
src/EcsRx.Infrastructure.Ninject/EcsRx.Infrastructure.Ninject.csproj
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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks> | ||
<Title>EcsRx.Infrastructure.Ninject</Title> | ||
<Authors>Grofit (LP)</Authors> | ||
<PackageLicenseUrl>https://github.com/ecsrx/ecsrx/blob/master/LICENSE</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/ecsrx/ecsrx</PackageProjectUrl> | ||
<Description>Ninject dependency wrapper for use with infrastructure projects</Description> | ||
<PackageTags>ecs rx reactive patterns ioc game-development xna monogame unity</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EcsRx.Infrastructure\EcsRx.Infrastructure.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Ninject" Version="3.3.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
6 changes: 4 additions & 2 deletions
6
src/EcsRx/Events/EventSystem.cs → ...csRx.Infrastructure/Events/EventSystem.cs
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
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,13 @@ | ||
using System; | ||
|
||
/* | ||
* This code was taken from UniRx project by neuecc | ||
* https://github.com/neuecc/UniRx | ||
*/ | ||
namespace EcsRx.MicroRx.Disposables | ||
{ | ||
public static class Disposable | ||
{ | ||
public static readonly IDisposable Empty = EmptyDisposable.Singleton; | ||
} | ||
} |
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,18 @@ | ||
using System; | ||
|
||
namespace EcsRx.MicroRx.Disposables | ||
{ | ||
public class EmptyDisposable : IDisposable | ||
{ | ||
public static EmptyDisposable Singleton = new EmptyDisposable(); | ||
|
||
private EmptyDisposable() | ||
{ | ||
|
||
} | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
} | ||
} |
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,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks> | ||
</PropertyGroup> | ||
</Project> |
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,12 @@ | ||
| ||
|
||
/* | ||
* This code was taken from UniRx project by neuecc | ||
* https://github.com/neuecc/UniRx | ||
*/ | ||
namespace EcsRx.MicroRx.Events | ||
{ | ||
public interface IMessageBroker : IMessagePublisher, IMessageReceiver | ||
{ | ||
} | ||
} |
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,10 @@ | ||
namespace EcsRx.MicroRx.Events | ||
{ | ||
public interface IMessagePublisher | ||
{ | ||
/// <summary> | ||
/// Send Message to all receiver. | ||
/// </summary> | ||
void Publish<T>(T message); | ||
} | ||
} |
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,12 @@ | ||
using System; | ||
|
||
namespace EcsRx.MicroRx.Events | ||
{ | ||
public interface IMessageReceiver | ||
{ | ||
/// <summary> | ||
/// Subscribe typed message. | ||
/// </summary> | ||
IObservable<T> Receive<T>(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/EcsRx/Reactive/MessageBroker.cs → src/EcsRx.MicroRx/Events/MessageBroker.cs
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,28 @@ | ||
using System; | ||
using EcsRx.MicroRx.Observers; | ||
|
||
/* | ||
* This code was taken from UniRx project by neuecc | ||
* https://github.com/neuecc/UniRx | ||
*/ | ||
namespace EcsRx.MicroRx.Extensions | ||
{ | ||
public static class IObservableExtensions | ||
{ | ||
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext) | ||
{ | ||
return source.Subscribe(CreateSubscribeObserver(onNext, Stubs.Throw, Stubs.Nop)); | ||
} | ||
|
||
internal static IObserver<T> CreateSubscribeObserver<T>(Action<T> onNext, Action<Exception> onError, Action onCompleted) | ||
{ | ||
// need compare for avoid iOS AOT | ||
if (onNext == Stubs<T>.Ignore) | ||
{ | ||
return new StubbedSubscribeObserver<T>(onError, onCompleted); | ||
} | ||
|
||
return new SubscribeObserver<T>(onNext, onError, onCompleted); | ||
} | ||
} | ||
} |
Oops, something went wrong.