19 #ifndef OPENXCOM_POSITION_H
20 #define OPENXCOM_POSITION_H
22 #include <yaml-cpp/yaml.h>
38 Position(
int x_,
int y_,
int z_) : x(x_), y(y_), z(z_) {};
42 Position& operator=(
const Position& pos) { x = pos.x; y = pos.y; z = pos.z;
return *
this; }
45 Position& operator+=(
const Position& pos) { x+=pos.x; y+=pos.y; z+=pos.z;
return *
this; }
48 Position& operator-=(
const Position& pos) { x-=pos.x; y-=pos.y; z-=pos.z;
return *
this; }
51 Position& operator*=(
const Position& pos) { x*=pos.x; y*=pos.y; z*=pos.z;
return *
this; }
52 Position operator*(
const int v)
const {
return Position(x * v, y * v, z * v); }
53 Position& operator*=(
const int v) { x*=v; y*=v; z*=v;
return *
this; }
56 Position& operator/=(
const Position& pos) { x/=pos.x; y/=pos.y; z/=pos.z;
return *
this; }
58 Position operator/(
const int v)
const {
return Position(x / v, y / v, z / v); }
63 return x == pos.x && y == pos.y && z == pos.z;
68 return x != pos.x || y != pos.y || z != pos.z;
73 inline std::ostream& operator<<(std::ostream& out,
const Position& pos)
75 out <<
"(" << pos.x <<
"," << pos.y <<
","<< pos.z <<
")";
80 inline std::wostream& operator<<(std::wostream& wout,
const Position& pos)
82 wout <<
"(" << pos.x <<
"," << pos.y <<
","<< pos.z <<
")";
86 typedef Position Vector3i;
93 struct convert<OpenXcom::Position>
98 node.push_back(rhs.x);
99 node.push_back(rhs.y);
100 node.push_back(rhs.z);
106 if(!node.IsSequence() || node.size() != 3)
109 rhs.x = node[0].as<
int>();
110 rhs.y = node[1].as<
int>();
111 rhs.z = node[2].as<
int>();
Position(const Position &pos)
Copy constructor.
Definition: Position.h:40
bool operator!=(const Position &pos) const
!= operator
Definition: Position.h:66
bool operator==(const Position &pos) const
== operator
Definition: Position.h:61
Position()
Null position constructor.
Definition: Position.h:36
Position(int x_, int y_, int z_)
X Y Z position constructor.
Definition: Position.h:38
Easy handling of X-Y-Z coordinates.
Definition: Position.h:30