Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
MarkerBeacons.cpp
Go to the documentation of this file.
1
#include "
Module.h
"
2
#include "
../MathUtilities.h
"
3
4
void
MarkerBeacons::FrameMove
(
float
fElapsed)
5
{
6
if
(!
sound
)
7
return
;
8
9
Bus::MarkerBeaconTypes
nowPlaying =
Bus::MarkerBeaconTypes::None
;
10
float
volume = 0.0f, distance = 9999.0f;
11
12
if
(!
playerships
[0].groundvehicle &&
ourcockpit
.
power
> 0.5f &&
playerships
[0].
reference
==
REF_APNMODE
)
13
{
14
for
(UINT i = 1; i <
bus
->
waypoint
.size(); i++)
15
{
16
const
Swaypoint
waypoint =
bus
->
waypoint
.at(i);
17
18
if
(waypoint.
type
!= 1 && waypoint.
type
!= 2 && waypoint.
type
!= 4)
// FAF, threshold, or MM
19
continue
;
20
21
if
(waypoint.
ils
== -1)
22
continue
;
23
24
// @todo waypoint.distance should be calculated once ... and then reused
25
RiseMath::Vector3
result = waypoint.
location
-
playerships
[0].
position
;
26
distance =
RiseMath::Vec3Length
(&result);
27
28
// The valid signal area is a 2,400 ft (730 m) × 4,200 ft (1,280 m) ellipse (as measured 1,000 ft (300 m) above the antenna.)
29
// So what we do is a hemisphere that is 1.28km radius (1.28km AGL and 1.28km in all directions)
30
31
float
maxRange = 1.58f;
32
if
(
f_AGL
< 1.1172287142747450885533340921257f)
33
maxRange *=
f_AGL
/ 1.1172287142747450885533340921257f;
34
maxRange *= 2.0f;
35
36
if
(distance >= maxRange)
37
continue
;
38
39
volume =
Clamp
(1.0f - distance / maxRange, 0, 1);
40
if
(waypoint.
type
== 1)
41
nowPlaying =
Bus::MarkerBeaconTypes::Outer
;
42
else
if
(waypoint.
type
== 2)
43
nowPlaying =
Bus::MarkerBeaconTypes::Inner
;
44
else
if
(waypoint.
type
== 4)
45
nowPlaying =
Bus::MarkerBeaconTypes::Middle
;
46
47
break
;
48
}
49
}
50
51
if
(
oldPlaying
&&
oldPlaying
!= nowPlaying)
52
sound
->
Stop
(
static_cast<
SOUNDS
>
(
SOUND_OUTERMARKER
+
oldPlaying
- 1));
53
54
if
(nowPlaying)
55
sound
->
PlayEx
(
static_cast<
SOUNDS
>
(
SOUND_OUTERMARKER
+ nowPlaying - 1),
true
, volume, 1, 0,
false
);
56
57
bus
->
MarkerBeacon
= nowPlaying;
58
oldPlaying
=
bus
->
MarkerBeacon
;
59
}
60
61
MarkerBeacons::MarkerBeacons
(
Bus
* prmBus,
Logger
* prmLogger,
Sound
* prmSound) :
Module
(prmBus)
62
{
63
logger
= prmLogger;
64
sound
= prmSound;
65
}
MathUtilities.h
Clamp
constexpr auto Clamp(T1 val, T2 min, T3 max)
Definition
MathUtilities.h:4
Module.h
REF_APNMODE
@ REF_APNMODE
Definition
ServerTypes.h:42
SOUNDS
SOUNDS
Definition
Sound.h:23
SOUND_OUTERMARKER
@ SOUND_OUTERMARKER
Definition
Sound.h:176
Bus
Definition
Bus.h:20
Bus::MarkerBeaconTypes
MarkerBeaconTypes
(29) Marker beacon passage;
Definition
Bus.h:163
Bus::Inner
@ Inner
Definition
Bus.h:167
Bus::Outer
@ Outer
Definition
Bus.h:165
Bus::Middle
@ Middle
Definition
Bus.h:166
Bus::None
@ None
Definition
Bus.h:164
Bus::waypoint
std::vector< Swaypoint > waypoint
Definition
Bus.h:500
Bus::MarkerBeacon
enum Bus::MarkerBeaconTypes MarkerBeacon
Logger
Definition
Logger.h:11
MarkerBeacons::MarkerBeacons
MarkerBeacons(Bus *prmBus, Logger *prmLogger, Sound *prmSound)
Definition
MarkerBeacons.cpp:61
MarkerBeacons::logger
Logger * logger
Definition
Module.h:484
MarkerBeacons::sound
Sound * sound
Definition
Module.h:485
MarkerBeacons::oldPlaying
Bus::MarkerBeaconTypes oldPlaying
Definition
Module.h:487
MarkerBeacons::FrameMove
void FrameMove(float fElapsedTime) override
Definition
MarkerBeacons.cpp:4
Module::Module
Module()
Module::bus
Bus * bus
Definition
Module.h:21
Sound
Definition
Sound.h:369
Sound::Stop
void Stop(SOUNDS soundEnum) const
Definition
Sound.cpp:3397
Sound::PlayEx
void PlayEx(SOUNDS soundEnum, bool loop, float volume=1.0f, float frequencyMod=1.0f, float pan=0.0f, bool restart=true, bool fromOutside=false, bool partOfHull=false)
Definition
Sound.cpp:1006
f_AGL
float f_AGL
Definition
globals.cpp:9
playerships
s_network_objects playerships[MAX_SCAN]
Definition
globals.cpp:112
ourcockpit
Scockpit ourcockpit
Definition
globals.cpp:114
RiseMath::Vec3Length
float Vec3Length(const Vector3 *a)
Definition
ClientMath.h:95
RiseMath::Vector3
Definition
ClientMath.h:38
Scockpit::power
float power
Definition
globals.h:599
Swaypoint
Definition
ServerTypes.h:891
Swaypoint::type
unsigned char type
Definition
ServerTypes.h:894
Swaypoint::location
RiseMath::Vector3 location
Definition
ServerTypes.h:897
Swaypoint::ils
char ils
Definition
ServerTypes.h:895
s_network_objects::position
RiseMath::Vector3 position
Definition
globals.h:511
s_network_objects::reference
char reference
Definition
globals.h:508
Modules
MarkerBeacons.cpp
Generated on
for Rise by
1.18.0