Recast  1
Game with custom magic
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
SpellNode.hpp
Go to the documentation of this file.
1 
8 #ifndef RECAST_SERVER_NODE_H
9 #define RECAST_SERVER_NODE_H
10 
11 #include <set>
12 #include "utils/Parcel.hpp"
14 
15 enum NodeType {
16  USUALLY = 0,
17  ENERGY = 1,
18  HEATER = 2,
19  AIM = 3,
21 };
22 
23 class SpellNode {
24 public:
25  SpellNode(NodeType type, float x, float y, float z) : x(x), y(y), z(z), type(type), nowInTick(false) {}
26 
27  ~SpellNode();
28 
29  virtual bool isEnergyNode() { return false; }
30 
37  void connectNode(SpellNode *otherNode);
38 
45  void tick(IEventListener &listener, SpellNode *callable);
46 
47  bool inTick() const { return nowInTick; }
48 
49  float getDistance(const SpellNode *otherNode) const;
50 
51  NodeType getType() const { return type; }
52 
53  void iterrator(std::function<void(SpellNode *)> next);
54 
55  std::set<SpellNode *> &getConnectedNodes() { return connectedNodes; }
56 
57  float getX() const { return x; }
58 
59  float getY() const { return y; }
60 
61  float getZ() const { return z; }
62 
63 
64  static void write(Parcel &in, SpellNode * obj);
65  static SpellNode *read(Parcel &out);
66 
67 protected:
68  float x, y, z;
69  std::set<SpellNode *> connectedNodes;
70  bool nowInTick;
72 
73  virtual inline void onTick(IEventListener &listener, SpellNode *callable) {};
74 };
75 
76 #endif //RECAST_SERVER_NODE_H
float getY() const
Definition: SpellNode.hpp:59
Serialization Parcel class header file.
Definition: SpellNode.hpp:20
float y
Definition: SpellNode.hpp:68
Definition: SpellNode.hpp:17
bool nowInTick
Definition: SpellNode.hpp:70
void iterrator(std::function< void(SpellNode *)> next)
Definition: SpellNode.cpp:55
~SpellNode()
Definition: SpellNode.cpp:47
static SpellNode * read(Parcel &out)
Definition: SpellNode.cpp:71
NodeType type
Definition: SpellNode.hpp:71
Definition: SpellNode.hpp:19
float z
Definition: SpellNode.hpp:68
NodeType getType() const
Definition: SpellNode.hpp:51
float getDistance(const SpellNode *otherNode) const
Definition: SpellNode.cpp:43
Definition: Parcel.hpp:35
Definition: SpellNode.hpp:23
float x
Definition: SpellNode.hpp:68
SpellNode(NodeType type, float x, float y, float z)
Definition: SpellNode.hpp:25
Definition: SpellNode.hpp:16
void connectNode(SpellNode *otherNode)
Definition: SpellNode.cpp:15
float getX() const
Definition: SpellNode.hpp:57
float getZ() const
Definition: SpellNode.hpp:61
Definition: SpellNode.hpp:18
std::set< SpellNode * > & getConnectedNodes()
Definition: SpellNode.hpp:55
NodeType
Definition: SpellNode.hpp:15
virtual void onTick(IEventListener &listener, SpellNode *callable)
Definition: SpellNode.hpp:73
void tick(IEventListener &listener, SpellNode *callable)
Definition: SpellNode.cpp:22
std::set< SpellNode * > connectedNodes
Definition: SpellNode.hpp:69
Definition: IEventListener.hpp:13
bool inTick() const
Definition: SpellNode.hpp:47
virtual bool isEnergyNode()
Definition: SpellNode.hpp:29
static void write(Parcel &in, SpellNode *obj)
Definition: SpellNode.cpp:64