コード例 #1
0
        public void Convert(Entity spawnerEntity, EntityManager em, GameObjectConversionSystem conversionSystem)
        {
            Debug.Log("Prefabs authoring: GO to entities conversion.");

            var spawnerData = new SpawnerPrefabs_FromEntityData
            {
                // The referenced prefab will be converted due to DeclareReferencedPrefabs.
                // So here we simply map the game object to an entity reference to that prefab.

                prefabCarEntity = conversionSystem.GetPrimaryEntity(prefabPolice),
            };


            em.AddComponent <Prefab> (spawnerData.prefabCarEntity);

            em.AddComponent <VehicleControllsComponent> (spawnerData.prefabCarEntity);
            em.AddComponent <VehicleVelocityComponent> (spawnerData.prefabCarEntity);


            em.AddComponent <CarTag> (spawnerData.prefabCarEntity);
            em.AddComponentData(spawnerData.prefabCarEntity, new ShaderAlphaComponent()
            {
                f = 1
            });

            em.AddComponent <LIDARTag> (spawnerData.prefabCarEntity);

            em.AddComponent <NNBrainTag> (spawnerData.prefabCarEntity);
            // em.AddComponent <IsSpawningTag> ( spawnerData.prefabPoliceEntity ) ;
            em.AddSharedComponentData(spawnerData.prefabCarEntity, new NNManagerSharedComponent()
            {
                i_entityIndex = 0, i_entityVersion = 0
            });
            em.AddComponentData(spawnerData.prefabCarEntity, new NNBrainScoreComponent()
            {
                i = 0, f = 0
            });

            em.AddComponent <NNAssignedToManagerComponent> (spawnerData.prefabCarEntity);
            em.AddComponent <NNInputNeuronsValuesBuffer> (spawnerData.prefabCarEntity);
            em.AddComponent <NNHiddenNeuronsValuesBuffer> (spawnerData.prefabCarEntity);
            em.AddComponent <NNOutputNeuronsValuesBuffer> (spawnerData.prefabCarEntity);
            em.AddComponent <NNInput2HiddenLayersWeightsBuffer> (spawnerData.prefabCarEntity);
            em.AddComponent <NNHidden2OutputLayersWeightsBuffer> (spawnerData.prefabCarEntity);
            // em.AddComponent <NNHiddenLayersNeuronsBiasBuffer> ( spawnerData.prefabCarEntity ) ;

            em.AddComponent <Unity.Physics.Stateful.StatefulTriggerEvent> (spawnerData.prefabCarEntity);


            em.AddComponentData(spawnerEntity, spawnerData);
        }
        // Update is called once per frame
        protected override void OnUpdate( )
        {
            if (group_prefabs.CalculateChunkCount() == 0)
            {
                return;                                               // Early exit.
            }
            // Get prefabs.
            NativeArray <Entity> na_entities = group_prefabs.ToEntityArray(Allocator.Temp);
            Entity prefabsEntity             = na_entities [0];

            na_entities.Dispose();
            SpawnerPrefabs_FromEntityData spawner = EntityManager.GetComponentData <SpawnerPrefabs_FromEntityData> (prefabsEntity);


            // Check none active managers.
            _CheckNoneActiveMangers(this, Dependency, ref em, ref becb, ref jsonNeuralNetworkMangers, in spawner, in group_MMMamagerNotYetActive, layersNeuronCounts);

            _ExecuteActiveManager(this, Dependency, ref em, ref becb, ref eecb, ref random, ref l_managerSharedData, ref jsonNeuralNetworkMangers, in s_path, in spawner, in group_MMMamager, in group_carSpawnerPoint, in group_finishedPopulation, in group_allPopulation, in group_firstPopulation, in group_previousGeneration, in group_currentPopulation, in group_need2InitializePopulation, layersNeuronCounts);
        }