Pioneer
Sensors.h
Go to the documentation of this file.
1 // Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _SENSORS_H
5 #define _SENSORS_H
6 /*
7  * Ship/station subsystem that holds a list of known contacts
8  * and handles IFF
9  * Some ideas:
10  * - targeting should be lost when going out of range
11  * - don't run radar sweep every frame (more of an optimization than simulation)
12  * - allow "pinned" radar contacts (visible at all ranges, for missions)
13  */
14 #include "Body.h"
15 #include "libs.h"
16 
17 class Body;
18 class HudTrail;
19 class Ship;
20 
21 class Sensors {
22 public:
23  enum IFF {
24  IFF_UNKNOWN, //also applies to inert objects
28  };
29 
32  };
33 
34  struct RadarContact {
35  RadarContact();
36  RadarContact(Body *);
37  ~RadarContact();
40  double distance;
42  bool fresh;
43  };
44 
45  typedef std::list<RadarContact> ContactList;
46 
47  static Color IFFColor(IFF);
48  static bool ContactDistanceSort(const RadarContact &a, const RadarContact &b);
49 
50  Sensors(Ship *owner);
52  IFF CheckIFF(Body *other);
53  const ContactList &GetContacts() { return m_radarContacts; }
54  const ContactList &GetStaticContacts() { return m_staticContacts; }
55  void Update(float time);
56  void UpdateIFF(Body *);
57  void ResetTrails();
58 
59 private:
60  Ship *m_owner;
61  ContactList m_radarContacts;
62  ContactList m_staticContacts; //things we know of regardless of range
63 
64  void PopulateStaticContacts();
65 };
66 
67 #endif
Definition: Body.h:54
Definition: HudTrail.h:23
Definition: Sensors.h:21
Sensors(Ship *owner)
Definition: Sensors.cpp:54
std::list< RadarContact > ContactList
Definition: Sensors.h:45
void UpdateIFF(Body *)
Definition: Sensors.cpp:149
IFF CheckIFF(Body *other)
Definition: Sensors.cpp:82
static bool ContactDistanceSort(const RadarContact &a, const RadarContact &b)
Definition: Sensors.cpp:49
bool ChooseTarget(TargetingCriteria)
Definition: Sensors.cpp:59
IFF
Definition: Sensors.h:23
@ IFF_NEUTRAL
Definition: Sensors.h:25
@ IFF_UNKNOWN
Definition: Sensors.h:24
@ IFF_HOSTILE
Definition: Sensors.h:27
@ IFF_ALLY
Definition: Sensors.h:26
TargetingCriteria
Definition: Sensors.h:30
@ TARGET_NEAREST_HOSTILE
Definition: Sensors.h:31
void ResetTrails()
Definition: Sensors.cpp:160
const ContactList & GetStaticContacts()
Definition: Sensors.h:54
const ContactList & GetContacts()
Definition: Sensors.h:53
void Update(float time)
Definition: Sensors.cpp:98
static Color IFFColor(IFF)
Definition: Sensors.cpp:37
Definition: Ship.h:64
Definition: Color.h:66
Definition: Sensors.h:34
double distance
Definition: Sensors.h:40
RadarContact()
Definition: Sensors.cpp:13
IFF iff
Definition: Sensors.h:41
~RadarContact()
Definition: Sensors.cpp:31
Body * body
Definition: Sensors.h:38
bool fresh
Definition: Sensors.h:42
HudTrail * trail
Definition: Sensors.h:39