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