1 #ifndef _FleetPlan_h_
2 #define _FleetPlan_h_
3 
4 
5 #include <memory>
6 #include <string>
7 #include <vector>
8 #include "../universe/Condition.h"
9 #include "../util/Export.h"
10 
11 
12 //! Prepopulated Fleet, consisting of a name and list of ShipDesign names.
13 //!
14 //! FleetPlan%s are used for providing Fleets during universe generation or
15 //! during game events.
16 //!
17 //! Fleet plans are loaded from the `default/scripting/starting_unlocks/fleets.inf`
18 //! file, the ShipDesign referenced are liste in `default/scripting/ship_designs`.
19 class FO_COMMON_API FleetPlan {
20 public:
21     FleetPlan(const std::string& fleet_name, const std::vector<std::string>& ship_design_names,
22               bool lookup_name_userstring = false) :
m_name(fleet_name)23         m_name(fleet_name),
24         m_ship_designs(ship_design_names),
25         m_name_in_stringtable(lookup_name_userstring)
26     {}
27 
FleetPlan()28     FleetPlan() :
29         m_name(""),
30         m_ship_designs(),
31         m_name_in_stringtable(false)
32     {}
33 
34     auto Name() const -> const std::string&;
35 
36     auto ShipDesigns() const -> const std::vector<std::string>&
37     { return m_ship_designs; }
38 
39 protected:
40     std::string              m_name;
41     std::vector<std::string> m_ship_designs;
42     bool                     m_name_in_stringtable;
43 };
44 
45 
46 //! Spawning instruction for Monster Fleets during universe generation.
47 class FO_COMMON_API MonsterFleetPlan : public FleetPlan {
48 public:
49     MonsterFleetPlan(const std::string& fleet_name, const std::vector<std::string>& ship_design_names,
50                      double spawn_rate = 1.0, int spawn_limit = 9999,
51                      std::unique_ptr<Condition::Condition>&& location = nullptr,
52                      bool lookup_name_userstring = false) :
FleetPlan(fleet_name,ship_design_names,lookup_name_userstring)53         FleetPlan(fleet_name, ship_design_names, lookup_name_userstring),
54         m_spawn_rate(spawn_rate),
55         m_spawn_limit(spawn_limit),
56         m_location(std::move(location))
57     {}
58 
MonsterFleetPlan()59     MonsterFleetPlan() :
60         FleetPlan()
61     {}
62 
63     auto SpawnRate() const -> auto
64     { return m_spawn_rate; }
65 
66     auto SpawnLimit() const -> int
67     { return m_spawn_limit; }
68 
69     auto Location() const -> const Condition::Condition*
70     { return m_location.get(); }
71 
72 protected:
73     double                                      m_spawn_rate = 1.0;
74     int                                         m_spawn_limit = 9999;
75     // Use shared_ptr insead of unique_ptr because boost::python requires a deleter
76     const std::shared_ptr<Condition::Condition> m_location;
77 };
78 
79 
80 #endif // __FleetPlan_h_
81