Pioneer
SectorGenerator.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 SECTORGENERATOR_H
5 #define SECTORGENERATOR_H
6 
7 #include "GalaxyGenerator.h"
8 #include "Random.h"
9 #include "RefCounted.h"
10 #include "Sector.h"
11 #include "StarSystem.h"
12 
14 public:
15  SectorCustomSystemsGenerator(int customOnlyRadius) :
16  m_customOnlyRadius(customOnlyRadius) {}
17  virtual bool Apply(Random &rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig *config);
18 
19 private:
20  int m_customOnlyRadius;
21 };
22 
24 public:
25  virtual bool Apply(Random &rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig *config);
26 
27 private:
28  const std::string GenName(RefCountedPtr<Galaxy> galaxy, const Sector &sec, Sector::System &sys, int si, Random &rand);
29 };
30 
32 public:
34  m_version(version) {}
35  virtual bool Apply(Random &rng, RefCountedPtr<Galaxy> galaxy, RefCountedPtr<Sector> sector, GalaxyGenerator::SectorConfig *config);
36  virtual void FromJson(const Json &jsonObj, RefCountedPtr<Galaxy> galaxy);
37  virtual void ToJson(Json &jsonObj, RefCountedPtr<Galaxy> galaxy);
38 
39 private:
40  void SetExplored(Sector::System *sys, StarSystem::ExplorationState e, double time);
41 
42  const GalaxyGenerator::Version m_version;
43 
44  // m_exploredSystems stores the date (in-game) when each system was explored.
45  // = 0 -> System was already explored at the start of the game.
46  // > 0 -> System explored at the specified date.
47  // < 0 -> System is unexplored.
48  // Systems that don't appear in the map are also unexplored.
49  //
50  // The date value is day/month/year, bit-packed into a 32-bit integer.
51  // Low 5 bits (bits 0..4) -> Day.
52  // Middle 4 bits (bits 5..8) -> Month.
53  // High bits (bits 9..) -> Year.
54  std::map<SystemPath, Sint32> m_exploredSystems;
55 };
56 
57 #endif
nlohmann::json Json
Definition: Json.h:8
int Version
Definition: GalaxyGenerator.h:19
Definition: Random.h:27
Definition: SectorGenerator.h:13
SectorCustomSystemsGenerator(int customOnlyRadius)
Definition: SectorGenerator.h:15
virtual bool Apply(Random &rng, RefCountedPtr< Galaxy > galaxy, RefCountedPtr< Sector > sector, GalaxyGenerator::SectorConfig *config)
Definition: SectorGenerator.cpp:175
Definition: GalaxyGenerator.h:115
Definition: SectorGenerator.h:31
SectorPersistenceGenerator(GalaxyGenerator::Version version)
Definition: SectorGenerator.h:33
virtual void ToJson(Json &jsonObj, RefCountedPtr< Galaxy > galaxy)
Definition: SectorGenerator.cpp:559
virtual void FromJson(const Json &jsonObj, RefCountedPtr< Galaxy > galaxy)
Definition: SectorGenerator.cpp:537
virtual bool Apply(Random &rng, RefCountedPtr< Galaxy > galaxy, RefCountedPtr< Sector > sector, GalaxyGenerator::SectorConfig *config)
Definition: SectorGenerator.cpp:512
Definition: SectorGenerator.h:23
virtual bool Apply(Random &rng, RefCountedPtr< Galaxy > galaxy, RefCountedPtr< Sector > sector, GalaxyGenerator::SectorConfig *config)
Definition: SectorGenerator.cpp:293
Definition: Sector.h:38
Definition: Sector.h:19
ExplorationState
Definition: StarSystem.h:33
Definition: GalaxyGenerator.h:53