public UIManager(IEntityCollectionManager collectionManager, IEventSystem eventSystem) { CurrentScreen = new ReactiveProperty <IEntity>(); defaultConllection = collectionManager.GetCollection(); this.eventSystem = eventSystem; uiGroup = collectionManager.GetObservableGroup(new Group(typeof(UIComponent))); }
public void StartSystem(IObservableGroup group) { _eventSystem.Receive <FoodPickupEvent>().Subscribe(x => { var clips = x.IsSoda ? _drinkSounds.AvailableClips : _foodSounds.AvailableClips; PlayOneOf(clips); }).AddTo(_subscriptions); _eventSystem.Receive <EntityMovedEvent>() .Subscribe(x => PlayOneOf(_walkingSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <EnemyHitEvent>() .Subscribe(x => PlayOneOf(_playerAttackSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <WallHitEvent>() .Subscribe(x => PlayOneOf(_playerAttackSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <PlayerHitEvent>() .Subscribe(x => PlayOneOf(_enemyAttackSounds.AvailableClips)) .AddTo(_subscriptions); _eventSystem.Receive <PlayerKilledEvent>() .Subscribe(x => PlayOneOf(_deathSounds.AvailableClips)) .AddTo(_subscriptions); }
public void StartSystem(IObservableGroup group) { _updateLoop = Observable.Interval(TimeSpan.FromSeconds(2)).Subscribe(x => { Debug.Log($"Outputting: {_timesOutputted++}"); }); }
public TurnsSystem(GameConfiguration gameConfiguration, IEventSystem eventSystem, IObservableGroupManager observableGroupManager) { _gameConfiguration = gameConfiguration; _eventSystem = eventSystem; _levelAccessor = observableGroupManager.GetObservableGroup(new Group(typeof(LevelComponent))); }
public void StartSystem(IObservableGroup observableGroup) { var quitSubscriptions = _ecsRxGame.OnUpdate.Subscribe(CheckIfGameShouldQuit); var clearSubscriptions = _ecsRxGame.OnPreRender.Subscribe(ClearScreen); _subscriptions.Add(quitSubscriptions); _subscriptions.Add(clearSubscriptions); }
public DespawnAllBulletsEventSystem(IEventSystem eventSystem, IEntityCollectionManager entityCollectionManager) : base(eventSystem) { _entityCollectionManager = entityCollectionManager; _group = new Group(typeof(BulletComponent), typeof(ViewComponent)); _observableGroup = entityCollectionManager.GetObservableGroup(_group); }
protected BatchAccessor(IObservableGroup observableGroup, IComponentDatabase componentDatabase, IBatchBuilder batchBuilder, IComponentTypeLookup componentTypeLookup) { ObservableGroup = observableGroup; ComponentDatabase = componentDatabase; BatchBuilder = batchBuilder; ComponentTypeLookup = componentTypeLookup; SetupAccessor(); }
protected ComputedFromGroup(IObservableGroup observableGroup) { ObservableGroup = observableGroup; Subscriptions = new List <IDisposable>(); dataChanged = new Subject <TValue>(); MonitorChanges(); RefreshData(); }
public void StartSystem(IObservableGroup group) { this.WaitForScene() .Subscribe(x => { var level = group.First(); _levelComponent = level.GetComponent <LevelComponent>(); SetupSubscriptions(); }); }
public ComputedFromGroup(IObservableGroup internalObservableGroup) { InternalObservableGroup = internalObservableGroup; Subscriptions = new List <IDisposable>(); _onDataChanged = new Subject <T>(); MonitorChanges(); RefreshData(); }
public void StartSystem(IObservableGroup group) { this.WaitForScene().Subscribe(x => { foreach (var player in group) { CheckForInteractions(player); } }); }
public void StartSystem(IObservableGroup group) { this.WaitForScene().Subscribe(x => { var player = group.First(); _playerComponent = player.GetComponent <PlayerComponent>(); _foodText = GameObject.Find("FoodText").GetComponent <Text>(); SetupSubscriptions(); }); }
public void StartSystem(IObservableGroup group) { this.WaitForScene() .Subscribe(x => { var level = @group.First(); _levelComponent = level.GetComponent <LevelComponent>(); _levelText = GameObject.Find("LevelText").GetComponent <Text>(); SetupSubscriptions(); }); }
protected ComputedGroup(IObservableGroup observableGroup) { ObservableGroup = observableGroup; Subscriptions = new List <IDisposable>(); CachedEntities = new Dictionary <int, IEntity>(); entityAdded = new Subject <IEntity>(); entityRemoving = new Subject <IEntity>(); entityRemoved = new Subject <IEntity>(); MonitorChanges(); RefreshEntities(); }
protected ComputedGroup(IObservableGroup internalObservableGroup) { InternalObservableGroup = internalObservableGroup; CachedEntities = new EntityLookup(); Subscriptions = new List <IDisposable>(); _onEntityAdded = new Subject <IEntity>(); _onEntityRemoved = new Subject <IEntity>(); _onEntityRemoving = new Subject <IEntity>(); MonitorChanges(); RefreshEntities(); }
public override Vector3 Transform(IObservableGroup observableGroup) { var player = observableGroup.FirstOrDefault(); if (player == null) { return(Vector3.zero); } var gameObject = player.GetGameObject(); return(gameObject.transform.position); }
public void StartSystem(IObservableGroup group) { this.WaitForScene().Subscribe(x => _level = _levelAccessor.First()); _updateSubscription = Observable.EveryUpdate().Where(x => IsLevelLoaded()) .Subscribe(x => { if (_isProcessing) { return; } MainThreadDispatcher.StartCoroutine(CarryOutTurns(@group)); }); }
protected ComputedCollectionFromGroup(IObservableGroup internalObservableGroup) { InternalObservableGroup = internalObservableGroup; Subscriptions = new List <IDisposable>(); FilteredCache = new Dictionary <int, T>(); _onDataChanged = new Subject <IEnumerable <T> >(); _onElementAdded = new Subject <CollectionElementChangedEvent <T> >(); _onElementChanged = new Subject <CollectionElementChangedEvent <T> >(); _onElementRemoved = new Subject <CollectionElementChangedEvent <T> >(); MonitorChanges(); RefreshData(); }
public virtual void StartSystem(IObservableGroup observableGroup) { ObservableGroup = observableGroup; ShouldParallelize = this.ShouldMutliThread(); var subscriptions = new CompositeDisposable(); ObservableGroup.OnEntityAdded.Subscribe(_ => RebuildBatch()).AddTo(subscriptions); ObservableGroup.OnEntityRemoved.Subscribe(_ => RebuildBatch()).AddTo(subscriptions); RebuildBatch(); ReactWhen().Subscribe(_ => RunBatch()).AddTo(subscriptions); Subscriptions = subscriptions; }
public void StartSystem(IObservableGroup group) { EventSystem.Receive <EffectTickedEvent>() .Subscribe(x => Console.WriteLine($"{x.ActiveEffect.Effect.Name} Ticked For {x.ActiveEffect.Effect.Potency}")) .AddTo(_subscriptions); EventSystem.Receive <EffectAddedEvent>() .Subscribe(x => Console.WriteLine($"{x.ActiveEffect.Effect.Name} Has Been Applied")) .AddTo(_subscriptions); EventSystem.Receive <EffectExpiredEvent>() .Subscribe(x => Console.WriteLine($"{x.ActiveEffect.Effect.Name} Has Expired")) .AddTo(_subscriptions); }
public IReferenceBatchAccessor <T1, T2> GetReferenceAccessorFor <T1, T2>(IObservableGroup observableGroup) where T1 : class, IComponent where T2 : class, IComponent { var componentTypes = ComponentTypeLookup.GetComponentTypes(typeof(T1), typeof(T2)); var token = new AccessorToken(componentTypes, observableGroup); if (BatchAccessors.ContainsKey(token)) { return((IReferenceBatchAccessor <T1, T2>)BatchAccessors[token]); } var batchBuilder = ReferenceBatchBuilderFactory.Create <T1, T2>(); var batchAccessor = new ReferenceBatchAccessor <T1, T2>(observableGroup, ComponentDatabase, batchBuilder, ComponentTypeLookup); BatchAccessors.Add(token, batchAccessor); return(batchAccessor); }
private IEnumerator CarryOutTurns(IObservableGroup group) { _isProcessing = true; yield return(new WaitForSeconds(_gameConfiguration.TurnDelay)); if (!group.Any()) { yield return(new WaitForSeconds(_gameConfiguration.TurnDelay)); } foreach (var enemy in group) { _eventSystem.Publish(new EnemyTurnEvent(enemy)); yield return(new WaitForSeconds(_gameConfiguration.MovementTime)); } _eventSystem.Publish(new PlayerTurnEvent()); _isProcessing = false; }
public IBatchAccessor <T1, T2, T3> GetAccessorFor <T1, T2, T3>(IObservableGroup observableGroup) where T1 : unmanaged, IComponent where T2 : unmanaged, IComponent where T3 : unmanaged, IComponent { var componentTypes = ComponentTypeLookup.GetComponentTypes(typeof(T1), typeof(T2), typeof(T3)); var token = new AccessorToken(componentTypes, observableGroup); if (BatchAccessors.ContainsKey(token)) { return((IBatchAccessor <T1, T2, T3>)BatchAccessors[token]); } var batchBuilder = BatchBuilderFactory.Create <T1, T2, T3>(); var batchAccessor = new BatchAccessor <T1, T2, T3>(observableGroup, ComponentDatabase, batchBuilder, ComponentTypeLookup); BatchAccessors.Add(token, batchAccessor); return(batchAccessor); }
public void StartSystem(IObservableGroup group) { var tickSubscription = EventSystem.Receive <EffectTickedEvent>().Subscribe(x => { var logMessage = $"{x.ActiveEffect.Effect.Name} Ticked For {x.ActiveEffect.Effect.Potency}"; UpdateLog(logMessage); }); var effectAddedSubscription = EventSystem.Receive <EffectAddedEvent>().Subscribe(x => { var logMessage = $"{x.ActiveEffect.Effect.Name} Has Been Applied"; UpdateLog(logMessage); }); var effectRemovedSubscription = EventSystem.Receive <EffectExpiredEvent>().Subscribe(x => { var logMessage = $"{x.ActiveEffect.Effect.Name} Has Expired"; UpdateLog(logMessage); }); _subscriptions.Add(tickSubscription); _subscriptions.Add(effectAddedSubscription); _subscriptions.Add(effectRemovedSubscription); }
public void Stop(IObservableGroup @group) { subscription.Dispose(); }
public void Start(IObservableGroup @group) { subscription = System.Receive <TEvent>().Subscribe(OnEventReceived); }
public void StopSystem(IObservableGroup group) { _subscriptions.DisposeAll(); }
public void StartSystem(IObservableGroup observableGroup) { Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(UpdateListings).AddTo(_subscriptions); }
public IObservable <IObservableGroup> ReactToGroup(IObservableGroup group) { return(Observable.Interval(TimeSpan.FromSeconds(1)).Select(x => group)); }
public void StopSystem(IObservableGroup observableGroup) { _sub.Dispose(); }