22 #include <yaml-cpp/yaml.h> 24 #include "../Savegame/WeightedOptions.h" 35 double lonMin, lonMax, latMin, latMax;
41 return AreSame(lonMax, ma.lonMax) && AreSame(lonMin, ma.lonMin) && AreSame(latMax, ma.latMax) && AreSame(latMin, ma.latMin);
46 return AreSame(lonMin, lonMax) && AreSame(latMin, latMax);
55 std::vector<MissionArea> areas;
59 areas.swap(other.areas);
76 std::vector<double> _lonMin, _lonMax, _latMin, _latMax;
77 std::vector<City*> _cities;
83 std::vector<MissionZone> _missionZones;
85 std::string _missionRegion;
92 void load(
const YAML::Node& node);
114 const std::vector<double> &
getLonMax()
const {
return _lonMax; }
116 const std::vector<double> &
getLonMin()
const {
return _lonMin; }
118 const std::vector<double> &
getLatMax()
const {
return _latMax; }
120 const std::vector<double> &
getLatMin()
const {
return _latMin; }
135 node.push_back(Rad2Deg(rhs.lonMin));
136 node.push_back(Rad2Deg(rhs.lonMax));
137 node.push_back(Rad2Deg(rhs.latMin));
138 node.push_back(Rad2Deg(rhs.latMax));
144 if (!node.IsSequence() || node.size() < 4)
147 rhs.lonMin = Deg2Rad(node[0].as<double>());
148 rhs.lonMax = Deg2Rad(node[1].as<double>());
149 rhs.latMin = Deg2Rad(node[2].as<double>());
150 rhs.latMax = Deg2Rad(node[3].as<double>());
151 if (rhs.latMin > rhs.latMax)
152 std::swap(rhs.latMin, rhs.latMax);
153 if (node.size() >= 5) rhs.texture = node[4].as<
int>();
154 if (node.size() >= 6) rhs.name = node[5].as<std::string>();
171 if (!node.IsSequence())
174 rhs.areas = node.as< std::vector<OpenXcom::MissionArea> >(rhs.areas);
const std::vector< double > & getLatMin() const
Gets the minimum latitude.
Definition: RuleRegion.h:120
std::vector< City * > * getCities()
Gets the cities in this region.
Definition: RuleRegion.cpp:124
int getBaseCost() const
Gets the region's base cost.
Definition: RuleRegion.cpp:90
RuleRegion(const std::string &type)
Creates a blank region ruleset.
Definition: RuleRegion.cpp:31
const std::vector< double > & getLonMin() const
Gets the minimum longitude.
Definition: RuleRegion.h:116
MissionArea getRandomMissionPoint(size_t zone) const
Gets a random mission area.
Definition: RuleRegion.cpp:221
Defines a rectangle in polar coordinates.
Definition: RuleRegion.h:33
A zone (set of areas) on the globe.
Definition: RuleRegion.h:53
const std::vector< double > & getLatMax() const
Gets the maximum latitude.
Definition: RuleRegion.h:118
const std::vector< double > & getLonMax() const
Gets the maximum longitude.
Definition: RuleRegion.h:114
size_t getWeight() const
Gets the weight of this region for mission selection.
Definition: RuleRegion.cpp:149
const std::vector< MissionZone > & getMissionZones() const
Gets a list of MissionZones.
Definition: RuleRegion.cpp:158
Definition: Position.h:81
Represents a city of the world.
Definition: City.h:32
const WeightedOptions & getAvailableMissions() const
Gets the weighted list of missions for this region.
Definition: RuleRegion.h:104
bool insideRegion(double lon, double lat) const
Checks if a point is inside the region.
Definition: RuleRegion.cpp:101
const std::string & getMissionRegion() const
Gets the substitute mission region.
Definition: RuleRegion.h:106
std::pair< double, double > getRandomPoint(size_t zone) const
Gets a random point inside a mission zone.
Definition: RuleRegion.cpp:168
Holds pairs of relative weights and IDs.
Definition: WeightedOptions.h:33
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
void load(const YAML::Node &node)
Loads the region from YAML.
Definition: RuleRegion.cpp:50
Represents a specific region of the world.
Definition: RuleRegion.h:71
MissionArea getMissionPoint(size_t zone, Target *target) const
Gets the mission area for the corresponding target.
Definition: RuleRegion.cpp:201
std::string getType() const
Gets the region's type.
Definition: RuleRegion.cpp:81
~RuleRegion()
Cleans up the region ruleset.
Definition: RuleRegion.cpp:38
Definition: BaseInfoState.cpp:40