コード例 #1
0
        protected override IDisposable ReactToPools()
        {
            var componentType1 = ComponentTypeLookup.GetComponentType(typeof(T1));
            var componentType2 = ComponentTypeLookup.GetComponentType(typeof(T2));
            var pool1          = ComponentDatabase.GetPoolFor <T1>(componentType1);
            var pool2          = ComponentDatabase.GetPoolFor <T2>(componentType2);

            var subscriptions = new CompositeDisposable();

            pool1.OnPoolExtending.Subscribe(_ => Refresh()).AddTo(subscriptions);
            pool2.OnPoolExtending.Subscribe(_ => Refresh()).AddTo(subscriptions);

            return(subscriptions);
        }
コード例 #2
0
        public void AddComponents(IReadOnlyList <IComponent> components)
        {
            var componentTypeIds = new int[components.Count];

            for (var i = 0; i < components.Count; i++)
            {
                var componentTypeId = ComponentTypeLookup.GetComponentType(components[i].GetType());
                var allocationId    = ComponentDatabase.Allocate(componentTypeId);
                InternalComponentAllocations[componentTypeId] = allocationId;
                ComponentDatabase.Set(componentTypeId, allocationId, components[i]);
            }

            _onComponentsAdded.OnNext(componentTypeIds);
        }
コード例 #3
0
        public IComponent GetComponent(Type componentType)
        {
            var componentTypeId = ComponentTypeLookup.GetComponentType(componentType);

            return(GetComponent(componentTypeId));
        }
コード例 #4
0
        public bool HasComponent(Type componentType)
        {
            var componentTypeId = ComponentTypeLookup.GetComponentType(componentType);

            return(HasComponent(componentTypeId));
        }