Skip to content

Commit

Permalink
Merge branch 'ecsrx-update'
Browse files Browse the repository at this point in the history
  • Loading branch information
grofit committed Mar 12, 2020
2 parents 674ef7d + 6226289 commit 8fa8cd4
Show file tree
Hide file tree
Showing 318 changed files with 8,727 additions and 4,976 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ src/\.idea/\.idea\.src/
/src/Assets/Plugins/Zenject/OptionalExtras
/src/.vs
/src/Assets/EcsRx/*.pdb
/src/Assets/EcsRx/*.pdb.meta
/src/Assets/EcsRx/*.pdb.meta
src/Logs/
433 changes: 222 additions & 211 deletions src/Assembly-CSharp-Editor.csproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Assembly-CSharp-Editor.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

408 changes: 208 additions & 200 deletions src/Assembly-CSharp-firstpass.csproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Assembly-CSharp-firstpass.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

410 changes: 210 additions & 200 deletions src/Assembly-CSharp.csproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Assembly-CSharp.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Assets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
using EcsRx.Groups;
using EcsRx.Groups.Observable;
using EcsRx.Plugins.ReactiveSystems.Systems;
using EcsRx.Systems;
using UniRx;
using UnityEngine;

namespace EcsRx.Examples.CustomGameObjectHandling.Systems
{
public class CameraFollowSystem : ISetupSystem, IReactToGroupSystem
public class CameraFollowSystem : ISetupSystem, IBasicSystem
{
public IGroup Group => new GroupBuilder()
.WithComponent<CameraFollowsComponent>()
Expand All @@ -23,9 +24,6 @@ public void Setup(IEntity entity)
cameraFollows.Camera = Camera.main;
}

public IObservable<IObservableGroup> ReactToGroup(IObservableGroup group)
{ return Observable.EveryUpdate().Select(x => group); }

public void Process(IEntity entity)
{
var entityPosition = entity.GetComponent<CustomViewComponent>().CustomView.transform.position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void Setup(IEntity entity)
{
var viewComponent = entity.GetComponent<CustomViewComponent>();
viewComponent.CustomView = GameObject.CreatePrimitive(PrimitiveType.Cube);
viewComponent.CustomView.name = "entity-" + entity.Id;
viewComponent.CustomView.name = $"entity-{entity.Id}";
var rigidBody = viewComponent.CustomView.AddComponent<Rigidbody>();
rigidBody.freezeRotation = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
using EcsRx.Groups;
using EcsRx.Groups.Observable;
using EcsRx.Plugins.ReactiveSystems.Systems;
using EcsRx.Systems;
using UniRx;
using UnityEngine;

namespace EcsRx.Examples.CustomGameObjectHandling.Systems
{
public class PlayerControlSystem : IReactToGroupSystem
public class PlayerControlSystem : IBasicSystem
{
public readonly float MovementSpeed = 2.0f;

Expand All @@ -19,9 +20,6 @@ public class PlayerControlSystem : IReactToGroupSystem
.WithComponent<PlayerControlledComponent>()
.Build();

public IObservable<IObservableGroup> ReactToGroup(IObservableGroup group)
{ return Observable.EveryUpdate().Select(x => group); }

public void Process(IEntity entity)
{
var strafeMovement = 0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace EcsRx.Examples.GameObjectLinking.Systems
{
public class ChangeScaleOnLinkingSystem : ISetupSystem
{
public IGroup Group { get; } = new Group(x => {
public IGroup Group { get; } = new GroupWithPredicate(x => {
var viewComponent = x.GetComponent<ViewComponent>();
return viewComponent.View != null;
}, typeof(ViewComponent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void StartSystem(IObservableGroup group)
{
_updateLoop = Observable.Interval(TimeSpan.FromSeconds(2)).Subscribe(x =>
{
Debug.Log("Outputting: " + _timesOutputted++);
Debug.Log($"Outputting: {_timesOutputted++}");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public class Application : EcsRxApplicationBehaviour
// We override this to stop auto bindings
protected override void BindSystems()
{
Container.Bind<ISystem, RandomMovementSystem>();
Container.Bind<RandomMovementSystem>();
}

// We override this to manually control how systems start
protected override void StartSystems()
{
// This one we are manually binding and starting at the same time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DefaultViewResolver(IEntityCollectionManager collectionManager, IEventSys

protected override void OnViewCreated(IEntity entity, GameObject view)
{
view.name = "entity-" + entity.Id;
view.name = $"entity-{entity.Id}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace EcsRx.Examples.RandomReactions.Components
{
public class RandomColorComponent : IComponent
{
public ReactiveProperty<Color> Color { get; set; }
public ReactiveProperty<Color> Color { get; }
public float Elapsed { get; set; }
public float NextChangeIn { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
using EcsRx.Groups;
using EcsRx.Groups.Observable;
using EcsRx.Plugins.ReactiveSystems.Systems;
using EcsRx.Systems;
using UniRx;
using UnityEngine;
using Random = UnityEngine.Random;

namespace EcsRx.Examples.RandomReactions.Systems
{
public class ColorChangingSystem : IReactToGroupSystem, ISetupSystem
public class ColorChangingSystem : IBasicSystem, ISetupSystem
{
private readonly float MaxDelay = 5.0f;
private readonly float MinDelay = 1.0f;

public IGroup Group => new Group(typeof(RandomColorComponent));

public IObservable<IObservableGroup> ReactToGroup(IObservableGroup group)
{ return Observable.EveryUpdate().Select(x => group); }


public void Setup(IEntity entity)
{
var randomColorComponent = entity.GetComponent<RandomColorComponent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ private void IncrementRow()
_nextPosition.z += _spacing;
}


protected override void OnViewCreated(IEntity entity, GameObject view)
{
view.transform.position = _nextPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
using EcsRx.Groups.Observable;
using EcsRx.Plugins.ReactiveSystems.Systems;
using EcsRx.Plugins.Views.Components;
using EcsRx.Systems;
using UniRx;
using UnityEngine;

namespace EcsRx.Examples.SimpleMovement.Systems
{
public class CameraFollowSystem : ISetupSystem, IReactToGroupSystem
public class CameraFollowSystem : ISetupSystem, IBasicSystem
{
public IGroup Group => new GroupBuilder()
.WithComponent<CameraFollowsComponent>()
Expand All @@ -24,9 +25,6 @@ public void Setup(IEntity entity)
cameraFollows.Camera = Camera.main;
}

public IObservable<IObservableGroup> ReactToGroup(IObservableGroup group)
{ return Observable.EveryUpdate().Select(x => group); }

public void Process(IEntity entity)
{
var viewComponent = entity.GetComponent<ViewComponent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
using EcsRx.Groups.Observable;
using EcsRx.Plugins.ReactiveSystems.Systems;
using EcsRx.Plugins.Views.Components;
using EcsRx.Systems;
using UniRx;
using UnityEngine;

namespace EcsRx.Examples.SimpleMovement.Systems
{
public class PlayerControlSystem : IReactToGroupSystem
public class PlayerControlSystem : IBasicSystem
{
public readonly float MovementSpeed = 2.0f;

Expand All @@ -20,9 +21,6 @@ public class PlayerControlSystem : IReactToGroupSystem
.WithComponent<PlayerControlledComponent>()
.Build();

public IObservable<IObservableGroup> ReactToGroup(IObservableGroup group)
{ return Observable.EveryUpdate().Select(x => group); }

public void Process(IEntity entity)
{
var strafeMovement = 0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public DefaultViewResolver(IEntityCollectionManager collectionManager, IEventSys

protected override void OnViewCreated(IEntity entity, GameObject view)
{
view.name = "entity-" + entity.Id;
view.name = $"entity-{entity.Id}";
var rigidBody = view.AddComponent<Rigidbody>();
rigidBody.freezeRotation = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace EcsRx.Examples.UsingBlueprints.Blueprints
{
public class PlayerBlueprint : IBlueprint
{
public float DefaultHealth { get; set; }
public string Name { get; set; }
public float DefaultHealth { get; }
public string Name { get; }

public PlayerBlueprint(string name, float defaultHealth = 100.0f)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ namespace EcsRx.Examples.UsingBlueprints.Groups
{
public class PlayerGroup : IGroup
{
public Type[] RequiredComponents { get; } = new[]
{
public Type[] RequiredComponents { get; } = {
typeof(HasName), typeof(WithHealthComponent)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ namespace EcsRx.Examples.UsingBlueprints.Systems
{
public class PlayerReportingSystem : ISetupSystem
{
public IGroup Group { get { return new PlayerGroup();} }
public IGroup Group => new PlayerGroup();

public void Setup(IEntity entity)
{
var nameComponent = entity.GetComponent<HasName>();
var healthComponent = entity.GetComponent<WithHealthComponent>();

var message = string.Format("{0} created with {1}/{2}",
nameComponent.Name,
healthComponent.CurrentHealth, healthComponent.MaxHealth);
var message = $"{nameComponent.Name} created with {healthComponent.CurrentHealth}/{healthComponent.MaxHealth}";

Debug.Log(message);
}
Expand Down
Binary file modified src/Assets/EcsRx/EcsRx.Infrastructure.dll
Binary file not shown.
Binary file modified src/Assets/EcsRx/EcsRx.MicroRx.dll
Binary file not shown.
Binary file modified src/Assets/EcsRx/EcsRx.Plugins.Batching.dll
Binary file not shown.
Binary file modified src/Assets/EcsRx/EcsRx.Plugins.Computeds.dll
Binary file not shown.
Binary file modified src/Assets/EcsRx/EcsRx.Plugins.ReactiveSystems.dll
Binary file not shown.
Binary file modified src/Assets/EcsRx/EcsRx.Plugins.Views.dll
Binary file not shown.
Binary file modified src/Assets/EcsRx/EcsRx.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions src/Assets/EcsRx/Unity/Modules.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/Assets/EcsRx/Unity/Modules/UnityOverrideModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using EcsRx.Infrastructure.Dependencies;
using EcsRx.Infrastructure.Extensions;
using EcsRx.Scheduling;
using EcsRx.Unity.Scheduling;

namespace EcsRx.Unity.Modules
{
public class UnityOverrideModule : IDependencyModule
{
public void Setup(IDependencyContainer container)
{
container.Unbind<IUpdateScheduler>();
container.Bind<IUpdateScheduler, UnityUpdateScheduler>(x => x.AsSingleton());
}
}
}
3 changes: 3 additions & 0 deletions src/Assets/EcsRx/Unity/Modules/UnityOverrideModule.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Assets/EcsRx/Unity/Scheduling.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/Assets/EcsRx/Unity/Scheduling/UnityUpdateScheduler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using EcsRx.Scheduling;
using UniRx;
using UnityEngine;

namespace EcsRx.Unity.Scheduling
{
public class UnityUpdateScheduler : IUpdateScheduler
{
public ElapsedTime ElapsedTime { get; private set; }

private readonly Subject<ElapsedTime> _onPreUpdate = new Subject<ElapsedTime>();
private readonly Subject<ElapsedTime> _onUpdate = new Subject<ElapsedTime>();
private readonly Subject<ElapsedTime> _onPostUpdate = new Subject<ElapsedTime>();
private readonly IDisposable _everyUpdateSub;

public IObservable<ElapsedTime> OnPreUpdate => _onPreUpdate;
public IObservable<ElapsedTime> OnUpdate => _onUpdate;
public IObservable<ElapsedTime> OnPostUpdate => _onPostUpdate;

public UnityUpdateScheduler()
{
_everyUpdateSub = Observable.EveryUpdate().Subscribe(x =>
{
var deltaTime = TimeSpan.FromSeconds(Time.deltaTime);
var totalTime = ElapsedTime.TotalTime + deltaTime;
ElapsedTime = new ElapsedTime(deltaTime, totalTime);

_onPreUpdate?.OnNext(ElapsedTime);
_onUpdate?.OnNext(ElapsedTime);
_onPostUpdate.OnNext(ElapsedTime);
});
}

public void Dispose()
{
_everyUpdateSub.Dispose();
_onPreUpdate?.Dispose();
_onPostUpdate?.Dispose();
_onUpdate?.Dispose();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public void Bind(Type fromType, Type toType, BindingConfiguration configuration
bindingSetup.To(toType).AsSingle();
return;
}

if(!string.IsNullOrEmpty(configuration.WithName))
{ bindingSetup.WithId(configuration.WithName); }

if (configuration.ToInstance != null)
{
Expand All @@ -63,10 +66,7 @@ public void Bind(Type fromType, Type toType, BindingConfiguration configuration
}

var binding = bindingSetup.To(toType);

if(!string.IsNullOrEmpty(configuration.WithName))
{ binding.WithConcreteId(configuration.WithName); }


if(configuration.AsSingleton)
{ binding.AsSingle(); }

Expand Down
2 changes: 2 additions & 0 deletions src/Assets/EcsRx/Zenject/EcsRxApplicationBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using EcsRx.Plugins.ReactiveSystems;
using EcsRx.Plugins.Views;
using EcsRx.Systems;
using EcsRx.Unity.Modules;
using EcsRx.Zenject.Dependencies;
using UnityEngine;
using Zenject;
Expand Down Expand Up @@ -91,6 +92,7 @@ protected virtual void LoadPlugins()
protected virtual void LoadModules()
{
Container.LoadModule<FrameworkModule>();
Container.LoadModule<UnityOverrideModule>();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Assets/Plugins/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8fa8cd4

Please sign in to comment.