Pioneer
Sensors.h
Go to the documentation of this file.
1// Copyright © 2008-2022 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
17class Body;
18class HudTrail;
19class Ship;
20
21class Sensors {
22public:
23 enum IFF {
24 IFF_UNKNOWN, //also applies to inert objects
28 };
29
32 };
33
34 struct 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
59private:
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:22
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
const ContactList & GetStaticContacts()
Definition: Sensors.h:54
const ContactList & GetContacts()
Definition: Sensors.h:53
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
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