OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Node.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_NODE_H
20 #define OPENXCOM_NODE_H
21 
22 #include "../Battlescape/Position.h"
23 #include <yaml-cpp/yaml.h>
24 
25 namespace OpenXcom
26 {
27 
28 enum NodeRank{NR_SCOUT=0, NR_XCOM, NR_SOLDIER, NR_NAVIGATOR, NR_LEADER, NR_ENGINEER, NR_MISC1, NR_MEDIC, NR_MISC2};
29 
34 class Node
35 {
36 private:
37  int _id;
38  Position _pos;
39  int _segment;
40  std::vector<int> _nodeLinks;
41  int _type;
42  int _rank;
43  int _flags;
44  int _reserved;
45  int _priority;
46  bool _allocated;
47 public:
48  static const int CRAFTSEGMENT = 1000;
49  static const int UFOSEGMENT = 2000;
50  static const int TYPE_FLYING = 0x01; // non-flying unit can not spawn here when this bit is set
51  static const int TYPE_SMALL = 0x02; // large unit can not spawn here when this bit is set
52  static const int TYPE_DANGEROUS = 0x04; // an alien was shot here, stop patrolling to it like an idiot with a death wish
53  static const int nodeRank[8][7]; // maps alien ranks to node (.RMP) ranks
55  Node();
56  Node(int id, Position pos, int segment, int type, int rank, int flags, int reserved, int priority);
58  ~Node();
60  void load(const YAML::Node& node);
62  YAML::Node save() const;
64  int getID() const;
66  std::vector<int> *getNodeLinks();
68  NodeRank getRank() const;
70  int getPriority() const;
72  const Position& getPosition() const;
74  int getSegment() const;
76  int getType() const;
78  void setType(int type);
80  int getFlags() { return _flags; }
82  bool operator<(Node &b) { return _flags < b.getFlags(); };
83  bool isAllocated() const;
84  void allocateNode();
85  void freeNode();
86  bool isTarget() const;
87 
88 };
89 
90 }
91 
92 #endif
YAML::Node save() const
Saves the node to YAML.
Definition: Node.cpp:88
NodeRank getRank() const
Gets node's rank.
Definition: Node.cpp:117
int getType() const
Gets the node's type.
Definition: Node.cpp:159
int getSegment() const
Gets the node's segment.
Definition: Node.cpp:144
std::vector< int > * getNodeLinks()
get the node's paths
Definition: Node.cpp:150
void load(const YAML::Node &node)
Loads the node from YAML.
Definition: Node.cpp:70
int getFlags()
gets "flags" variable, which is really the patrolling desirability value
Definition: Node.h:80
~Node()
Cleans up the Node.
Definition: Node.cpp:48
int getID() const
get the node's id
Definition: Node.cpp:108
Node()
Creates a Node.
Definition: Node.cpp:25
int getPriority() const
Gets node's priority.
Definition: Node.cpp:126
const Position & getPosition() const
Gets the node's position.
Definition: Node.cpp:135
bool operator<(Node &b)
compares the _flags variables of the nodes (for the purpose of patrol decisions!) ...
Definition: Node.h:82
Represents a node/spawnpoint in the battlescape, loaded from RMP files.
Definition: Node.h:34
void setType(int type)
Sets the node's type, surprisingly.
Definition: Node.cpp:184
Easy handling of X-Y-Z coordinates.
Definition: Position.h:30