當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。