コード例 #1
0
        public static uint CreateAll <T>(uint startIndex, ExclusiveGroup group, Transform contextHolder,
                                         IEntityFactory factory) where T : MonoBehaviour, IEntityDescriptorHolder
        {
            var holders = contextHolder.GetComponentsInChildren <T>(true);

            foreach (var holder in holders)
            {
                var implementors = holder.GetComponents <IImplementor>();

                ExclusiveGroup.ExclusiveGroupStruct realGroup = group;

                if (string.IsNullOrEmpty(holder.groupName) == false)
                {
                    realGroup = ExclusiveGroup.Search(holder.groupName);
                }

                EGID egid;
                var  holderId = holder.id;
                if (holderId == 0)
                {
                    egid = new EGID(startIndex++, realGroup);
                }
                else
                {
                    egid = new EGID(holderId, realGroup);
                }

                var init = factory.BuildEntity(egid, holder.GetDescriptor(), implementors);

                init.Init(new EntityHierarchyStruct(group));
            }

            return(startIndex);
        }
コード例 #2
0
        static uint InternalBuildAll(uint startIndex, IEntityDescriptorHolder descriptorHolder,
                                     IEntityFactory factory, ExclusiveGroup group, IImplementor[] implementors, string groupNamePostfix)
        {
            ExclusiveGroupStruct realGroup = group;

            if (string.IsNullOrEmpty(descriptorHolder.groupName) == false)
            {
                realGroup = ExclusiveGroup.Search(!string.IsNullOrEmpty(groupNamePostfix)
                    ? $"{descriptorHolder.groupName}{groupNamePostfix}"
                    : descriptorHolder.groupName);
            }

            EGID egid;
            var  holderId = descriptorHolder.id;

            if (holderId == 0)
            {
                egid = new EGID(startIndex++, realGroup);
            }
            else
            {
                egid = new EGID(holderId, realGroup);
            }

            var init = factory.BuildEntity(egid, descriptorHolder.GetDescriptor(), implementors);

            init.Init(new EntityHierarchyComponent(group));

            return(startIndex);
        }
コード例 #3
0
        IEnumerator PollForInput()
        {
            while (true)
            {
                while (_buttonConsumer.TryDequeue(out var entity))
                {
                    if (entity.message == ButtonEvents.SELECT)
                    {
                        IGuiViewIndex guiViewIndex = entitiesDB.QueryEntity <GuiViewIndexEntityViewStruct>(entity.ID).guiViewIndex;

                        ExclusiveGroup.ExclusiveGroupStruct group = entity.ID.groupID;
                        if (string.IsNullOrEmpty(guiViewIndex.groupName) == false)
                        {
                            group = ExclusiveGroup.Search(guiViewIndex.groupName);
                        }

                        var entities = entitiesDB.QueryEntities <GUIEntityViewStruct>(group);
                        foreach (var gui in entities)
                        {
                            gui.guiRoot.view = guiViewIndex.index;
                        }
                    }
                }

                yield return(null);
            }
        }
コード例 #4
0
        /// <summary>
        /// Works like CreateAll but only builds entities with holders that have the same group specified
        /// </summary>
        /// <param name="startId"></param>
        /// <param name="group">The group to match</param>
        /// <param name="contextHolder"></param>
        /// <param name="factory"></param>
        /// <typeparam name="T">EntityDescriptorHolder type</typeparam>
        /// <returns>Next available ID</returns>
        public static uint CreateAllInMatchingGroup <T>(uint startId, ExclusiveGroup exclusiveGroup,
                                                        Transform contextHolder, IEntityFactory factory) where T : MonoBehaviour, IEntityDescriptorHolder
        {
            var holders = contextHolder.GetComponentsInChildren <T>(true);

            foreach (var holder in holders)
            {
                if (string.IsNullOrEmpty(holder.groupName) == false)
                {
                    var realGroup = ExclusiveGroup.Search(holder.groupName);
                    if (realGroup != exclusiveGroup)
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }

                var implementors = holder.GetComponents <IImplementor>();

                startId = InternalBuildAll(startId, holder, factory, exclusiveGroup, implementors, null);
            }

            return(startId);
        }
コード例 #5
0
        public static void CreateAll <T>(ExclusiveGroup group, Transform contextHolder,
                                         IEntityFactory factory) where T : MonoBehaviour, IEntityDescriptorHolder
        {
            var holders = contextHolder.GetComponentsInChildren <T>(true);

            foreach (var holder in holders)
            {
                var implementors = holder.GetComponents <IImplementor>();

                ExclusiveGroup.ExclusiveGroupStruct realGroup = group;

                if (string.IsNullOrEmpty(holder.groupName) == false)
                {
                    realGroup = ExclusiveGroup.Search(holder.groupName);
                }

                factory.BuildEntity(holder.GetInstanceID(), realGroup, holder.GetDescriptor(), implementors);
            }
        }