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 _CUSTOMSYSTEM_H 5 #define _CUSTOMSYSTEM_H 6 7 #include "Color.h" 8 #include "Polit.h" 9 #include "galaxy/SystemBody.h" 10 11 #include "fixed.h" 12 #include "vector3.h" 13 14 class Faction; 15 class Galaxy; 16 17 class CustomSystemBody { 18 public: 19 CustomSystemBody(); 20 ~CustomSystemBody(); 21 22 std::string name; 23 SystemBody::BodyType type; 24 fixed radius; // in earth radii for planets, sol radii for stars (equatorial radius) 25 fixed aspectRatio; // the ratio between equatorial radius and polar radius for bodies flattened due to equatorial bulge (1.0 to infinity) 26 fixed mass; // earth masses or sol masses 27 int averageTemp; // kelvin 28 fixed semiMajorAxis; // in AUs 29 fixed eccentricity; 30 fixed orbitalOffset; 31 fixed orbitalPhaseAtStart; // mean anomaly at start 0 to 2 pi 32 bool want_rand_offset; 33 // for orbiting things, latitude = inclination 34 float latitude, longitude; // radians 35 fixed rotationPeriod; // in days 36 fixed rotationalPhaseAtStart; // 0 to 2 pi 37 fixed axialTilt; // in radians 38 std::string heightMapFilename; 39 int heightMapFractal; 40 std::vector<CustomSystemBody *> children; 41 42 /* composition */ 43 fixed metallicity; // (crust) 0.0 = light (Al, SiO2, etc), 1.0 = heavy (Fe, heavy metals) 44 fixed volatileGas; // 1.0 = earth atmosphere density 45 fixed volatileLiquid; // 1.0 = 100% ocean cover (earth = 70%) 46 fixed volatileIces; // 1.0 = 100% ice cover (earth = 3%) 47 fixed volcanicity; // 0 = none, 1.0 = fucking volcanic 48 fixed atmosOxidizing; // 0.0 = reducing (H2, NH3, etc), 1.0 = oxidising (CO2, O2, etc) 49 fixed life; // 0.0 = dead, 1.0 = teeming 50 51 /* rings */ 52 enum RingStatus { 53 WANT_RANDOM_RINGS, 54 WANT_RINGS, 55 WANT_NO_RINGS, 56 WANT_CUSTOM_RINGS 57 }; 58 RingStatus ringStatus; 59 fixed ringInnerRadius; 60 fixed ringOuterRadius; 61 Color ringColor; 62 63 Uint32 seed; 64 bool want_rand_seed; 65 std::string spaceStationType; 66 67 void SanityChecks(); 68 69 }; 70 71 class CustomSystem { 72 public: 73 static const int CUSTOM_ONLY_RADIUS = 4; 74 CustomSystem(); 75 ~CustomSystem(); 76 77 std::string name; 78 std::vector<std::string> other_names; 79 CustomSystemBody *sBody; 80 SystemBody::BodyType primaryType[4]; 81 unsigned numStars; 82 int sectorX, sectorY, sectorZ; 83 vector3f pos; 84 Uint32 seed; 85 bool want_rand_explored; 86 bool explored; 87 const Faction *faction; 88 Polit::GovType govType; 89 bool want_rand_lawlessness; 90 fixed lawlessness; // 0.0 = lawful, 1.0 = totally lawless 91 std::string shortDesc; 92 std::string longDesc; 93 94 void SanityChecks(); 95 IsRandom()96 bool IsRandom() const { return !sBody; } 97 }; 98 99 class CustomSystemsDatabase { 100 public: CustomSystemsDatabase(Galaxy * galaxy,const std::string & customSysDir)101 CustomSystemsDatabase(Galaxy *galaxy, const std::string &customSysDir) : 102 m_galaxy(galaxy), 103 m_customSysDirectory(customSysDir) {} 104 ~CustomSystemsDatabase(); 105 106 void Load(); 107 108 typedef std::vector<const CustomSystem *> SystemList; 109 // XXX this is not as const-safe as it should be 110 const SystemList &GetCustomSystemsForSector(int sectorX, int sectorY, int sectorZ) const; 111 void AddCustomSystem(const SystemPath &path, CustomSystem *csys); GetGalaxy()112 Galaxy *GetGalaxy() const { return m_galaxy; } 113 114 private: 115 typedef std::map<SystemPath, SystemList> SectorMap; 116 117 Galaxy *const m_galaxy; 118 const std::string m_customSysDirectory; 119 SectorMap m_sectorMap; 120 static const SystemList s_emptySystemList; // see: Null Object pattern 121 }; 122 123 #endif /* _CUSTOMSYSTEM_H */ 124