示例#1
0
        public Node GetNode(ComponentMatcher componentMatcher)
        {
            if (!nodes.TryGetValue(componentMatcher, out Node node))
            {
                node = new Node(componentMatcher);
                var entities = GetAllEntities();
                for (int i = 0; i < entities.Length; i++)
                {
                    node.HandleEntity(entities[i]);
                }
                nodes.Add(componentMatcher, node);

                var matcherIndices = componentMatcher.GetIndices();
                for (int i = 0; i < matcherIndices.Length; i++)
                {
                    var componentID = matcherIndices[i];
                    if (nodesForComponentId[componentID] == null)
                    {
                        var nodeList = new List <Node>();
                        nodesForComponentId[componentID] = nodeList;
                    }
                    nodesForComponentId[componentID].Add(node);
                }
            }
            return(node);
        }
示例#2
0
文件: Node.cs 项目: jjenber/MonoECS
 public Node(ComponentMatcher matcher)
 {
     this.matcher = matcher;
 }