예제 #1
0
        public void Start()
        {
            TaskUtils.SetGlobalMultithreading(false);

            ///// GRASSING!!!!!

            var singleGenerationArea = new Vector2(10, 10);
            var positionsProvider    =
                new GrassVegetationSubjectsPositionsGenerator(
                    new GrassVegetationSubjectsPositionsGenerator.
                    GrassVegetationSubjectsPositionsGeneratorConfiguration()
            {
                PositionsGridSize = singleGenerationArea
            });

            _debugGrassGroupsGrowerUnderTest = new DebugGrassGroupsGrowerUnderTest(new DebugBushPlanterUnderTest());
            _debugGrassGroupsGrowerUnderTest.Start(ComputeShaderContainer);

            GrassGroupsGrower    grassGroupsGrower    = _debugGrassGroupsGrowerUnderTest.Grower;
            Grass2RuntimeManager grass2RuntimeManager = new Grass2RuntimeManager(grassGroupsGrower,
                                                                                 new Grass2RuntimeManager.Grass2RuntimeManagerConfiguration()
            {
                GroupSize = singleGenerationArea
            });
            var vegetationSubjectsChangesListener =
                new Grass2RuntimeManagerProxy(grass2RuntimeManager);

            //////

            _runtimeManagement = new VegetationRuntimeManagement(
                positionsProvider: positionsProvider,
                vegetationSubjectsChangesListener: vegetationSubjectsChangesListener,
                visibleEntitiesContainer: new VegetationSubjectsVisibleEntitiesContainer(),
                configuration: new VegetationRuntimeManagementConfiguration()
            {
                DetailFieldsTemplate = new SingleSquareDetailFieldsTemplate(100, VegetationDetailLevel.FULL),
                UpdateMinDistance    = 10
            });

            _vegetationRuntimeManagementProxy = new VegetationRuntimeManagementProxy(_runtimeManagement);
        }
        public void Start()
        {
            TaskUtils.SetGlobalMultithreading(false);
            TreePrefabManager prefabManager = new TreePrefabManager();
            TreeClan          clan          = prefabManager.LoadTreeClan("clan1");

            _globalInstancingContainer = new GlobalGpuInstancingContainer();
            var representationContainer = new DesignBodyRepresentationContainer();
            DesignBodyInstanceBucketsContainer instanceBucketsContainer =
                new DesignBodyInstanceBucketsContainer(_globalInstancingContainer);

            var quadBillboardMesh = GameObject.CreatePrimitive(PrimitiveType.Quad).GetComponent <MeshFilter>().mesh;
            var shifter           = new TreeClanToDetailProviderShifter(new DetailProviderRepository(), quadBillboardMesh,
                                                                        representationContainer, instanceBucketsContainer);

            shifter.AddClan(clan, VegetationSpeciesEnum.Tree1A);

            _forgingContainerProxy = new ForgingVegetationSubjectInstanceContainerProxy(
                new ForgingVegetationSubjectInstanceContainer(
                    new DesignBodyPortrayalForger(
                        representationContainer,
                        instanceBucketsContainer)));

            ///// GRASSING!!!!!

            var singleGenerationArea = new Vector2(10, 10);
            var positionsProvider    = new CompositeVegetationSubjectsPositionProvider(
                new List <IVegetationSubjectsPositionsProvider>()
            {
                //CreateSamplePositionsDatabase(),
                new GrassVegetationSubjectsPositionsGenerator(
                    new GrassVegetationSubjectsPositionsGenerator.
                    GrassVegetationSubjectsPositionsGeneratorConfiguration()
                {
                    PositionsGridSize = singleGenerationArea
                })
            });

            _debugGrassGroupsGrowerUnderTest = new DebugGrassGroupsGrowerUnderTest(new DebugGrassPlanterUnderTest());
            _debugGrassGroupsGrowerUnderTest.Start(ComputeShaderContainer);

            GrassGroupsGrower    grassGroupsGrower    = _debugGrassGroupsGrowerUnderTest.Grower;
            Grass2RuntimeManager grass2RuntimeManager = new Grass2RuntimeManager(grassGroupsGrower,
                                                                                 new Grass2RuntimeManager.Grass2RuntimeManagerConfiguration()
            {
                GroupSize = singleGenerationArea
            });
            var vegetationSubjectsChangesListener = new CompositeVegetationSubjectsChangesListener(
                new List <VegetationSubjectsInstancingChangeListenerWithFilter>()
            {
                new VegetationSubjectsInstancingChangeListenerWithFilter()
                {
                    ChangeListener = new Grass2RuntimeManagerProxy(grass2RuntimeManager),
                    Filter         = (entity => entity.Detail.SpeciesEnum == VegetationSpeciesEnum.Grass2SpotMarker)
                },
                //new VegetationSubjectsInstancingChangeListenerWithFilter()
                //{
                //    ChangeListener = _forgingContainerProxy,
                //    Filter = entity => true
                //}
            });

            //////

            _runtimeManagement = new VegetationRuntimeManagement(
                positionsProvider: positionsProvider,
                vegetationSubjectsChangesListener: vegetationSubjectsChangesListener,
                visibleEntitiesContainer: new VegetationSubjectsVisibleEntitiesContainer(),
                configuration: new VegetationRuntimeManagementConfiguration()
            {
                DetailFieldsTemplate = new CenterHolesDetailFieldsTemplate(new List <DetailFieldsTemplateOneLine>()
                {
                    new DetailFieldsTemplateOneLine(VegetationDetailLevel.FULL, 0, 60),
                    new DetailFieldsTemplateOneLine(VegetationDetailLevel.REDUCED, 40, 120),
                    new DetailFieldsTemplateOneLine(VegetationDetailLevel.BILLBOARD, 100, 280),
                }),
                UpdateMinDistance = 10
            });

            _vegetationRuntimeManagementProxy = new VegetationRuntimeManagementProxy(_runtimeManagement);
            _forgingContainerProxy.StartThreading(() => { });
        }