| 15 | |
| 16 | CUIArtefactDetectorAdv& CAdvancedDetector::ui() { return *((CUIArtefactDetectorAdv*)m_ui); } |
| 17 | void CAdvancedDetector::UpdateAf() |
| 18 | { |
| 19 | ui().SetValue(0.0f, Fvector{}); |
| 20 | if (m_artefacts.m_ItemInfos.empty()) |
| 21 | return; |
| 22 | |
| 23 | auto it_b = m_artefacts.m_ItemInfos.begin(); |
| 24 | auto it_e = m_artefacts.m_ItemInfos.end(); |
| 25 | auto it = it_b; |
| 26 | float min_dist = flt_max; |
| 27 | |
| 28 | Fvector detector_pos = Position(); |
| 29 | for (; it_b != it_e; ++it_b) // only nearest |
| 30 | { |
| 31 | CArtefact* pAf = it_b->first; |
| 32 | if (pAf->H_Parent()) |
| 33 | continue; |
| 34 | |
| 35 | float d = detector_pos.distance_to(pAf->Position()); |
| 36 | if (d < min_dist) |
| 37 | { |
| 38 | min_dist = d; |
| 39 | it = it_b; |
| 40 | } |
| 41 | |
| 42 | if (pAf->CanBeInvisible()) |
| 43 | { |
| 44 | if (d < m_fAfVisRadius) |
| 45 | pAf->SwitchVisibility(true); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | ITEM_INFO& af_info = it->second; |
| 50 | ITEM_TYPE* item_type = af_info.curr_ref; |
| 51 | CArtefact* pCurrentAf = it->first; |
| 52 | |
| 53 | float dist = min_dist; |
| 54 | float fRelPow = (dist / m_fAfDetectRadius); |
| 55 | clamp(fRelPow, 0.f, 1.f); |
| 56 | |
| 57 | // direction |
| 58 | Fvector dir_to_artefact; |
| 59 | dir_to_artefact.sub(pCurrentAf->Position(), Device.vCameraPosition); |
| 60 | dir_to_artefact.normalize(); |
| 61 | float _ang_af = dir_to_artefact.getH(); |
| 62 | float _ang_cam = Device.vCameraDirection.getH(); |
| 63 | |
| 64 | float _diff = angle_difference_signed(_ang_af, _ang_cam); |
| 65 | |
| 66 | // sounds |
| 67 | af_info.cur_period = item_type->freq.x + (item_type->freq.y - item_type->freq.x) * (fRelPow * fRelPow); |
| 68 | |
| 69 | float min_snd_freq = 0.9f; |
| 70 | float max_snd_freq = 1.4f; |
| 71 | |
| 72 | float snd_freq = min_snd_freq + (max_snd_freq - min_snd_freq) * (1.0f - fRelPow); |
| 73 | |
| 74 | if (af_info.snd_time > af_info.cur_period) |
nothing calls this directly
no test coverage detected