public void Execute(int i)
            {
                const float RANGE  = 10f;
                var         random = random_list_[i];
                var         pos    = new float3(random.range(-RANGE, RANGE),
                                                random.range(-RANGE, RANGE),
                                                random.range(-RANGE, RANGE));

                ECSExplosionManager.spawn(command_buffer_,
                                          time_,
                                          ref pos,
                                          random.range(-Mathf.PI, Mathf.PI));
                random_list_[i] = random;
            }
#pragma warning restore 0169

        protected override void OnUpdate()
        {
            LaserSystem.Sync();
            ZakoSystem.Sync();

            var spawner = ECSExplosionManager.GetExplosionSpawnDataQueue();
            ExplosionSpawnData data;

            while (spawner.TryDequeue(out data))
            {
                ECSExplosionManager.spawn(PostUpdateCommands,
                                          Time.GetCurrent(),
                                          ref data.position_,
                                          0f /* rotation1 */);
            }
        }
Beispiel #3
0
 protected override void OnUpdate()
 {
     for (var i = 0; i < group_.random_list_.Length; ++i)
     {
         const float RANGE  = 10f;
         var         time   = Time.GetCurrent();
         var         random = group_.random_list_[i];
         var         pos    = new float3(random.range(-RANGE, RANGE),
                                         random.range(-RANGE, RANGE),
                                         random.range(-RANGE, RANGE));
         ECSExplosionManager.spawn(PostUpdateCommands,
                                   time,
                                   ref pos,
                                   random.range(-Mathf.PI, Mathf.PI));
         group_.random_list_[i] = random;
     }
 }
Beispiel #4
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            rigidbody_position_system_.Sync();

            handle_ = inputDeps;

            Entity player_entity = SystemManager.Instance.getPrimaryPlayer();
            var    job           = new ZakoJob {
                time_              = Time.GetCurrent(),
                dt_                = Time.GetDT(),
                player_pos_        = position_list_from_entity_[player_entity],
                group_             = group_,
                bullet_spawner_    = ECSBulletManager.GetBulletSpawnDataQueue().ToConcurrent(),
                explosion_spawner_ = ECSExplosionManager.GetExplosionSpawnDataQueue().ToConcurrent(),
            };

            handle_ = job.Schedule(group_.zako_list_.Length, 8, handle_);

            return(handle_);
        }
        void OnEnable()
        {
            explosion_spawn_data_queue_ = new NativeQueue <ExplosionSpawnData>(Allocator.Persistent);

            var entity_manager = World.Active.GetOrCreateManager <EntityManager>();

            arche_type_ = entity_manager.CreateArchetype(typeof(Destroyable)
                                                         , typeof(Position)
                                                         , typeof(Rotation)
                                                         , typeof(LocalToWorld)
                                                         , typeof(Frozen)
                                                         , typeof(AlivePeriod)
                                                         , typeof(StartTime)
                                                         , typeof(MeshInstanceRenderer)
                                                         );
            Vector3[] vertices = new Vector3[4];
            Vector2[] uvs      =
            {
                new Vector2(0, 0),
                new Vector2(1, 0),
                new Vector2(0, 1),
                new Vector2(1, 1),
            };
            int[] triangles =
            {
                0, 1, 2,
                2, 1, 3,
            };
            mesh_           = new Mesh();
            mesh_.vertices  = vertices;
            mesh_.uv        = uvs;
            mesh_.triangles = triangles;
            mesh_.bounds    = new Bounds(Vector3.zero, Vector3.one * 99999999);

            instance_ = GameObject.Find("explosion_manager").GetComponent <ECSExplosionManager>();
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            handle_ = inputDeps;

            var entity_manager = Unity.Entities.World.Active.GetOrCreateManager <EntityManager>();
            var job            = new Job()
            {
                time_             = Time.GetCurrent(),
                dt_               = Time.GetDT(),
                flow_z_           = CV.FLOW_VELOCITY,
                entity_list_      = group_.entity_list_,
                laser_list_       = group_.laser_list_,
                position_list_    = group_.position_list_,
                rb_position_list_ = group_.rb_position_list_,
                local_to_world_list_from_entity_ = local_to_world_list_from_entity_,
                trail_data_list_   = group_.trail_data_list_,
                destroyable_list_  = group_.destroyable_list_,
                explosion_spawner_ = ECSExplosionManager.GetExplosionSpawnDataQueue(),
            };

            handle_ = job.Schedule(group_.rb_position_list_.Length, 8, handle_);

            return(handle_);
        }