コード例 #1
0
        public ObservableGroup(ObservableGroupToken token, IEnumerable <IEntity> initialEntities, INotifyingEntityCollection notifyingCollection)
        {
            Token = token;
            NotifyingCollection = notifyingCollection;

            _onEntityAdded    = new Subject <IEntity>();
            _onEntityRemoved  = new Subject <IEntity>();
            _onEntityRemoving = new Subject <IEntity>();

            Subscriptions  = new List <IDisposable>();
            CachedEntities = initialEntities.Where(x => Token.LookupGroup.Matches(x)).ToDictionary(x => x.Id, x => x);

            MonitorEntityChanges();
        }
コード例 #2
0
ファイル: ObservableGroup.cs プロジェクト: redchew-fork/ecsrx
        private void MonitorEntityChanges(INotifyingEntityCollection notifyingCollection)
        {
            notifyingCollection.EntityAdded
            .Subscribe(OnEntityAddedToCollection)
            .AddTo(Subscriptions);

            notifyingCollection.EntityRemoved
            .Subscribe(OnEntityRemovedFromCollection)
            .AddTo(Subscriptions);

            notifyingCollection.EntityComponentsAdded
            .Subscribe(OnEntityComponentAdded)
            .AddTo(Subscriptions);

            notifyingCollection.EntityComponentsRemoving
            .Subscribe(OnEntityComponentRemoving)
            .AddTo(Subscriptions);

            notifyingCollection.EntityComponentsRemoved
            .Subscribe(OnEntityComponentRemoved)
            .AddTo(Subscriptions);
        }