ScummVM API documentation
ai_node.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program 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  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SCUMM_HE_MOONBASE_AI_NODE_H
23 #define SCUMM_HE_MOONBASE_AI_NODE_H
24 
25 #include "common/array.h"
26 
27 namespace Scumm {
28 
29 const float SUCCESS = -1;
30 const float FAILURE = 1e20f;
31 
33 private:
34  int _objID;
35  float _valueG;
36 
37 protected:
38  virtual float getG() const { return _valueG; }
39  virtual float calcH() { return 0; }
40 
41 public:
42  IContainedObject() { _valueG = 0; _objID = -1; }
43  IContainedObject(float inG) { _valueG = inG; _objID = -1; }
44  IContainedObject(IContainedObject &sourceContainedObject);
45  virtual ~IContainedObject() {}
46 
47  virtual IContainedObject *duplicate() = 0;
48 
49  void setValueG(float inG) { _valueG = inG; }
50  float getValueG() { return _valueG; }
51 
52  int getObjID() const { return _objID; }
53  void setObjID(int inputObjID) { _objID = inputObjID; }
54 
55  virtual int numChildrenToGen() = 0;
56  virtual IContainedObject *createChildObj(int index, int &completionFlag) = 0;
57 
58  virtual int checkSuccess() = 0;
59  virtual float calcT() { return getG(); }
60 
61  float returnG() const { return getG(); }
62 };
63 
64 class Node {
65 private:
66  Node *_parent;
67  Common::Array<Node *> _children;
68 
69  int _depth;
70  static int _nodeCount;
71 
72  IContainedObject *_contents;
73 
74 public:
75  Node();
76  Node(Node *sourceNode);
77  ~Node();
78 
79  void setParent(Node *parentPtr) { _parent = parentPtr; }
80  Node *getParent() const { return _parent; }
81 
82  void setDepth(int depth) { _depth = depth; }
83  int getDepth() const { return _depth; }
84 
85  static int getNodeCount() { return _nodeCount; }
86 
87  void setContainedObject(IContainedObject *value) { _contents = value; }
88  IContainedObject *getContainedObject() { return _contents; }
89 
90  Common::Array<Node *> getChildren() const { return _children; }
91  int generateChildren();
92  int generateNextChild();
93  Node *popChild();
94 
95  float getObjectT() { return _contents->calcT(); }
96 
97  Node *getFirstStep();
98 };
99 
100 } // End of namespace Scumm
101 
102 #endif
Definition: ai_node.h:64
Definition: array.h:52
Definition: ai_node.h:32
Definition: actor.h:30