Exemplo n.º 1
0
        protected override TreeViewItem BuildRoot()
        {
            componentGroupsById.Clear();
            queriesById.Clear();
            controlsById.Clear();
            var currentId = 0;
            var root      = new TreeViewItem {
                id = currentId++, depth = -1, displayName = "Root"
            };

            if (getWorldSelection() == null)
            {
                root.AddChild(new TreeViewItem {
                    id = currentId, displayName = "No world selected"
                });
            }
            else if (SelectedSystem == null)
            {
                root.AddChild(new TreeViewItem {
                    id = currentId, displayName = "Null System"
                });
            }
            else
            {
                var queries       = GetQueriesForSystem(SelectedSystem);
                var entityManager = getWorldSelection().EntityManager;

                foreach (var query in queries)
                {
                    var group = entityManager.CreateEntityQuery(query);
                    queriesById.Add(currentId, query);
                    componentGroupsById.Add(currentId, group);

                    var groupItem = new TreeViewItem {
                        id = currentId++
                    };
                    root.AddChild(groupItem);
                }
                if (SelectedSystem.EntityQueries != null)
                {
                    foreach (var group in SelectedSystem.EntityQueries)
                    {
                        componentGroupsById.Add(currentId, group);

                        var groupItem = new TreeViewItem {
                            id = currentId++
                        };
                        root.AddChild(groupItem);
                    }
                }
                if (componentGroupsById.Count == 0)
                {
                    root.AddChild(new TreeViewItem {
                        id = currentId, displayName = "No Component Groups or Queries in Manager"
                    });
                }
                else
                {
                    SetupDepthsFromParentsAndChildren(root);

                    foreach (var idGroupPair in componentGroupsById)
                    {
                        var newControl = new EntityQueryGUIControl(idGroupPair.Value.GetQueryTypes(), idGroupPair.Value.GetReadAndWriteTypes(), true);
                        controlsById.Add(idGroupPair.Key, newControl);
                    }
                }
            }
            return(root);
        }
Exemplo n.º 2
0
        protected unsafe override TreeViewItem BuildRoot()
        {
            queriesById.Clear();
            queryDescsById.Clear();
            controlsById.Clear();
            var currentId = 0;
            var root      = new TreeViewItem {
                id = currentId++, depth = -1, displayName = "Root"
            };

            if (getWorldSelection() == null)
            {
                root.AddChild(new TreeViewItem {
                    id = currentId, displayName = "No world selected"
                });
            }
            else if (SelectedSystem == null)
            {
                root.AddChild(new TreeViewItem {
                    id = currentId, displayName = "Null System"
                });
            }
            else
            {
                var queryDescs    = GetQueryDescsForSystem(SelectedSystem);
                var entityManager = getWorldSelection().EntityManager;

                foreach (var queryDesc in queryDescs)
                {
                    var group = entityManager.CreateEntityQuery(queryDesc);
                    queryDescsById.Add(currentId, queryDesc);
                    queriesById.Add(currentId, group);

                    var groupItem = new TreeViewItem {
                        id = currentId++
                    };
                    root.AddChild(groupItem);
                }
                var ptr = SelectedSystem.StatePointer;
                if (ptr != null && ptr->EntityQueries.Length > 0)
                {
                    ref var queries = ref ptr->EntityQueries;
                    for (int i = 0; i < queries.Length; ++i)
                    {
                        var query = queries[i];
                        queriesById.Add(currentId, query);

                        var queryItem = new TreeViewItem {
                            id = currentId++
                        };
                        root.AddChild(queryItem);
                    }
                }
                if (queriesById.Count == 0)
                {
                    root.AddChild(new TreeViewItem {
                        id = currentId, displayName = "No Entity Queries in System"
                    });
                }
                else
                {
                    SetupDepthsFromParentsAndChildren(root);

                    foreach (var idQueryPair in queriesById)
                    {
                        var newControl = new EntityQueryGUIControl(idQueryPair.Value.GetQueryTypes(), idQueryPair.Value.GetReadAndWriteTypes(), true);
                        controlsById.Add(idQueryPair.Key, newControl);
                    }
                }
            }