Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Radar::Track Class Reference

#include <track.h>

Classes

struct  Relation
 
struct  Type
 

Public Member Functions

const VectorGetPosition () const
 
float GetDistance () const
 
float GetSize () const
 
Type::Value GetType () const
 
bool IsExploding () const
 
float ExplodingProgress () const
 
bool HasWeapons () const
 
bool HasTurrets () const
 
bool HasActiveECM () const
 
bool HasLock () const
 
bool HasWeaponLock () const
 
Relation::Value GetRelation () const
 

Protected Member Functions

 Track (Unit *, Unit *)
 
 Track (Unit *, Unit *, const Vector &)
 
 Track (Unit *, Unit *, const Vector &, float)
 
Type::Value IdentifyType () const
 

Protected Attributes

Unitplayer
 
Unittarget
 
Vector position
 
float distance
 
Type::Value type
 

Friends

class Sensor
 

Detailed Description

Definition at line 18 of file track.h.

Constructor & Destructor Documentation

Radar::Track::Track ( Unit player,
Unit target 
)
protected

Definition at line 13 of file track.cpp.

References distance, UnitUtil::getDistance(), IdentifyType(), Unit::LocalCoordinates(), position, and type.

14  : player(player),
15  target(target),
16  distance(0.0)
17 {
18  position = player->LocalCoordinates(target);
19  distance = UnitUtil::getDistance(player, target);
20  type = IdentifyType();
21 }
Radar::Track::Track ( Unit player,
Unit target,
const Vector position 
)
protected

Definition at line 23 of file track.cpp.

References distance, UnitUtil::getDistance(), IdentifyType(), and type.

24  : player(player),
25  target(target),
27 {
28  distance = UnitUtil::getDistance(player, target);
29  type = IdentifyType();
30 }
Radar::Track::Track ( Unit player,
Unit target,
const Vector position,
float  distance 
)
protected

Definition at line 32 of file track.cpp.

References IdentifyType(), and type.

33  : player(player),
34  target(target),
37 {
38  type = IdentifyType();
39 }

Member Function Documentation

float Radar::Track::ExplodingProgress ( ) const

Definition at line 70 of file track.cpp.

References Unit::ExplodingProgress(), IsExploding(), and target.

Referenced by Radar::SphereDisplay::DrawTrack(), Radar::BubbleDisplay::DrawTrack(), and Radar::PlaneDisplay::DrawTrack().

71 {
72  assert(IsExploding());
73 
74  return target->ExplodingProgress();
75 }
float Radar::Track::GetDistance ( ) const

Definition at line 46 of file track.cpp.

References distance.

Referenced by Radar::Sensor::InRange().

47 {
48  return distance;
49 }
const Vector & Radar::Track::GetPosition ( ) const

Definition at line 41 of file track.cpp.

References position.

Referenced by Radar::SphereDisplay::DrawTrack(), Radar::BubbleDisplay::DrawTrack(), and Radar::PlaneDisplay::DrawTrack().

42 {
43  return position;
44 }
Track::Relation::Value Radar::Track::GetRelation ( ) const

Definition at line 172 of file track.cpp.

References Radar::Track::Relation::Enemy, Radar::Track::Relation::Friend, Unit::getRelation(), Radar::Track::Relation::Neutral, player, and target.

Referenced by Radar::Sensor::GetColor(), and Radar::Sensor::IdentifyThreat().

173 {
174  assert(player);
175  assert(target);
176 
177  const float relation = player->getRelation(target);
178  if (relation > 0)
179  return Relation::Friend;
180 
181  if (relation < 0)
182  return Relation::Enemy;
183 
184  return Relation::Neutral;
185 }
float Radar::Track::GetSize ( ) const

Definition at line 56 of file track.cpp.

References Unit::rSize(), and target.

Referenced by Radar::BubbleDisplay::DrawTrack(), and Radar::PlaneDisplay::DrawTrack().

57 {
58  assert(target);
59 
60  return target->rSize();
61 }
Track::Type::Value Radar::Track::GetType ( ) const
bool Radar::Track::HasActiveECM ( ) const

Definition at line 91 of file track.cpp.

References UnitUtil::getECM(), and target.

Referenced by Radar::SphereDisplay::DrawTrack(), Radar::BubbleDisplay::DrawTrack(), and Radar::PlaneDisplay::DrawTrack().

92 {
93  assert(target);
94 
95  return (UnitUtil::getECM(target) > 0);
96 }
bool Radar::Track::HasLock ( ) const

Definition at line 98 of file track.cpp.

References player, target, and Unit::Target().

Referenced by Radar::Sensor::GetColor(), and HasWeaponLock().

99 {
100  assert(player);
101  assert(target);
102 
103  return (player == target->Target());
104 }
bool Radar::Track::HasTurrets ( ) const

Definition at line 84 of file track.cpp.

References UnitCollection::empty(), Unit::SubUnits, and target.

Referenced by Radar::Sensor::IdentifyThreat().

85 {
86  assert(target);
87 
88  return !(target->SubUnits.empty());
89 }
bool Radar::Track::HasWeaponLock ( ) const

Definition at line 106 of file track.cpp.

References HasLock(), target, and Unit::TargetLocked().

Referenced by Radar::Sensor::IdentifyThreat().

107 {
108  assert(target);
109 
110  return (HasLock() && target->TargetLocked());
111 }
bool Radar::Track::HasWeapons ( ) const

Definition at line 77 of file track.cpp.

References Unit::GetNumMounts(), and target.

Referenced by Radar::Sensor::IdentifyThreat().

78 {
79  assert(target);
80 
81  return (target->GetNumMounts() > 0);
82 }
Track::Type::Value Radar::Track::IdentifyType ( ) const
protected

Definition at line 113 of file track.cpp.

References Radar::Track::Type::Asteroid, ASTEROIDPTR, Radar::Track::Type::Base, BUILDINGPTR, Radar::Track::Type::CapitalShip, Radar::Track::Type::Cargo, Radar::Track::Type::DeadPlanet, ENHANCEMENTPTR, Unit::faction, FactionUtil::GetUpgradeFaction(), Planet::hasLights(), Planet::isAtmospheric(), Unit::IsBase(), UnitUtil::isCapitalShip(), Unit::isJumppoint(), Unit::isUnit(), Radar::Track::Type::JumpPoint, Radar::Track::Type::Missile, MISSILEPTR, Radar::Track::Type::Nebula, NEBULAPTR, Radar::Track::Type::Planet, PLANETPTR, Radar::Track::Type::Ship, Radar::Track::Type::Star, target, UNITPTR, and Radar::Track::Type::Unknown.

Referenced by Track().

114 {
115  assert(target);
116 
117  switch (target->isUnit())
118  {
119  case NEBULAPTR:
120  return Type::Nebula;
121 
122  case PLANETPTR:
123  {
124  Planet *planet = static_cast<Planet *>(target);
125  if (planet->isJumppoint())
126  return Type::JumpPoint;
127 
128  if (planet->hasLights())
129  return Type::Star;
130 
131  if (planet->isAtmospheric())
132  return Type::Planet;
133 
134  return Type::DeadPlanet;
135  }
136  break;
137 
138  case ASTEROIDPTR:
139  return Type::Asteroid;
140 
141  case BUILDINGPTR:
142  // FIXME: Can this ever happen?
143  return Type::Unknown;
144 
145  case UNITPTR:
146  {
147  if (target->IsBase())
148  return Type::Base;
149 
151  return Type::CapitalShip;
152 
153  return Type::Ship;
154  }
155 
156  case ENHANCEMENTPTR:
157  return Type::Cargo;
158 
159  case MISSILEPTR:
160  // FIXME: Is this correct?
162  return Type::Cargo;
163 
164  return Type::Missile;
165 
166  default:
167  assert(false);
168  return Type::Unknown;
169  }
170 }
bool Radar::Track::IsExploding ( ) const

Friends And Related Function Documentation

friend class Sensor
friend

Definition at line 81 of file track.h.

Member Data Documentation

float Radar::Track::distance
protected

Definition at line 92 of file track.h.

Referenced by GetDistance(), and Track().

Unit* Radar::Track::player
protected

Definition at line 89 of file track.h.

Referenced by GetRelation(), and HasLock().

Vector Radar::Track::position
protected

Definition at line 91 of file track.h.

Referenced by GetPosition(), and Track().

Type::Value Radar::Track::type
protected

Definition at line 93 of file track.h.

Referenced by GetType(), and Track().


The documentation for this class was generated from the following files: