protected override JobHandle OnUpdate(JobHandle inputDeps) { var translationType = GetArchetypeChunkComponentType <Translation>(); var playerType = GetArchetypeChunkComponentType <PlayerComponent>(); var job = new PlayerJob() { DeltaTime = Time.DeltaTime, TranslationType = translationType, PlayerComponentType = playerType, }; return(job.Schedule(entityQuery, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { 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(), }; 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(), 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 vel = math.mul(player_rotation.Value, new float3(0f, 0f, 48f)); var pos0 = math.mul(player_rotation.Value, new float3(0.3f, 0.1f, 0.8f)) + player_position.Value; ECSBulletManager.spawnBullet(barrier_.CreateCommandBuffer(), Time.GetCurrent(), ref pos0, ref vel); var pos1 = math.mul(player_rotation.Value, new float3(-0.3f, 0.1f, 0.8f)) + player_position.Value; ECSBulletManager.spawnBullet(barrier_.CreateCommandBuffer(), Time.GetCurrent(), ref pos1, ref vel); 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_); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var neighbors = new NeighborsDetectionJob { prodThresh = math.cos(math.radians(Bootstrap.Param.neighborFov)), distThresh = Bootstrap.Param.neighborDistance, neighborsFromEntity = GetBufferFromEntity <NeighborsEntityBuffer>(false), positionFromEntity = GetComponentDataFromEntity <Translation>(true), entities = group.ToEntityArray(Allocator.TempJob), }; var wall = new WallJob { scale = Bootstrap.Param.wallScale * 0.5f, thresh = Bootstrap.Param.wallDistance, weight = Bootstrap.Param.wallWeight, }; var separation = new SeparationJob { separationWeight = Bootstrap.Param.separationWeight, neighborsFromEntity = GetBufferFromEntity <NeighborsEntityBuffer>(true), positionFromEntity = GetComponentDataFromEntity <Translation>(true), }; var alignment = new AlignmentJob { alignmentWeight = Bootstrap.Param.alignmentWeight, neighborsFromEntity = GetBufferFromEntity <NeighborsEntityBuffer>(true), velocityFromEntity = GetComponentDataFromEntity <Velocity>(true), }; var cohesion = new CohesionJob { cohesionWeight = Bootstrap.Param.cohesionWeight, neighborsFromEntity = GetBufferFromEntity <NeighborsEntityBuffer>(true), positionFromEntity = GetComponentDataFromEntity <Translation>(true), }; var player = new PlayerJob() { separationWeight = Bootstrap.Param.separationWeight, playerEntities = playerGroup.ToComponentDataArray <Translation>(Allocator.TempJob), }; var move = new MoveJob { dt = Time.DeltaTime, minSpeed = Bootstrap.Param.minSpeed, maxSpeed = Bootstrap.Param.maxSpeed, }; inputDeps = neighbors.Schedule(this, inputDeps); inputDeps = wall.Schedule(this, inputDeps); inputDeps = separation.Schedule(this, inputDeps); inputDeps = alignment.Schedule(this, inputDeps); inputDeps = cohesion.Schedule(this, inputDeps); inputDeps = player.Schedule(this, inputDeps); //inputDeps = move.Schedule(this, inputDeps); return(inputDeps); }