Pioneer
ShipType.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _SHIPTYPE_H
5 #define _SHIPTYPE_H
6 
7 #include "ship/Propulsion.h"
8 #include <map>
9 #include <string>
10 #include <vector>
11 
12 struct ShipType {
13  enum DualLaserOrientation { // <enum scope='ShipType' name='DualLaserOrientation' prefix='DUAL_LASERS_' public>
16  };
17  enum Tag { // <enum scope='ShipType' name=ShipTypeTag prefix=TAG_ public>
22  TAG_MAX // <enum skip>
23  };
24  typedef std::string Id;
25 
26  ShipType(){};
27  ShipType(const Id &id, const std::string &path);
28 
31  Id id;
32  std::string name;
33  std::string shipClass;
34  std::string manufacturer;
35  std::string modelName;
36  std::string cockpitName;
38  float angThrust;
40  std::map<std::string, int> slots;
41  std::map<std::string, bool> roles;
42  Color globalThrusterColor; // Override default color for thrusters
43  bool isGlobalColorDefined; // If globalThrusterColor is filled with... a color :)
46  double thrusterUpgrades[4];
48  int capacity; // tonnes
49  int hullMass;
50  float effectiveExhaustVelocity; // velocity at which the propellant escapes the engines
51  int fuelTankMass; //full fuel tank mass, on top of hullMass
52 
53  //values for atmospheric flight
57  double topDragCoeff;
58  double sideDragCoeff;
60 
62  double atmoStability;
63 
64  // storing money as a double is weird, but the value is a double on the Lua side anyway,
65  // so we don't lose anything by storing it as a double here too
66  double baseprice;
67 
69  int minCrew, maxCrew; // XXX really only for Lua, but needs to be declared in the ship def
71 
72  // percentage (ie, 0--100) of tank used per second at full thrust
73  float GetFuelUseRate() const;
74 
75  static const std::string POLICE;
76  static const std::string MISSILE_GUIDED;
77  static const std::string MISSILE_NAVAL;
78  static const std::string MISSILE_SMART;
79  static const std::string MISSILE_UNGUIDED;
80 
81  static std::map<Id, const ShipType> types;
82  static std::vector<Id> player_ships;
83  static std::vector<Id> static_ships;
84  static std::vector<Id> missile_ships;
85 
86  static void Init();
87  static const ShipType *Get(const char *name)
88  {
89  std::map<Id, const ShipType>::iterator t = types.find(name);
90  if (t == types.end())
91  return 0;
92  else
93  return &(*t).second;
94  }
95 };
96 
97 #endif /* _SHIPTYPE_H */
@ THRUSTER_MAX
Definition: Propulsion.h:22
Definition: Color.h:66
Definition: ShipType.h:12
Color directionThrusterColor[THRUSTER_MAX]
Definition: ShipType.h:44
static const std::string MISSILE_UNGUIDED
Definition: ShipType.h:79
int capacity
Definition: ShipType.h:48
double atmoStability
Definition: ShipType.h:62
double atmosphericPressureLimit
Definition: ShipType.h:47
Tag tag
Definition: ShipType.h:30
float linThrust[THRUSTER_MAX]
Definition: ShipType.h:37
double topCrossSection
Definition: ShipType.h:54
std::string modelName
Definition: ShipType.h:35
std::map< std::string, int > slots
Definition: ShipType.h:40
double shipLiftCoefficient
Definition: ShipType.h:61
double thrusterUpgrades[4]
Definition: ShipType.h:46
double frontCrossSection
Definition: ShipType.h:56
int hullMass
Definition: ShipType.h:49
float linAccelerationCap[THRUSTER_MAX]
Definition: ShipType.h:39
static std::vector< Id > static_ships
Definition: ShipType.h:83
static const std::string POLICE
Definition: ShipType.h:75
int minCrew
Definition: ShipType.h:69
int maxCrew
Definition: ShipType.h:69
static const std::string MISSILE_GUIDED
Definition: ShipType.h:76
static const ShipType * Get(const char *name)
Definition: ShipType.h:87
bool isDirectionColorDefined[THRUSTER_MAX]
Definition: ShipType.h:45
DualLaserOrientation
Definition: ShipType.h:13
@ DUAL_LASERS_HORIZONTAL
Definition: ShipType.h:14
@ DUAL_LASERS_VERTICAL
Definition: ShipType.h:15
static std::map< Id, const ShipType > types
Definition: ShipType.h:81
std::string cockpitName
Definition: ShipType.h:36
float angThrust
Definition: ShipType.h:38
int hyperdriveClass
Definition: ShipType.h:68
double sideCrossSection
Definition: ShipType.h:55
Color globalThrusterColor
Definition: ShipType.h:42
float GetFuelUseRate() const
Definition: ShipType.cpp:33
int fuelTankMass
Definition: ShipType.h:51
std::string manufacturer
Definition: ShipType.h:34
double frontDragCoeff
Definition: ShipType.h:59
static const std::string MISSILE_SMART
Definition: ShipType.h:78
Tag
Definition: ShipType.h:17
@ TAG_SHIP
Definition: ShipType.h:19
@ TAG_MISSILE
Definition: ShipType.h:21
@ TAG_STATIC_SHIP
Definition: ShipType.h:20
@ TAG_NONE
Definition: ShipType.h:18
@ TAG_MAX
Definition: ShipType.h:22
float effectiveExhaustVelocity
Definition: ShipType.h:50
Id id
Definition: ShipType.h:31
static std::vector< Id > missile_ships
Definition: ShipType.h:84
std::string shipClass
Definition: ShipType.h:33
double sideDragCoeff
Definition: ShipType.h:58
ShipType()
Definition: ShipType.h:26
std::string Id
Definition: ShipType.h:24
bool isGlobalColorDefined
Definition: ShipType.h:43
static const std::string MISSILE_NAVAL
Definition: ShipType.h:77
std::string name
Definition: ShipType.h:32
static std::vector< Id > player_ships
Definition: ShipType.h:82
double baseprice
Definition: ShipType.h:66
static void Init()
Definition: ShipType.cpp:408
double topDragCoeff
Definition: ShipType.h:57
std::map< std::string, bool > roles
Definition: ShipType.h:41