#pragma warning restore 0169

        protected override void OnUpdate()
        {
            PlayerSystem.Sync();
            ZakoSystem.Sync();
            var             spawner = ECSBulletManager.GetBulletSpawnDataQueue();
            BulletSpawnData data;

            while (spawner.TryDequeue(out data))
            {
                if (data.type_ == 0)
                {
                    ECSBulletManager.spawnBullet(PostUpdateCommands,
                                                 Time.GetCurrent(),
                                                 ref data.position_,
                                                 ref data.velocity_);
                }
                else
                {
                    ECSBulletManager.spawnEnemyBullet(PostUpdateCommands,
                                                      Time.GetCurrent(),
                                                      ref data.position_,
                                                      ref data.velocity_);
                }
            }
        }
Esempio n. 2
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_);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            CollisionSystem.Sync();
            CursorSystem.Sync();
            game_camera_update_system_.Sync();

            handle_ = inputDeps;

            if (lockon_limit_.IsCreated)
            {
                lockon_limit_.Dispose();
            }
            // for (var i = 0; i < player_group_.Length; ++i) {
            int i = 0;          // only one player now.
            {
                var entity          = player_group_.entity_list_[i];
                var player          = player_group_.player_list_[i];
                var player_position = player_group_.position_list_[i];
                var player_rotation = player_group_.rotation_list_[i];

                // Debug.Log(player.life_.get());

                var pc = player_controller_list_from_entity_[entity];
                if (pc.lockon_ != 0)
                {
                    lockon_limit_ = new NativeLimitedCounter(Allocator.TempJob);

                    var sumup_job = new SumupJob {
                        time_            = Time.GetCurrent(),
                        locktarget_list_ = lockon_group_.locktarget_list_,
                        lockon_limit_    = lockon_limit_,
                    };
                    handle_ = sumup_job.Schedule(lockon_group_.Length, 8, handle_);

                    var lockon_job = new LockonJob {
                        time_ = Time.GetCurrent(),
                        locktarget_entity_list_         = lockon_group_.entity_list_,
                        locktarget_list_                = lockon_group_.locktarget_list_,
                        locktarget_local_to_world_list_ = lockon_group_.local_to_world_list_,
                        player_position_                = player_position,
                        player_normal_ = math.mul(player_rotation.Value, new float3(0f, 0f, 1f)),
                        lockon_limit_  = lockon_limit_,
                        sight_spawner_ = ECSSightManager.GetSightSpawnDataQueue().ToConcurrent(),
                    };
                    handle_ = lockon_job.Schedule(lockon_group_.Length, 8, handle_);
                }

                if (pc.fire_laser_ != 0)
                {
                    var fire_laser_job = new FireLaserJob {
                        time_            = Time.GetCurrent(),
                        command_buffer_  = barrier_.CreateCommandBuffer().ToConcurrent(),
                        entity_list_     = lockon_group_.entity_list_,
                        player_position_ = player_position,
                        player_rotation_ = player_rotation,
                        player_          = player,
                        locktarget_list_ = lockon_group_.locktarget_list_,
                        random_list_     = lockon_group_.random_list_,
                    };
                    handle_ = fire_laser_job.Schedule(lockon_group_.Length, 8, handle_);
                }

                if (pc.fire_bullet_ != 0)
                {
                    player.fire_bullet_time_  = Time.GetCurrent();
                    player.fire_bullet_count_ = 0;
                }
                const int RENSYA_NUM = 16;
                if (Time.GetCurrent() - player.fire_bullet_time_ >= 0f && player.fire_bullet_count_ < RENSYA_NUM)
                {
                    var fire_bullet_job = new FireBulletJob {
                        bullet_spawner_  = ECSBulletManager.GetBulletSpawnDataQueue().ToConcurrent(),
                        current_time_    = Time.GetCurrent(),
                        player_position_ = player_position,
                        player_rotation_ = player_rotation,
                    };
                    handle_ = fire_bullet_job.Schedule(handle_);
                    const float INTERVAL = 0.05f;
                    player.fire_bullet_time_ = Time.GetCurrent() + INTERVAL;
                    ++player.fire_bullet_count_;
                }
                player_group_.player_list_[i] = player;
            }

            var job = new PlayerJob {
                dt_                        = Time.GetDT(),
                position_list_             = player_group_.position_list_,
                rotation_list_             = player_group_.rotation_list_,
                rb_position_list_          = player_group_.rb_position_list_,
                player_list_               = player_group_.player_list_,
                player_controller_list_    = player_group_.player_controller_list_,
                position_list_from_entity_ = position_list_from_entity_,
            };

            handle_ = job.Schedule(player_group_.Length, 8, handle_);

            return(handle_);
        }