Entitas.Group.HandleEntity C# (CSharp) Method

HandleEntity() public method

public HandleEntity ( Entity entity, int index, IComponent component ) : void
entity Entity
index int
component IComponent
return void
        public void HandleEntity(
            Entity entity, int index, IComponent component)
        {
            if(_matcher.Matches(entity)) {
                addEntity(entity, index, component);
            } else {
                removeEntity(entity, index, component);
            }
        }

Usage Example

示例#1
0
        public virtual Group GetGroup(IMatcher matcher)
        {
            Group group;

            if (!_groups.TryGetValue(matcher, out group))
            {
                group = new Group(matcher);
                var entities = GetEntities();
                for (int i = 0, entitiesLength = entities.Length; i < entitiesLength; i++)
                {
                    group.HandleEntity(entities[i]);
                }
                _groups.Add(matcher, group);

                for (int i = 0, indicesLength = matcher.indices.Length; i < indicesLength; i++)
                {
                    var index = matcher.indices[i];
                    if (_groupsForIndex[index] == null)
                    {
                        _groupsForIndex[index] = new List <Group>();
                    }
                    _groupsForIndex[index].Add(group);
                }

                if (OnGroupCreated != null)
                {
                    OnGroupCreated(this, group);
                }
            }

            return(group);
        }
All Usage Examples Of Entitas.Group::HandleEntity