示例#1
0
        public static void Compile()
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();
            var assemblyToInjectPath = Path.GetFullPath(TempStagingManaged + MainAssemblyFileName);
            var injectedTypes        =
                GenericResolver.InjectTypes(BufferGroupUtility.CreatePossibleTypes()
                                            .Union(BufferGroupUtility.GetFixedBufferProperties()),
                                            assemblyToInjectPath, $"Concrete{nameof(Renderer)}");

            watch.Stop();

            var log = $"{nameof(Stackray)}.{nameof(Renderer)} - {watch.ElapsedMilliseconds * 0.001f}s to inject {injectedTypes.Count()} concrete types in assembly '{Path.GetFullPath(assemblyToInjectPath)}'";

            Debug.Log(log);
            log += "\n" + string.Join("\n", injectedTypes);
            WriteLog(log);
        }
        protected override void OnCreate()
        {
            m_availableFixedBuffers   = BufferGroupUtility.GetAvailableBufferProperties(typeof(IFixedBufferProperty <>), inst => ((IBufferProperty)inst).BufferName);
            m_availableDynamicBuffers = BufferGroupUtility.GetAvailableBufferProperties(typeof(IDynamicBufferProperty <>), inst => ((IBufferProperty)inst).BufferName);
            var queryDesc = new EntityQueryDesc {
                All = new ComponentType[] {
                    ComponentType.ReadOnly <RenderMesh>(),
                    ComponentType.ChunkComponent <ChunkWorldRenderBounds>()
                }.Union(m_availableFixedBuffers.Select(kvp => ComponentType.ReadOnly(kvp.Key))).ToArray(),
                Any = m_availableDynamicBuffers.Select(kvp => ComponentType.ReadOnly(kvp.Key)).ToArray()
            };

            m_renderQuery          = GetEntityQuery(queryDesc);
            m_missingColorProperty = GetEntityQuery(new EntityQueryDesc {
                All = new ComponentType[] {
                    ComponentType.ReadOnly <RenderMesh>(),
                    ComponentType.ChunkComponent <ChunkWorldRenderBounds>()
                },
                None = new ComponentType[] { ComponentType.ReadOnly <ColorProperty>() }
            });
        }