2019-12-31 05:05:16 -08:00
|
|
|
// Copyright © 2008-2020 Pioneer Developers. See AUTHORS.txt for details
|
2014-01-18 03:50:57 -08:00
|
|
|
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
|
|
|
|
2013-11-05 13:57:55 -08:00
|
|
|
#ifndef _SENSORS_H
|
|
|
|
#define _SENSORS_H
|
|
|
|
/*
|
|
|
|
* Ship/station subsystem that holds a list of known contacts
|
|
|
|
* and handles IFF
|
|
|
|
* Some ideas:
|
|
|
|
* - targeting should be lost when going out of range
|
|
|
|
* - don't run radar sweep every frame (more of an optimization than simulation)
|
|
|
|
* - allow "pinned" radar contacts (visible at all ranges, for missions)
|
|
|
|
*/
|
|
|
|
#include "Body.h"
|
2019-01-02 08:59:07 -08:00
|
|
|
#include "libs.h"
|
2013-11-05 13:57:55 -08:00
|
|
|
|
|
|
|
class Body;
|
|
|
|
class HudTrail;
|
|
|
|
class Ship;
|
|
|
|
|
|
|
|
class Sensors {
|
|
|
|
public:
|
|
|
|
enum IFF {
|
|
|
|
IFF_UNKNOWN, //also applies to inert objects
|
|
|
|
IFF_NEUTRAL,
|
|
|
|
IFF_ALLY,
|
|
|
|
IFF_HOSTILE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum TargetingCriteria {
|
|
|
|
TARGET_NEAREST_HOSTILE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RadarContact {
|
|
|
|
RadarContact();
|
|
|
|
RadarContact(Body *);
|
|
|
|
~RadarContact();
|
|
|
|
Body *body;
|
2019-01-02 08:59:07 -08:00
|
|
|
HudTrail *trail;
|
2013-11-05 13:57:55 -08:00
|
|
|
double distance;
|
|
|
|
IFF iff;
|
|
|
|
bool fresh;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::list<RadarContact> ContactList;
|
|
|
|
|
|
|
|
static Color IFFColor(IFF);
|
|
|
|
static bool ContactDistanceSort(const RadarContact &a, const RadarContact &b);
|
|
|
|
|
|
|
|
Sensors(Ship *owner);
|
|
|
|
bool ChooseTarget(TargetingCriteria);
|
|
|
|
IFF CheckIFF(Body *other);
|
|
|
|
const ContactList &GetContacts() { return m_radarContacts; }
|
|
|
|
const ContactList &GetStaticContacts() { return m_staticContacts; }
|
|
|
|
void Update(float time);
|
2019-01-02 08:59:07 -08:00
|
|
|
void UpdateIFF(Body *);
|
2013-11-07 13:01:41 -08:00
|
|
|
void ResetTrails();
|
2013-11-05 13:57:55 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ship *m_owner;
|
|
|
|
ContactList m_radarContacts;
|
|
|
|
ContactList m_staticContacts; //things we know of regardless of range
|
|
|
|
|
|
|
|
void PopulateStaticContacts();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|