protected override StatementSyntax GetOrDeclareEntityArray(RoslynEcsTranslator.IterationContext iterationContext, out StatementSyntax arrayDisposal)
 {
     arrayDisposal = ExpressionStatement(
         InvocationExpression(
             MemberAccessExpression(
                 SyntaxKind.SimpleMemberAccessExpression,
                 IdentifierName(iterationContext.EntitiesArrayName),
                 IdentifierName(nameof(IDisposable.Dispose)))))
                     .NormalizeWhitespace();
     return(RoslynBuilder.DeclareLocalVariable(
                typeof(NativeArray <Entity>),
                iterationContext.EntitiesArrayName,
                ForEachContext.MakeInitEntityArray(iterationContext),
                RoslynBuilder.VariableDeclarationType.InferredType));
 }
Esempio n. 2
0
 protected override StatementSyntax GetOrDeclareEntityArray(RoslynEcsTranslator.IterationContext iterationContext, out StatementSyntax arrayDisposal)
 {
     m_MemberDeclarations.Insert(0, AddAttribute(
                                     RoslynBuilder.DeclareField(
                                         typeof(NativeArray <Entity>),
                                         iterationContext.EntitiesArrayName,
                                         AccessibilityFlags.Public),
                                     nameof(DeallocateOnJobCompletionAttribute),
                                     nameof(NativeDisableParallelForRestrictionAttribute)));
     m_JobInitializers.Add(AssignmentExpression(
                               SyntaxKind.SimpleAssignmentExpression,
                               IdentifierName(iterationContext.EntitiesArrayName),
                               ForEachContext.MakeInitEntityArray(iterationContext)));
     arrayDisposal = null;
     return(null); // nothing to declare in context
 }