Beispiel #1
0
 void BuildCriteriaForComponentQuery(ComponentQueryDeclarationModel componentQueryDeclarationModel, ref int nbRows, Blackboard blackboard)
 {
     Sortable = true;
     ExpandableRowTitleContainer.AddManipulator(new Clickable(() => {}));
     ExpandableRowTitleContainer.Add(new Button(() => { AddCriteriaModel(componentQueryDeclarationModel); })
     {
         name = "addCriteriaButton", text = "+"
     });
     componentQueryDeclarationModel.ExpandOnCreateUI = false;
     nbRows += AddCriteriaModelRows(componentQueryDeclarationModel, ExpandedContainer);
 }
        public QuerySubSection(Stencil stencil,
                               ComponentQueryDeclarationModel componentQueryDeclarationModel,
                               Blackboard blackboard)
            : base("",
                   graphElementModel: null,
                   store: blackboard.Store,
                   parentElement: null,
                   rebuildCallback: null,
                   canAcceptDrop: null)
        {
            name     = "queriesSection";
            userData = name;

            AddToClassList("subSection");
            State state = blackboard.Store.GetState();

            var componentQuery = new ComponentQuery(componentQueryDeclarationModel, Store, blackboard.Rebuild);

            Sortable = true;
            ExpandableRowTitleContainer.AddManipulator(new Clickable(() => {}));
            ExpandableRowTitleContainer.Add(componentQuery);
            ExpandableRowTitleContainer.Add(new Label($"({(componentQueryDeclarationModel.Query?.Components?.Count ?? 0)})")
            {
                name = "count"
            });
            var rowName = $"{ComponentQueriesRow.BlackboardEcsProviderTypeName}/{GetType().Name}/{componentQueryDeclarationModel}";

            OnExpanded += e =>
                          Store.GetState().EditorDataModel?.ExpandBlackboardRowsUponCreation(new[] { rowName }, e);
            if (state.EditorDataModel.ShouldExpandBlackboardRowUponCreation(rowName))
            {
                Expanded = true;
            }

            ExpandedContainer.Add(new ComponentsSubSection(stencil, componentQueryDeclarationModel, blackboard));
            ExpandedContainer.Add(new CriteriaSubSection(stencil, componentQueryDeclarationModel, blackboard));
            blackboard.GraphVariables.Add(componentQuery);
        }