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


C# Entity.Release方法代码示例

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


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

示例1: removeEntitySilently

 void removeEntitySilently(Entity entity) {
     var removed = _entities.Remove(entity);
     if (removed) {
         _entitiesCache = null;
         _singleEntityCache = null;
         entity.Release();
     }
 }
开发者ID:jyunfan2015,项目名称:Entitasteroids,代码行数:8,代码来源:Group.cs

示例2: DestroyEntity

        public virtual void DestroyEntity(Entity entity)
        {
            var removed = _entities.Remove(entity);
            if (!removed) {
                throw new PoolDoesNotContainEntityException(entity,
                    "Could not destroy entity!");
            }
            _entitiesCache = null;

            if (OnEntityWillBeDestroyed != null) {
                OnEntityWillBeDestroyed(this, entity);
            }

            entity.destroy();

            if (OnEntityDestroyed != null) {
                OnEntityDestroyed(this, entity);
            }

            if (entity._refCount == 1) {
                entity.OnEntityReleased -= _cachedOnEntityReleased;
                _reusableEntities.Push(entity);
            } else {
                _retainedEntities.Add(entity);
            }
            entity.Release();
        }
开发者ID:namlunoy,项目名称:Entitas-CSharp,代码行数:27,代码来源:Pool.cs

示例3: DrawEntity

        public static void DrawEntity(Pool pool, Entity entity)
        {
            var bgColor = GUI.backgroundColor;
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Destroy Entity")) {
                pool.DestroyEntity(entity);
            }
            GUI.backgroundColor = bgColor;

            DrawComponents(pool, entity);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Retained by (" + entity.retainCount + ")", EditorStyles.boldLabel);

            #if !ENTITAS_FAST_AND_UNSAFE

            EntitasEditorLayout.BeginVerticalBox();
            {
                foreach (var owner in entity.owners.ToArray()) {
                    EntitasEditorLayout.BeginHorizontal();
                    {
                        EditorGUILayout.LabelField(owner.ToString());
                        if (GUILayout.Button("Release", GUILayout.Width(88), GUILayout.Height(14))) {
                            entity.Release(owner);
                        }
                        EntitasEditorLayout.EndHorizontal();
                    }
                }
            }
            EntitasEditorLayout.EndVertical();

            #endif
        }
开发者ID:JamesMcMahon,项目名称:entitas-2d-roguelike,代码行数:34,代码来源:EntityDrawer.cs

示例4: removeEntity

 void removeEntity(Entity entity, int index, IComponent component) {
     var removed = _entities.Remove(entity);
     if (removed) {
         _entitiesCache = null;
         _singleEntityCache = null;
         if (OnEntityRemoved != null) {
             OnEntityRemoved(this, entity, index, component);
         }
         entity.Release(this);
     }
 }
开发者ID:ntl92bk,项目名称:Entitas-CSharp,代码行数:11,代码来源:Group.cs

示例5: removeEntitySilently

        bool removeEntitySilently(Entity entity) {
            var removed = _entities.Remove(entity);
            if (removed) {
                _entitiesCache = null;
                _singleEntityCache = null;
                entity.Release(this);
            }

            return removed;
        }
开发者ID:ntl92bk,项目名称:Entitas-CSharp,代码行数:10,代码来源:Group.cs

示例6: DestroyEntity

        public virtual void DestroyEntity(Entity entity) {
            var removed = _entities.Remove(entity);
            if (!removed) {
                throw new PoolDoesNotContainEntityException("'" + this + "' cannot destroy " + entity + "!",
                    "Did you call pool.DestroyEntity() on a wrong pool?");
            }
            _entitiesCache = null;

            if (OnEntityWillBeDestroyed != null) {
                OnEntityWillBeDestroyed(this, entity);
            }

            entity.destroy();

            if (OnEntityDestroyed != null) {
                OnEntityDestroyed(this, entity);
            }

            if (entity.retainCount == 1) {
                entity.OnEntityReleased -= _cachedOnEntityReleased;
                _reusableEntities.Push(entity);
            } else {
                _retainedEntities.Add(entity);
            }
            entity.Release(this);
        }
开发者ID:thebatoust,项目名称:EntitasTurnBasedGame,代码行数:26,代码来源:Pool.cs

示例7: DrawEntity

        public static void DrawEntity(Pool pool, Entity entity)
        {
            var bgColor = GUI.backgroundColor;
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Destroy Entity")) {
                pool.DestroyEntity(entity);
            }
            GUI.backgroundColor = bgColor;

            bool[] unfoldedComponents;
            if (!_poolToUnfoldedComponents.TryGetValue(pool, out unfoldedComponents)) {
                unfoldedComponents = new bool[pool.totalComponents];
                for (int i = 0; i < unfoldedComponents.Length; i++) {
                    unfoldedComponents[i] = true;
                }
                _poolToUnfoldedComponents.Add(pool, 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 componentNames = entity.poolMetaData.componentNames;
                var index = EditorGUILayout.Popup("Add Component", -1, componentNames);
                if (index >= 0) {
                    var componentType = entity.poolMetaData.componentTypes[index];
                    var component = (IComponent)Activator.CreateInstance(componentType);
                    entity.AddComponent(index, component);
                }

                EditorGUILayout.Space();

                _componentNameSearchTerm = EditorGUILayout.TextField("Search", _componentNameSearchTerm);

                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]);
                }

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Retained by (" + entity.retainCount + ")", EditorStyles.boldLabel);

                #if !ENTITAS_FAST_AND_UNSAFE

                EntitasEditorLayout.BeginVerticalBox();
                {
                    foreach (var owner in entity.owners.ToArray()) {
                        EntitasEditorLayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField(owner.ToString());
                            if (GUILayout.Button("Release", GUILayout.Width(88), GUILayout.Height(14))) {
                                entity.Release(owner);
                            }
                            EntitasEditorLayout.EndHorizontal();
                        }
                    }
                }
                EntitasEditorLayout.EndVertical();

                #endif
            }
            EntitasEditorLayout.EndVertical();
        }
开发者ID:robinryf,项目名称:Entitas-CSharp,代码行数:83,代码来源:EntityDrawer.cs

示例8: DestroyEntity

        public virtual void DestroyEntity(Entity entity)
        {
            var removed = _entities.Remove(entity);
            if(!removed) {
                throw new ContextDoesNotContainEntityException(
                    "'" + this + "' cannot destroy " + entity + "!",
                    "Did you call context.DestroyEntity() on a wrong context?"
                );
            }
            _entitiesCache = null;

            if(OnEntityWillBeDestroyed != null) {
                OnEntityWillBeDestroyed(this, entity);
            }

            entity.destroy();

            if(OnEntityDestroyed != null) {
                OnEntityDestroyed(this, entity);
            }

            if(entity.retainCount == 1) {
                // Can be released immediately without
                // adding to _retainedEntities
                entity.OnEntityReleased -= _cachedEntityReleased;
                _reusableEntities.Push(entity);
                entity.Release(this);
                entity.removeAllOnEntityReleasedHandlers();
            } else {
                _retainedEntities.Add(entity);
                entity.Release(this);
            }
        }
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:33,代码来源:Context.cs


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