diff --git a/Assets/EcsRx/EcsRx.Infrastructure.dll b/Assets/EcsRx/EcsRx.Infrastructure.dll index 829fcd1..a21d869 100644 Binary files a/Assets/EcsRx/EcsRx.Infrastructure.dll and b/Assets/EcsRx/EcsRx.Infrastructure.dll differ diff --git a/Assets/EcsRx/EcsRx.Plugins.Batching.dll b/Assets/EcsRx/EcsRx.Plugins.Batching.dll index a91515e..8b31a80 100644 Binary files a/Assets/EcsRx/EcsRx.Plugins.Batching.dll and b/Assets/EcsRx/EcsRx.Plugins.Batching.dll differ diff --git a/Assets/EcsRx/EcsRx.Plugins.Computeds.dll b/Assets/EcsRx/EcsRx.Plugins.Computeds.dll index e636d6d..eed16dc 100644 Binary files a/Assets/EcsRx/EcsRx.Plugins.Computeds.dll and b/Assets/EcsRx/EcsRx.Plugins.Computeds.dll differ diff --git a/Assets/EcsRx/EcsRx.Plugins.GroupBinding.dll b/Assets/EcsRx/EcsRx.Plugins.GroupBinding.dll new file mode 100644 index 0000000..e9b2c8e Binary files /dev/null and b/Assets/EcsRx/EcsRx.Plugins.GroupBinding.dll differ diff --git a/Assets/EcsRx/EcsRx.Plugins.GroupBinding.dll.meta b/Assets/EcsRx/EcsRx.Plugins.GroupBinding.dll.meta new file mode 100644 index 0000000..b7f50c0 --- /dev/null +++ b/Assets/EcsRx/EcsRx.Plugins.GroupBinding.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: fc9dadac6298e274ca89476f861bf564 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/EcsRx/EcsRx.Plugins.ReactiveSystems.dll b/Assets/EcsRx/EcsRx.Plugins.ReactiveSystems.dll index 30048c6..0b66f95 100644 Binary files a/Assets/EcsRx/EcsRx.Plugins.ReactiveSystems.dll and b/Assets/EcsRx/EcsRx.Plugins.ReactiveSystems.dll differ diff --git a/Assets/EcsRx/EcsRx.Plugins.Views.dll b/Assets/EcsRx/EcsRx.Plugins.Views.dll index 8f151bf..7ec376b 100644 Binary files a/Assets/EcsRx/EcsRx.Plugins.Views.dll and b/Assets/EcsRx/EcsRx.Plugins.Views.dll differ diff --git a/Assets/EcsRx/EcsRx.dll b/Assets/EcsRx/EcsRx.dll index b9871ed..30dac02 100644 Binary files a/Assets/EcsRx/EcsRx.dll and b/Assets/EcsRx/EcsRx.dll differ diff --git a/Assets/EcsRx/SystemsRx.Infrastructure.dll b/Assets/EcsRx/SystemsRx.Infrastructure.dll index 0870261..3b987a9 100644 Binary files a/Assets/EcsRx/SystemsRx.Infrastructure.dll and b/Assets/EcsRx/SystemsRx.Infrastructure.dll differ diff --git a/Assets/EcsRx/SystemsRx.dll b/Assets/EcsRx/SystemsRx.dll index d84c2f0..664a804 100644 Binary files a/Assets/EcsRx/SystemsRx.dll and b/Assets/EcsRx/SystemsRx.dll differ diff --git a/Assets/Game/Application.cs b/Assets/Game/Application.cs index cbc678c..37019c2 100644 --- a/Assets/Game/Application.cs +++ b/Assets/Game/Application.cs @@ -2,6 +2,7 @@ using SystemsRx.Infrastructure.Extensions; using EcsRx.Collections.Entity; using EcsRx.Extensions; +using EcsRx.Plugins.GroupBinding; using EcsRx.Plugins.Views.Components; using EcsRx.Zenject; using Game.Blueprints; @@ -30,6 +31,12 @@ protected override void LoadModules() Container.LoadModule(); } + protected override void LoadPlugins() + { + base.LoadPlugins(); + RegisterPlugin(new GroupBindingsPlugin()); + } + protected override void ApplicationStarted() { defaultCollection = EntityDatabase.GetCollection(); diff --git a/Assets/Game/Computeds/ComputedPlayerPosition.cs b/Assets/Game/Computeds/ComputedPlayerPosition.cs index 900342a..e68af7d 100644 --- a/Assets/Game/Computeds/ComputedPlayerPosition.cs +++ b/Assets/Game/Computeds/ComputedPlayerPosition.cs @@ -22,7 +22,6 @@ public override Vector3 Transform(IObservableGroup observableGroup) if(player == null) { return Vector3.zero; } - Debug.Log("Have Player"); var gameObject = player.GetGameObject(); return gameObject.transform.position; } diff --git a/Assets/Game/Systems/ExitReachedSystem.cs b/Assets/Game/Systems/ExitReachedSystem.cs index d88554d..1cfe3f0 100644 --- a/Assets/Game/Systems/ExitReachedSystem.cs +++ b/Assets/Game/Systems/ExitReachedSystem.cs @@ -5,6 +5,7 @@ using EcsRx.Extensions; using EcsRx.Groups; using EcsRx.Groups.Observable; +using EcsRx.Plugins.GroupBinding.Attributes; using EcsRx.Systems; using EcsRx.Unity.Extensions; using Game.Blueprints; @@ -16,18 +17,16 @@ namespace Game.Systems { public class ExitReachedSystem : IReactToEventSystem, IManualSystem, IGroupSystem { - private IEntity _level; - private IObservableGroup _observableGroup; - public IGroup Group { get; } = new Group(typeof(LevelComponent)); - public ExitReachedSystem(IObservableGroupManager observableGroupManager) - { - _observableGroup = observableGroupManager.GetObservableGroup(Group); - } + [FromGroup] + public IObservableGroup ObservableGroup; + + private IEntity _level; + public void StartSystem() - { this.WaitForScene().Subscribe(x => _level = _observableGroup.First()); } + { this.WaitForScene().Subscribe(x => _level = ObservableGroup.First()); } public void StopSystem() {} diff --git a/Assets/Game/Systems/FoodTextUpdateSystem.cs b/Assets/Game/Systems/FoodTextUpdateSystem.cs index e70b623..31fefe5 100644 --- a/Assets/Game/Systems/FoodTextUpdateSystem.cs +++ b/Assets/Game/Systems/FoodTextUpdateSystem.cs @@ -8,6 +8,8 @@ using EcsRx.Collections; using EcsRx.Extensions; using EcsRx.Groups; +using EcsRx.Groups.Observable; +using EcsRx.Plugins.GroupBinding.Attributes; using EcsRx.Systems; using EcsRx.Unity.Extensions; using Game.Components; @@ -23,27 +25,26 @@ public class FoodTextUpdateSystem : IManualSystem, IGroupSystem { public IGroup Group { get; } = new Group(typeof(PlayerComponent)); - private readonly IEventSystem _eventSystem; - private IObservableGroupManager _observableGroupManager; + [FromGroup] + public IObservableGroup ObservableGroup; + private readonly IEventSystem _eventSystem; private PlayerComponent _playerComponent; private Text _foodText; private readonly IList _subscriptions = new List(); - public FoodTextUpdateSystem(IEventSystem eventSystem, IObservableGroupManager observableGroupManager) + public FoodTextUpdateSystem(IEventSystem eventSystem) { _eventSystem = eventSystem; - _observableGroupManager = observableGroupManager; } public void StartSystem() { this.WaitForScene().Subscribe(x => { - var player = _observableGroupManager.GetObservableGroup(Group).First(); + var player = ObservableGroup.First(); _playerComponent = player.GetComponent(); _foodText = GameObject.Find("FoodText").GetComponent(); - SetupSubscriptions(); }); } diff --git a/Assets/Game/Systems/LevelScreenVisibilitySystem.cs b/Assets/Game/Systems/LevelScreenVisibilitySystem.cs index 903aa5b..b0340f6 100644 --- a/Assets/Game/Systems/LevelScreenVisibilitySystem.cs +++ b/Assets/Game/Systems/LevelScreenVisibilitySystem.cs @@ -7,6 +7,8 @@ using EcsRx.Collections; using EcsRx.Extensions; using EcsRx.Groups; +using EcsRx.Groups.Observable; +using EcsRx.Plugins.GroupBinding.Attributes; using EcsRx.Systems; using EcsRx.Unity.Extensions; using Game.Components; @@ -18,19 +20,19 @@ namespace Game.Systems { public class LevelScreenVisibilitySystem : IManualSystem, IGroupSystem { - private IEventSystem _eventSystem; - private IObservableGroupManager _observableGroupManager; - public IGroup Group { get; } = new Group(typeof(LevelComponent)); - + + [FromGroup] + public IObservableGroup ObservableGroup; + + private IEventSystem _eventSystem; private GameObject _levelImage; private LevelComponent _levelComponent; private IList _subscriptions = new List(); - public LevelScreenVisibilitySystem(IEventSystem eventSystem, IObservableGroupManager observableGroupManager) + public LevelScreenVisibilitySystem(IEventSystem eventSystem) { _eventSystem = eventSystem; - _observableGroupManager = observableGroupManager; } public void StartSystem() @@ -38,7 +40,7 @@ public void StartSystem() this.WaitForScene() .Subscribe(x => { - var level = _observableGroupManager.GetObservableGroup(Group).First(); + var level = ObservableGroup.First(); _levelComponent = level.GetComponent(); _levelImage = GameObject.Find("LevelImage"); SetupSubscriptions(); diff --git a/Assets/Game/Systems/LevelTextUpdateSystem.cs b/Assets/Game/Systems/LevelTextUpdateSystem.cs index 9141f21..e8a2623 100644 --- a/Assets/Game/Systems/LevelTextUpdateSystem.cs +++ b/Assets/Game/Systems/LevelTextUpdateSystem.cs @@ -7,6 +7,8 @@ using EcsRx.Collections; using EcsRx.Extensions; using EcsRx.Groups; +using EcsRx.Groups.Observable; +using EcsRx.Plugins.GroupBinding.Attributes; using EcsRx.Systems; using EcsRx.Unity.Extensions; using Game.Components; @@ -21,16 +23,17 @@ public class LevelTextUpdateSystem : IManualSystem, IGroupSystem { public IGroup Group { get; } = new Group(typeof(LevelComponent)); + [FromGroup] + public IObservableGroup ObservableGroup; + private Text _levelText; private LevelComponent _levelComponent; private readonly IEventSystem _eventSystem; - private readonly IObservableGroupManager _observableGroupManager; private readonly IList _subscriptions = new List(); - public LevelTextUpdateSystem(IEventSystem eventSystem, IObservableGroupManager observableGroupManager) + public LevelTextUpdateSystem(IEventSystem eventSystem) { _eventSystem = eventSystem; - _observableGroupManager = observableGroupManager; } public void StartSystem() @@ -38,7 +41,7 @@ public void StartSystem() this.WaitForScene() .Subscribe(x => { - var level = _observableGroupManager.GetObservableGroup(Group).First(); + var level = ObservableGroup.First(); _levelComponent = level.GetComponent(); _levelText = GameObject.Find("LevelText").GetComponent(); SetupSubscriptions(); diff --git a/Assets/Game/Systems/MusicSystem.cs b/Assets/Game/Systems/MusicSystem.cs index 9000a15..c9bef8d 100644 --- a/Assets/Game/Systems/MusicSystem.cs +++ b/Assets/Game/Systems/MusicSystem.cs @@ -4,9 +4,10 @@ using SystemsRx.Events; using SystemsRx.Systems.Conventional; using SystemsRx.Extensions; -using EcsRx.Collections; using EcsRx.Extensions; using EcsRx.Groups; +using EcsRx.Groups.Observable; +using EcsRx.Plugins.GroupBinding.Attributes; using EcsRx.Systems; using EcsRx.Unity.Extensions; using Game.Components; @@ -20,19 +21,19 @@ public class MusicSystem : IManualSystem, IGroupSystem { public IGroup Group { get; } = new Group(typeof(LevelComponent)); - private readonly IEventSystem _eventSystem; - private readonly IObservableGroupManager _observableGroupManager; + [FromGroup] + public IObservableGroup ObservableGroup; + private readonly IEventSystem _eventSystem; private readonly AudioSource _musicSource; private LevelComponent _levelComponent; private readonly IList _subscriptions = new List(); - public MusicSystem(IEventSystem eventSystem, IObservableGroupManager observableGroupManager) + public MusicSystem(IEventSystem eventSystem) { var soundEffectObject = GameObject.Find("MusicSource"); _musicSource = soundEffectObject.GetComponent(); _eventSystem = eventSystem; - _observableGroupManager = observableGroupManager; } public void StartSystem() @@ -40,7 +41,7 @@ public void StartSystem() this.WaitForScene() .Subscribe(x => { - var level = _observableGroupManager.GetObservableGroup(Group).First(); + var level = ObservableGroup.First(); _levelComponent = level.GetComponent(); SetupSubscriptions(); }); diff --git a/Assets/Game/Systems/PlayerInteractionSystem.cs b/Assets/Game/Systems/PlayerInteractionSystem.cs index 027cd9b..5a1ac0d 100644 --- a/Assets/Game/Systems/PlayerInteractionSystem.cs +++ b/Assets/Game/Systems/PlayerInteractionSystem.cs @@ -6,6 +6,8 @@ using EcsRx.Collections; using EcsRx.Entities; using EcsRx.Groups; +using EcsRx.Groups.Observable; +using EcsRx.Plugins.GroupBinding.Attributes; using EcsRx.Systems; using EcsRx.Unity.Extensions; using EcsRx.Unity.MonoBehaviours; @@ -20,24 +22,24 @@ namespace Game.Systems public class PlayerInteractionSystem : IManualSystem, IGroupSystem { public IGroup Group { get; } = new Group(typeof (PlayerComponent), typeof (ViewComponent)); + + [FromGroup] + public IObservableGroup ObservableGroup; private readonly IList _foodTriggers = new List(); private readonly IList _exitTriggers = new List(); private readonly IEventSystem _eventSystem; - private readonly IObservableGroupManager _observableGroupManager; - public PlayerInteractionSystem(IEventSystem eventSystem, IObservableGroupManager observableGroupManager) + public PlayerInteractionSystem(IEventSystem eventSystem) { _eventSystem = eventSystem; - _observableGroupManager = observableGroupManager; } public void StartSystem() { this.WaitForScene().Subscribe(x => { - var observableGroup = _observableGroupManager.GetObservableGroup(Group); - foreach(var player in observableGroup) + foreach(var player in ObservableGroup) { CheckForInteractions(player); } }); } diff --git a/Assets/Game/Systems/StandardInputSystem.cs b/Assets/Game/Systems/StandardInputSystem.cs index 26ec17b..4d91194 100644 --- a/Assets/Game/Systems/StandardInputSystem.cs +++ b/Assets/Game/Systems/StandardInputSystem.cs @@ -16,9 +16,7 @@ public class StandardInputSystem : IReactToGroupSystem public IGroup Group { get; } = new Group(typeof(MovementComponent), typeof(StandardInputComponent)); public IObservable ReactToGroup(IObservableGroup group) - { - return Observable.EveryUpdate().Select(x => group); - } + { return Observable.EveryUpdate().Select(x => group); } public void Process(IEntity entity) { diff --git a/Assets/Game/Systems/TurnsSystem.cs b/Assets/Game/Systems/TurnsSystem.cs index 45b8793..a01685a 100644 --- a/Assets/Game/Systems/TurnsSystem.cs +++ b/Assets/Game/Systems/TurnsSystem.cs @@ -8,6 +8,7 @@ using EcsRx.Extensions; using EcsRx.Groups; using EcsRx.Groups.Observable; +using EcsRx.Plugins.GroupBinding.Attributes; using EcsRx.Systems; using EcsRx.Unity.Extensions; using Game.Components; @@ -18,25 +19,26 @@ namespace Game.Systems { - public class TurnsSystem : IManualSystem, IGroupSystem + public class TurnsSystem : IManualSystem { private readonly GameConfiguration _gameConfiguration; private readonly IEventSystem _eventSystem; private IDisposable _updateSubscription; private bool _isProcessing; - private readonly IObservableGroup _levelAccessor, _enemyAccessor; + + [FromComponents(typeof (LevelComponent))] + public IObservableGroup LevelAccessor; + + [FromComponents(typeof(EnemyComponent))] + public IObservableGroup EnemyAccessor; + private IEntity _level; - public IGroup Group { get; } = new Group(typeof(EnemyComponent)); - - public TurnsSystem(GameConfiguration gameConfiguration, IEventSystem eventSystem, IObservableGroupManager observableGroupManager) + public TurnsSystem(GameConfiguration gameConfiguration, IEventSystem eventSystem) { _gameConfiguration = gameConfiguration; _eventSystem = eventSystem; - - _levelAccessor = observableGroupManager.GetObservableGroup(new Group(typeof (LevelComponent))); - _enemyAccessor = observableGroupManager.GetObservableGroup(Group); } private IEnumerator CarryOutTurns() @@ -44,10 +46,10 @@ private IEnumerator CarryOutTurns() _isProcessing = true; yield return new WaitForSeconds(_gameConfiguration.TurnDelay); - if(!_enemyAccessor.Any()) + if(!EnemyAccessor.Any()) { yield return new WaitForSeconds(_gameConfiguration.TurnDelay); } - foreach (var enemy in _enemyAccessor) + foreach (var enemy in EnemyAccessor) { _eventSystem.Publish(new EnemyTurnEvent(enemy)); yield return new WaitForSeconds(_gameConfiguration.MovementTime); @@ -66,7 +68,7 @@ private bool IsLevelLoaded() public void StartSystem() { - this.WaitForScene().Subscribe(x => _level = _levelAccessor.First()); + this.WaitForScene().Subscribe(x => _level = LevelAccessor.First()); _updateSubscription = Observable.EveryUpdate().Where(x => IsLevelLoaded()) .Subscribe(x => {