public IEnumerable <SyntaxNode> SetComponent(TranslationContext context, ExpressionSyntax entity,
                                                     Type componentType, ExpressionSyntax componentDeclaration)
        {
            var type         = TypeSystem.BuildTypeSyntax(componentType);
            var expressionId = typeof(ISharedComponentData).IsAssignableFrom(componentType)
                ? nameof(EntityCommandBuffer.Concurrent.SetSharedComponent)
                : nameof(EntityCommandBuffer.Concurrent.SetComponent);

            yield return(RoslynBuilder.MethodInvocation(
                             expressionId,
                             context.GetOrDeclareCommandBuffer(true),
                             m_Concurrent
                ? new[]
            {
                Argument(IdentifierName(context.GetJobIndexParameterName())),
                Argument(entity),
                Argument(componentDeclaration)
            }
                : new[]
            {
                Argument(entity),
                Argument(componentDeclaration)
            },
                             new[] { type }));
        }
        public IEnumerable <StatementSyntax> AddComponent(TranslationContext context, ExpressionSyntax entity,
                                                          ExpressionSyntax componentDeclaration, TypeSyntax componentTypeSyntax, bool isSharedComponent)
        {
            var expressionId = isSharedComponent
                ? nameof(EntityCommandBuffer.Concurrent.AddSharedComponent)
                : nameof(EntityCommandBuffer.Concurrent.AddComponent);

            var arguments = m_Concurrent
                ? new[]
            {
                Argument(IdentifierName(context.GetJobIndexParameterName())),
                Argument(entity),
                Argument(componentDeclaration)
            }
            : new[]
            {
                Argument(entity),
                Argument(componentDeclaration)
            };

            yield return(ExpressionStatement(RoslynBuilder.MethodInvocation(
                                                 expressionId,
                                                 context.GetOrDeclareCommandBuffer(true),
                                                 arguments,
                                                 new[] { componentTypeSyntax })));
        }
 public IEnumerable <SyntaxNode> CreateEntity(TranslationContext context)
 {
     yield return(RoslynBuilder.MethodInvocation(
                      nameof(EntityCommandBuffer.Concurrent.CreateEntity),
                      context.GetOrDeclareCommandBuffer(true),
                      m_Concurrent ? new[]
     {
         Argument(IdentifierName(context.GetJobIndexParameterName())),
     } :
                      Enumerable.Empty <ArgumentSyntax>(),
                      Enumerable.Empty <TypeSyntax>()));
 }
 public IEnumerable <SyntaxNode> Instantiate(TranslationContext context, ExpressionSyntax entity)
 {
     yield return(RoslynBuilder.MethodInvocation(
                      nameof(EntityCommandBuffer.Concurrent.Instantiate),
                      context.GetOrDeclareCommandBuffer(true),
                      m_Concurrent ? new[]
     {
         Argument(IdentifierName(context.GetJobIndexParameterName())),
         Argument(entity)
     } :  new[]
     {
         Argument(entity)
     },
                      Enumerable.Empty <TypeSyntax>()));
 }
 public IEnumerable <StatementSyntax> RemoveComponent(TranslationContext context, ExpressionSyntax entity,
                                                      string componentName)
 {
     yield return(ExpressionStatement(RoslynBuilder.MethodInvocation(
                                          nameof(EntityCommandBuffer.Concurrent.RemoveComponent),
                                          context.GetOrDeclareCommandBuffer(true),
                                          m_Concurrent
         ? new[]
     {
         Argument(IdentifierName(context.GetJobIndexParameterName())),
         Argument(entity)
     }
         : new[]
     {
         Argument(entity)
     },
                                          new[] { IdentifierName(Identifier(componentName)) })));
 }
        public IEnumerable <SyntaxNode> SetComponent(TranslationContext context, ExpressionSyntax entity,
                                                     string componentTypeName, ExpressionSyntax componentDeclaration, bool isSharedComponent)
        {
            var expressionId = isSharedComponent
                ? nameof(EntityCommandBuffer.Concurrent.SetSharedComponent)
                : nameof(EntityCommandBuffer.Concurrent.SetComponent);

            yield return(RoslynBuilder.MethodInvocation(
                             expressionId,
                             context.GetOrDeclareCommandBuffer(true),
                             m_Concurrent
                ? new[]
            {
                Argument(IdentifierName(context.GetJobIndexParameterName())),
                Argument(entity),
                Argument(componentDeclaration)
            }
                : new[]
            {
                Argument(entity),
                Argument(componentDeclaration)
            },
                             new[] { IdentifierName(componentTypeName) }));
        }
 public virtual IdentifierNameSyntax GetOrDeclareCommandBuffer(bool isConcurrent)
 {
     return(Parent.GetOrDeclareCommandBuffer(isConcurrent));
 }
Пример #8
0
 public virtual ExpressionSyntax GetOrDeclareCommandBuffer(bool isConcurrent)
 {
     return(Parent.GetOrDeclareCommandBuffer(isConcurrent));
 }