19 #ifndef OPENXCOM_RULEREGION_H
20 #define OPENXCOM_RULEREGION_H
24 #include <yaml-cpp/yaml.h>
26 #include "../Savegame/WeightedOptions.h"
37 double lonMin, lonMax, latMin, latMax;
41 return AreSame(lonMax, ma.lonMax) && AreSame(lonMin, ma.lonMin) && AreSame(latMax, ma.latMax) && AreSame(latMin, ma.latMin);
50 std::vector<MissionArea> areas;
54 areas.swap(other.areas);
70 std::vector<double> _lonMin, _lonMax, _latMin, _latMax;
71 std::vector<City*> _cities;
77 std::vector<MissionZone> _missionZones;
79 std::string _missionRegion;
81 static const int CITY_MISSION_ZONE = 3;
82 static const int ALIEN_BASE_ZONE = 4;
88 void load(
const YAML::Node& node);
106 const std::vector<double> &
getLonMax()
const {
return _lonMax; }
108 const std::vector<double> &
getLonMin()
const {
return _lonMin; }
110 const std::vector<double> &
getLatMax()
const {
return _latMax; }
112 const std::vector<double> &
getLatMin()
const {
return _latMin; }
113 const std::vector<MissionZone> &getMissionZones()
const;
121 struct convert<OpenXcom::MissionArea>
126 node.push_back(rhs.lonMin);
127 node.push_back(rhs.lonMax);
128 node.push_back(rhs.latMin);
129 node.push_back(rhs.latMax);
135 if (!node.IsSequence() || node.size() != 4)
138 rhs.lonMin = node[0].as<
double>();
139 rhs.lonMax = node[1].as<
double>();
140 rhs.latMin = node[2].as<
double>();
141 rhs.latMax = node[3].as<
double>();
147 struct convert<OpenXcom::MissionZone>
158 if (!node.IsSequence())
161 rhs.areas = node.as< std::vector<OpenXcom::MissionArea> >(rhs.areas);
std::vector< City * > * getCities()
Gets the cities in this region.
Definition: RuleRegion.cpp:168
RuleRegion(const std::string &type)
Creates a blank region ruleset.
Definition: RuleRegion.cpp:34
const WeightedOptions & getAvailableMissions() const
Gets the weighted list of missions for this region.
Definition: RuleRegion.h:100
Defines a rectangle in polar coordinates.
Definition: RuleRegion.h:35
const std::vector< double > & getLonMin() const
Gets the minimum longitude.
Definition: RuleRegion.h:108
const std::string & getMissionRegion() const
Gets the substitute mission region.
Definition: RuleRegion.h:102
bool insideRegion(double lon, double lat) const
Checks if a point is inside the region.
Definition: RuleRegion.cpp:145
A zone (set of areas) on the globe.
Definition: RuleRegion.h:48
int getBaseCost() const
Gets the region's base cost.
Definition: RuleRegion.cpp:134
const std::vector< double > & getLatMax() const
Gets the maximum latitude.
Definition: RuleRegion.h:110
const std::vector< double > & getLatMin() const
Gets the minimum latitude.
Definition: RuleRegion.h:112
std::string getType() const
Gets the region's type.
Definition: RuleRegion.cpp:125
const std::vector< double > & getLonMax() const
Gets the maximum longitude.
Definition: RuleRegion.h:106
Represents a city of the world.
Definition: City.h:32
Holds pairs of relative weights and IDs.
Definition: WeightedOptions.h:34
void load(const YAML::Node &node)
Loads the region from YAML.
Definition: RuleRegion.cpp:53
Represents a specific region of the world.
Definition: RuleRegion.h:65
~RuleRegion()
Cleans up the region ruleset.
Definition: RuleRegion.cpp:41
std::pair< double, double > getRandomPoint(size_t site) const
Gets a random point inside a mission site.
Definition: RuleRegion.cpp:189
size_t getWeight() const
Gets the weight of this region for mission selection.
Definition: RuleRegion.cpp:178