当前位置: 首页>>代码示例>>C#>>正文


C# Entity.GetComponents方法代码示例

本文整理汇总了C#中System.Entity.GetComponents方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.GetComponents方法的具体用法?C# Entity.GetComponents怎么用?C# Entity.GetComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Entity的用法示例。


在下文中一共展示了Entity.GetComponents方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Blueprint

        public Blueprint(string poolIdentifier, string name, Entity entity)
        {
            this.poolIdentifier = poolIdentifier;
            this.name = name;

            var allComponents = entity.GetComponents();
            var componentIndices = entity.GetComponentIndices();
            components = new ComponentBlueprint[allComponents.Length];
            for (int i = 0, componentsLength = allComponents.Length; i < componentsLength; i++) {
                components[i] = new ComponentBlueprint(componentIndices[i], allComponents[i]);
            }
        }
开发者ID:Cotoff,项目名称:Entitas-CSharp,代码行数:12,代码来源:Blueprint.cs

示例2: AddEntity

        internal void AddEntity(Entity mEntity)
        {
            _entities.Add(mEntity);

            foreach (var tag in mEntity.GetTags())
            {
                if (!_taggedEntities.ContainsKey(tag)) _taggedEntities.Add(tag, new HashSet<Entity>());
                _taggedEntities[tag].Add(mEntity);
            }

            foreach (var component in mEntity.GetComponents())
            {
                var componentType = component.GetType();

                if (!_componentEntities.ContainsKey(componentType))
                {
                    _componentEntities.Add(componentType, new HashSet<Entity>());
                    _components.Add(componentType, new HashSet<Component>());
                }

                _componentEntities[componentType].Add(mEntity);
                _components[componentType].Add(component);
            }
        }
开发者ID:SuperV1234,项目名称:VeeTileEngine2012,代码行数:24,代码来源:Repository.cs

示例3: RemoveEntity

        internal void RemoveEntity(Entity mEntity)
        {
            _entities.Remove(mEntity);

            foreach (var tag in mEntity.GetTags()) _taggedEntities[tag].Remove(mEntity);
            foreach (var component in mEntity.GetComponents())
            {
                var componentType = component.GetType();
                _componentEntities[componentType].Remove(mEntity);
                _components[componentType].Remove(component);
            }
        }
开发者ID:SuperV1234,项目名称:VeeTileEngine2012,代码行数:12,代码来源:Repository.cs

示例4: UtilizeEntity

 public void UtilizeEntity(Entity entity)
 {
     var components = entity.GetComponents();
     entity.ClearComponents();
     AddToSync(entity, SyncState.Remove);
 }
开发者ID:remy22,项目名称:BlueberryEngine,代码行数:6,代码来源:EntityManager.cs

示例5: DrawComponents

        public static void DrawComponents(Context context, Entity entity, bool hideInBlueprintInspector = false)
        {
            bool[] unfoldedComponents;
            if(!_contextToUnfoldedComponents.TryGetValue(context, out unfoldedComponents)) {
                unfoldedComponents = new bool[context.totalComponents];
                for (int i = 0; i < unfoldedComponents.Length; i++) {
                    unfoldedComponents[i] = true;
                }
                _contextToUnfoldedComponents.Add(context, unfoldedComponents);
            }

            EntitasEditorLayout.BeginVerticalBox();
            {
                EntitasEditorLayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Components (" + entity.GetComponents().Length + ")", EditorStyles.boldLabel);
                    if(GUILayout.Button("▸", GUILayout.Width(21), GUILayout.Height(14))) {
                        for (int i = 0; i < unfoldedComponents.Length; i++) {
                            unfoldedComponents[i] = false;
                        }
                    }
                    if(GUILayout.Button("▾", GUILayout.Width(21), GUILayout.Height(14))) {
                        for (int i = 0; i < unfoldedComponents.Length; i++) {
                            unfoldedComponents[i] = true;
                        }
                    }
                }
                EntitasEditorLayout.EndHorizontal();

                EditorGUILayout.Space();

                var index = drawAddComponentMenu(entity, hideInBlueprintInspector);
                if(index >= 0) {
                    var componentType = entity.contextInfo.componentTypes[index];
                    var component = (IComponent)Activator.CreateInstance(componentType);
                    entity.AddComponent(index, component);
                }

                EditorGUILayout.Space();

                EntitasEditorLayout.BeginHorizontal();
                {
                    _componentNameSearchTerm = EditorGUILayout.TextField("Search", _componentNameSearchTerm);

                    const string clearButtonControlName = "Clear Button";
                    GUI.SetNextControlName(clearButtonControlName);
                    if(GUILayout.Button("x", GUILayout.Width(19), GUILayout.Height(14))) {
                        _componentNameSearchTerm = string.Empty;
                        GUI.FocusControl(clearButtonControlName);
                    }
                }
                EntitasEditorLayout.EndHorizontal();

                EditorGUILayout.Space();

                var indices = entity.GetComponentIndices();
                var components = entity.GetComponents();
                for (int i = 0; i < components.Length; i++) {
                    DrawComponent(unfoldedComponents, entity, indices[i], components[i]);
                }
            }
            EntitasEditorLayout.EndVertical();
        }
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:63,代码来源:EntityDrawer.cs


注:本文中的System.Entity.GetComponents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。