Ejemplo n.º 1
0
        protected override void OnCreateLoopVariables(VariableCreator variableCreator, IPortModel connectedPortModel)
        {
            if ((connectedPortModel?.NodeModel as IObjectReference)?.ReferencedObject is
                VariableDeclarationModel variableDeclarationModel &&
                variableDeclarationModel.DataType != typeof(EntityQuery).GenerateTypeHandle(Stencil))
            {
                return;
            }

            var componentQueryDeclarationModel = ComponentQueryDeclarationModel;
            var entityName = componentQueryDeclarationModel != null
                ? $"{componentQueryDeclarationModel.VariableName}Entity"
                : "Entity";

            ItemVariableDeclarationModel = variableCreator.DeclareVariable <LoopVariableDeclarationModel>(
                entityName,
                typeof(Entity).GenerateTypeHandle(Stencil),
                TitleComponentIcon.Item,
                VariableFlags.Generated | VariableFlags.Hidden);
            CollectionVariableDeclarationModel = variableCreator.DeclareVariable <LoopVariableDeclarationModel>(
                DefaultCollectionName,
                typeof(EntityQuery).GenerateTypeHandle(Stencil),
                TitleComponentIcon.Collection,
                VariableFlags.Generated | VariableFlags.Hidden);

            Assert.AreEqual(k_NonComponentVariablesCount, variableCreator.DeclaredVariablesCount);

            CreateComponentVariables(Stencil, variableCreator, this);
        }
Ejemplo n.º 2
0
 protected override void OnCreateLoopVariables(VariableCreator variableCreator, IPortModel connectedPortModel)
 {
     base.OnCreateLoopVariables(variableCreator, connectedPortModel);
     variableCreator.DeclareVariable <LoopVariableDeclarationModel>(
         "ev",
         EventTypeHandle,
         LoopStackModel.TitleComponentIcon.Item, VariableFlags.None);
 }
Ejemplo n.º 3
0
        internal static void CreateComponentVariables(Stencil stencil, VariableCreator variableCreator, IIteratorStackModel iteratorStackModel)
        {
            var componentQueryDeclarationModel = iteratorStackModel.ComponentQueryDeclarationModel;

            if (componentQueryDeclarationModel != null)
            {
                foreach (QueryComponent component in componentQueryDeclarationModel.Components.Where(def => !def.Component.Subtract))
                {
                    variableCreator.DeclareVariable <LoopVariableDeclarationModel>(
                        component.Component.TypeHandle.GetMetadata(stencil).FriendlyName,
                        component.Component.TypeHandle,
                        TitleComponentIcon.Item,
                        VariableFlags.Generated,
                        component.ForceInsert);
                    component.ForceInsert = false;
                }
            }
        }