MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / UpdateAf

Method UpdateAf

ogsr_engine/xrGame/SimpleDetector.cpp:17–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16CUIArtefactDetectorSimple& CSimpleDetector::ui() { return *((CUIArtefactDetectorSimple*)m_ui); }
17void CSimpleDetector::UpdateAf()
18{
19 if (m_artefacts.m_ItemInfos.empty())
20 return;
21
22 auto it_b = m_artefacts.m_ItemInfos.begin();
23 auto it_e = m_artefacts.m_ItemInfos.end();
24 auto it = it_b;
25 float min_dist = flt_max;
26
27 Fvector detector_pos = Position();
28
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 if (pAf->CanBeInvisible())
42 {
43 if (d < m_fAfVisRadius)
44 pAf->SwitchVisibility(true);
45 }
46 }
47
48 ITEM_INFO& af_info = it->second;
49
50 ITEM_TYPE* item_type = af_info.curr_ref;
51
52 float dist = min_dist;
53
54 float fRelPow = (dist / m_fAfDetectRadius);
55 clamp(fRelPow, 0.f, 1.f);
56
57 //определить текущую частоту срабатывания сигнала
58 af_info.cur_period = item_type->freq.x + (item_type->freq.y - item_type->freq.x) * (fRelPow * fRelPow);
59
60 float min_snd_freq = 0.9f;
61 float max_snd_freq = 1.4f;
62
63 float snd_freq = min_snd_freq + (max_snd_freq - min_snd_freq) * (1.0f - fRelPow);
64
65 if (af_info.snd_time > af_info.cur_period)
66 {
67 af_info.snd_time = 0;
68 HUD_SOUND::PlaySound(item_type->detect_snds, Fvector{}, this, true, false);
69 ui().Flash(true, fRelPow);
70 if (item_type->detect_snds.m_activeSnd)
71 item_type->detect_snds.m_activeSnd->snd.set_frequency(snd_freq);
72 }
73 else
74 af_info.snd_time += Device.fTimeDelta;

Callers

nothing calls this directly

Calls 10

clampFunction · 0.85
PositionMethod · 0.80
CanBeInvisibleMethod · 0.80
SwitchVisibilityMethod · 0.80
FlashMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
distance_toMethod · 0.45
set_frequencyMethod · 0.45

Tested by

no test coverage detected