-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlightSimulator.h
More file actions
62 lines (53 loc) · 1.8 KB
/
FlightSimulator.h
File metadata and controls
62 lines (53 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <cstdint>
#include <string>
#include <map>
enum class ENamedVariable : int
{
FlapPosition,
Altitude,
EngineRPM,
NoNamedVariable
};
struct NamedVariableQuery
{
NamedVariableQuery(uint32_t var) : Variable(var) {}
NamedVariableQuery(ENamedVariable var) : Variable((uint32_t)var) {}
NamedVariableQuery(uint32_t var, int index) : Variable(var), Index(index) {}
NamedVariableQuery(ENamedVariable var, int index) : Variable((uint32_t)var), Index(index) {}
NamedVariableQuery() : Variable((uint32_t)ENamedVariable::NoNamedVariable) {}
// the INTEGER representation of the ENamedVariable enumeration
uint32_t Variable;
// the index in case the variable represents an array (-1 means no array)
int Index = -1;
bool operator<(const NamedVariableQuery& r) const {
if (Variable < r.Variable) return true;
if (Variable > r.Variable) return false;
if (Index < r.Index) return true;
if (Index > r.Index) return false;
return false;
}
bool operator==(const NamedVariableQuery& r) const {
if (Variable != r.Variable) return false;
if (Index != r.Index) return false;
return true;
}
};
class CFlightSimulator
{
public:
void Update();
float GetFlapPosition();
float GetAltitude();
float GetEngineRPM(int enginenr);
NamedVariableQuery ParseNamedVariable(std::string identifier);
float GetNamedVariableValue(NamedVariableQuery variable);
float* GetAddressOfNamedVariableFloat(std::string identifier);
private:
uint64_t mTicksOnLastUpdate = 0;
float mAltitude = 0;
float mFlapPosition = 0;
float mEngineRPM[4] = {0,0,0,0};
void UpdateNamedVariableFloats();
std::map<NamedVariableQuery, float> mNamedVariableSources;
};