public DestructibleSpawnSystem(IEventSystem eventSystem, IPoolManager poolManager)
        {
            _pool          = poolManager.GetPool("");
            _subscriptions = new List <IDisposable>();

            _eventSystem = eventSystem;
        }
Exemplo n.º 2
0
 public UIManager(IPoolManager poolManager, IEventSystem eventSystem)
 {
     CurrentScreen    = new ReactiveProperty <IEntity>();
     defaultPool      = poolManager.GetPool();
     this.eventSystem = eventSystem;
     uiGroupAccessor  = poolManager.CreateGroupAccessor(new Group(typeof(UIComponet)));
 }
Exemplo n.º 3
0
 public KillSystem(
     IEventSystem eventSystem,
     IPoolManager poolManager
     ) : base(eventSystem)
 {
     _pool = poolManager.GetPool("");
 }
Exemplo n.º 4
0
        public SceneManager(IPoolManager poolManager)
        {
            this.poolManager = poolManager;
            sceneEntities    = new Dictionary <string, IEntity>();
            scenes           = new List <string>();

            IPool defaultPool = poolManager.GetPool();

            SceneLoadedAsObservable().Subscribe(arg =>
            {
                scenes.Add(arg.Scene.name);
                var entity         = defaultPool.CreateEntity();
                var sceneComponent = new SceneComponent {
                    Scene = arg.Scene
                };
                entity.AddComponent(sceneComponent);
                sceneEntities.Add(new KeyValuePair <string, IEntity>(arg.Scene.name, entity));
            }).AddTo(disposables);

            SceneUnloadedAsObservable().Subscribe(scene =>
            {
                if (sceneEntities.ContainsKey(scene.name))
                {
                    scenes.Remove(scene.name);
                    defaultPool.RemoveEntity(sceneEntities[scene.name]);
                    sceneEntities.Remove(scene.name);
                }
            }).AddTo(disposables);
        }
Exemplo n.º 5
0
        public HitScoreSystem(IPoolManager poolManager)
        {
            var canvas = GameObject.Find("Canvas");

            _pool   = poolManager.GetPool("");
            _camera = Camera.main;
            _canvasRectTransform = canvas.GetComponent <RectTransform>();
        }
Exemplo n.º 6
0
 public EnemySpawnSystem(IEventSystem eventSystem, IPoolManager poolManager)
 {
     _pool          = poolManager.GetPool("");
     _maxEnemies    = 8;
     _enemies       = 0;
     _eventSystem   = eventSystem;
     _subscriptions = new List <IDisposable>();
 }
Exemplo n.º 7
0
 public DamageSystem(
     IEventSystem eventSystem,
     IPoolManager poolManager
     ) : base(eventSystem)
 {
     _pool        = poolManager.GetPool("");
     _eventSystem = eventSystem;
 }
Exemplo n.º 8
0
        public DestructableFactory(IPoolManager poolManager)
        {
            _pool = poolManager.GetPool("destructablePool");

            // todo: create enum to blueprint editor
            var typeLen = Enum.GetValues(typeof(DestructableTypes)).Length;

            _blueprints = new Func <IBlueprint> [typeLen];
            _blueprints[(int)DestructableTypes.PooledPrefab] = () => new SelfDestructBlueprint();
        }
Exemplo n.º 9
0
        public virtual void Initialize(IEventSystem eventSystem, IPoolManager poolManager)
        {
            Components  = new Type[] { typeof(T1), typeof(T2) };
            EventSystem = eventSystem;
            EntityPool  = poolManager.GetPool();

            cachedEntities.ObserveAdd().Select(x => x.Value).Subscribe(entity => {
                if (Predicates.Count == 0)
                {
                    PreAdd(entity);
                    AddEntity(entity);
                    return;
                }

                var bools = new List <ReactiveProperty <bool> >();
                foreach (var predicate in Predicates)
                {
                    bools.Add(predicate.Invoke(entity));
                }
                var onLatest = Observable.CombineLatest(bools.ToArray());
                onLatest.DistinctUntilChanged().Subscribe(values => {
                    if (values.All(value => value == true))
                    {
                        PreAdd(entity);
                        AddEntity(entity);
                    }
                    else
                    {
                        PreRemove(entity);
                        RemoveEntity(entity);
                    }
                }).AddTo(this.Disposer);;
            }).AddTo(this.Disposer);

            cachedEntities.ObserveRemove().Select(x => x.Value).Subscribe(entity => {
                PreRemove(entity);
                RemoveEntity(entity);
            }).AddTo(this.Disposer);

            foreach (IEntity entity in EntityPool.Entities)
            {
                if (entity.Has(Components.ToArray()))
                {
                    cachedEntities.Add(entity);
                }
            }

            EventSystem.OnEvent <EntityAddedEvent>().Where(_ => _.Entity.Has(Components.ToArray()) && cachedEntities.Contains(_.Entity) == false).Subscribe(_ => { cachedEntities.Add(_.Entity); });

            EventSystem.OnEvent <EntityRemovedEvent>().Where(_ => cachedEntities.Contains(_.Entity)).Subscribe(_ => { cachedEntities.Remove(_.Entity); });

            EventSystem.OnEvent <ComponentAddedEvent>().Where(_ => _.Entity.Has(Components.ToArray()) && cachedEntities.Contains(_.Entity) == false).Subscribe(_ => { cachedEntities.Add(_.Entity); });

            EventSystem.OnEvent <ComponentRemovedEvent>().Where(_ => Components.Contains(_.Component.GetType()) && cachedEntities.Contains(_.Entity)).Subscribe(_ => { cachedEntities.Remove(_.Entity); });
        }
Exemplo n.º 10
0
 public LevelSystem(
     IEventSystem eventSystem,
     IPoolManager poolManager,
     PlayerController playerController
     )
 {
     _pool             = poolManager.GetPool("");
     _eventSystem      = eventSystem;
     _subscriptions    = new List <IDisposable>();
     _playerController = playerController;
     _mapGo            = Resources.Load <GameObject>("Prefabs/Maps/Map_1");
 }
Exemplo n.º 11
0
        private void Awake()
        {
            var pool = _poolManager.GetPool(PoolName);
            var view = Components.FirstOrDefault(x => x.Type == typeof(ViewComponent));

            if (view == null)
            {
                view = new ViewComponent();
                Components.Add(view);
            }
            (view as ViewComponent).GameObject = this.gameObject;
            var entity     = pool.CreateEntity((IEnumerable <IComponent>)Components);
            var entityView = this.gameObject.AddComponent <EntityView>();

            entityView.Entity = entity;
            Destroy(this);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Lists the pools matching the specified filter options
        /// </summary>
        /// <param name="options">The options to use when querying for pools</param>
        /// <returns>The pools matching the specified filter options</returns>
        public IEnumerable <PSCloudPool> ListPools(ListPoolOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single pool matching the specified name
            if (!string.IsNullOrWhiteSpace(options.PoolName))
            {
                WriteVerbose(string.Format(Resources.GBP_GetByName, options.PoolName));
                using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager())
                {
                    ICloudPool  pool   = poolManager.GetPool(options.PoolName, additionalBehaviors: options.AdditionalBehaviors);
                    PSCloudPool psPool = new PSCloudPool(pool);
                    return(new PSCloudPool[] { psPool });
                }
            }
            // List pools using the specified filter
            else
            {
                ODATADetailLevel odata            = null;
                string           verboseLogString = null;
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString = Resources.GBP_GetByOData;
                    odata            = new ODATADetailLevel(filterClause: options.Filter);
                }
                else
                {
                    verboseLogString = Resources.GBP_NoFilter;
                }
                WriteVerbose(verboseLogString);

                using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager())
                {
                    IEnumerableAsyncExtended <ICloudPool> pools           = poolManager.ListPools(odata, options.AdditionalBehaviors);
                    Func <ICloudPool, PSCloudPool>        mappingFunction = p => { return(new PSCloudPool(p)); };
                    return(PSAsyncEnumerable <PSCloudPool, ICloudPool> .CreateWithMaxCount(
                               pools, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
                }
            }
        }
Exemplo n.º 13
0
        public BulletCollisionSystem(IPoolManager poolManager, IEventSystem eventSystem)
        {
            _pool        = poolManager.GetPool("");
            _eventSystem = eventSystem;

            _destructiblesAccessor = poolManager
                                     .CreateGroupAccessor(new Group(
                                                              typeof(DestructibleComponent)
                                                              ));
            _subscriptions = new List <IDisposable>();

            _eventSystem.Receive <LevelEvent>()
            .Where(x => x.action == LevelActions.START)
            .Subscribe(x =>
            {
                var destructiblesGo   = GameObject.Find("Map/Destructibles");
                _destructiblesTilemap = destructiblesGo.GetComponent <Tilemap>();
            })
            .AddTo(_subscriptions);
        }
Exemplo n.º 14
0
 public MapController(IPoolManager poolManager)
 {
     _pool = poolManager.GetPool("");
 }
Exemplo n.º 15
0
 public CoinSpawnSystem(IEventSystem eventSystem, IPoolManager poolManager) : base(eventSystem)
 {
     _pool = poolManager.GetPool("");
 }
Exemplo n.º 16
0
 public PlayerController(IPoolManager poolManager)
 {
     _pool = poolManager.GetPool("");
 }
Exemplo n.º 17
0
        public virtual void Initialize(IEventSystem eventSystem, IPoolManager poolManager)
        {
            EventSystem = eventSystem;
            EntityPool  = poolManager.GetPool();

            cachedEntities.ObserveAdd().Select(x => x.Value).Subscribe(entity =>
            {
                cachedEntitySet.Add(entity);

                if (Predicates.Count == 0)
                {
                    PreAdd(entity);
                    AddEntity(entity);
                    return;
                }

                var bools = new List <IReadOnlyReactiveProperty <bool> >();
                foreach (var predicate in Predicates)
                {
                    bools.Add(predicate.Invoke(entity));
                }
                var onLatest            = Observable.CombineLatest(bools.ToArray());
                var predicateDisposable = onLatest.DistinctUntilChanged().Subscribe(values =>
                {
                    if (values.All(value => value == true))
                    {
                        PreAdd(entity);
                        AddEntity(entity);
                    }
                    else if (Entities.Contains(entity))
                    {
                        PreRemove(entity);
                        RemoveEntity(entity);
                    }
                }).AddTo(this.Disposer);
                entityPredicateTable.Add(entity, predicateDisposable);
            }).AddTo(this.Disposer);

            cachedEntities.ObserveRemove().Select(x => x.Value).Subscribe(entity =>
            {
                cachedEntitySet.Remove(entity);

                if (entityPredicateTable.ContainsKey(entity))
                {
                    entityPredicateTable[entity].Dispose();
                    entityPredicateTable.Remove(entity);
                }

                if (Entities.Contains(entity))
                {
                    PreRemove(entity);
                    RemoveEntity(entity);
                }
            }).AddTo(this.Disposer);

            foreach (IEntity entity in EntityPool.Entities)
            {
                if (entity.HasComponents(Components))
                {
                    cachedEntities.Add(entity);
                }
            }

            EventSystem.OnEvent <EntityAddedEvent> ().Subscribe(evt =>
            {
                if (!cachedEntitySet.Contains(evt.Entity) && evt.Entity.HasComponents(Components))
                {
                    cachedEntities.Add(evt.Entity);
                }
            }).AddTo(this.Disposer);

            EventSystem.OnEvent <EntityRemovedEvent> ().Subscribe(evt =>
            {
                if (cachedEntitySet.Contains(evt.Entity))
                {
                    cachedEntities.Remove(evt.Entity);
                }
            }).AddTo(this.Disposer);

            EventSystem.OnEvent <ComponentAddedEvent> ().Subscribe(evt =>
            {
                if (Components.Contains(evt.Component.GetType()) && !cachedEntitySet.Contains(evt.Entity) && evt.Entity.HasComponents(Components))
                {
                    cachedEntities.Add(evt.Entity);
                }
            }).AddTo(this.Disposer);

            EventSystem.OnEvent <ComponentsAddedEvent> ().Subscribe(evt =>
            {
                if (!cachedEntitySet.Contains(evt.Entity) && evt.Entity.HasComponents(Components))
                {
                    cachedEntities.Add(evt.Entity);
                }
            }).AddTo(this.Disposer);

            EventSystem.OnEvent <ComponentRemovedEvent> ().Subscribe(evt =>
            {
                if (Components.Contains(evt.Component.GetType()) && cachedEntitySet.Contains(evt.Entity))
                {
                    cachedEntities.Remove(evt.Entity);
                }
            }).AddTo(this.Disposer);
        }
Exemplo n.º 18
0
        public virtual void Initialize(IEventSystem eventSystem, IPoolManager poolManager)
        {
            EventSystem = eventSystem;
            EntityPool  = poolManager.GetPool();

            cachedEntities.ObserveAdd().Select(e => e.Value).Subscribe(entity =>
            {
                if (Predicates.Count == 0)
                {
                    PreAdd(entity);
                    AddEntity(entity);
                    return;
                }

                var bools = new List <ReactiveProperty <bool> >();
                for (int i = 0; i < Predicates.Count; i++)
                {
                    bools.Add(Predicates[i].Invoke(entity));
                }
                var onLatest            = Observable.CombineLatest(bools.ToArray());
                var predicateDisposable = onLatest.DistinctUntilChanged().Subscribe(values =>
                {
                    for (int i = 0; i < values.Count; i++)
                    {
                        if (!values[i])
                        {
                            if (Entities.Contains(entity))
                            {
                                PreRemove(entity);
                                RemoveEntity(entity);
                            }
                            return;
                        }
                    }
                    PreAdd(entity);
                    AddEntity(entity);
                }).AddTo(this.Disposer);
                predicatesTable.Add(entity, predicateDisposable);
            }).AddTo(this.Disposer);

            cachedEntities.ObserveRemove().Select(e => e.Value).Subscribe(entity =>
            {
                if (predicatesTable.ContainsKey(entity))
                {
                    predicatesTable[entity].Dispose();
                    predicatesTable.Remove(entity);
                }
                PreRemove(entity);
                RemoveEntity(entity);
            }).AddTo(this.Disposer);

            foreach (IEntity entity in EntityPool.Entities)
            {
                if (entity.HasComponents(Components))
                {
                    cachedEntities.Add(entity);
                }
            }

            EventSystem.Receive <EntityAddedEvent>().Subscribe(evt =>
            {
                if (!cachedEntities.Contains(evt.Entity) && evt.Entity.HasComponents(Components))
                {
                    cachedEntities.Add(evt.Entity);
                }
            }).AddTo(this);

            EventSystem.Receive <EntityRemovedEvent>().Subscribe(evt =>
            {
                if (cachedEntities.Contains(evt.Entity))
                {
                    cachedEntities.Remove(evt.Entity);
                }
            }).AddTo(this);

            EventSystem.Receive <ComponentsAddedEvent>().Subscribe(evt =>
            {
                if (!cachedEntities.Contains(evt.Entity) && evt.Entity.HasComponents(Components))
                {
                    cachedEntities.Add(evt.Entity);
                }
            }).AddTo(this);

            EventSystem.Receive <ComponentsRemovedEvent>().Subscribe(evt =>
            {
                if (cachedEntities.Contains(evt.Entity))
                {
                    foreach (var component in evt.Components)
                    {
                        for (int i = 0; i < Components.Length; i++)
                        {
                            if (Components[i] == component.GetType())
                            {
                                cachedEntities.Remove(evt.Entity);
                                return;
                            }
                        }
                    }
                }
            }).AddTo(this);
        }
Exemplo n.º 19
0
 public SpawnSystem(IPoolManager poolManager)
 {
     _defaultPool = poolManager.GetPool();
 }
Exemplo n.º 20
0
 public PlayerFireSystem(IPoolManager poolManager)
 {
     _pool = poolManager.GetPool("");
 }
Exemplo n.º 21
0
 public BulletMovementSystem(IPoolManager poolManager)
 {
     _pool = poolManager.GetPool("");
 }
Exemplo n.º 22
0
 public SpawnSystem(IPoolManager poolManager)
 {
     TargetGroup  = new Group(typeof(SpawnerComponent), typeof(ViewComponent));
     _defaultPool = poolManager.GetPool();
 }
Exemplo n.º 23
0
 public SelfDestructionSystem(IPoolManager poolManager)
 {
     TargetGroup  = new Group(typeof(SelfDestructComponent), typeof(ViewComponent));
     _defaultPool = poolManager.GetPool();
 }
Exemplo n.º 24
0
 public SelfDestructionSystem(IPoolManager poolManager)
 {
     _defaultPool = poolManager.GetPool();
 }
Exemplo n.º 25
0
 public CoinSystem(IPoolManager poolManager)
 {
     _pool = poolManager.GetPool("");
 }
Exemplo n.º 26
0
 public EnemyCollisionSystem(IPoolManager poolManager, IEventSystem eventSystem)
 {
     _pool        = poolManager.GetPool("");
     _eventSystem = eventSystem;
 }