CUGL 1.3
Cornell University Game Library
|
#include <CUDecoratorNode.h>
Public Member Functions | |
DecoratorNode () | |
~DecoratorNode () | |
const BehaviorNode * | getChild () const |
template<typename T > | |
const T * | getChild () const |
virtual void | query (float dt) override |
virtual BehaviorNode::State | update (float dt) override |
Public Member Functions inherited from cugl::ai::BehaviorNode | |
BehaviorNode () | |
~BehaviorNode () | |
bool | init (const std::string &name) |
virtual void | dispose () |
const std::string & | getName () const |
float | getPriority () const |
BehaviorNode::State | getState () const |
virtual void | setState (BehaviorNode::State state) |
std::function< float()> | getPrioritizer () const |
void | setPrioritizer (const std::function< float()> &func) |
virtual std::string | toString (bool verbose=false) const |
operator std::string () const | |
const BehaviorNode * | getParent () const |
void | setParent (BehaviorNode *parent) |
void | removeFromParent () |
int | getParentalOffset () const |
size_t | getChildCount () const |
std::vector< const BehaviorNode * > | getChildren () const |
const BehaviorNode * | getChild (Uint32 pos) const |
template<typename T > | |
const T * | getChild (Uint32 pos) const |
const BehaviorNode * | getNodeByName (const std::string &name) const |
const BehaviorNode * | getNodeByName (const char *name) const |
template<typename T > | |
const T * | getNodeByName (const std::string &name) const |
template<typename T > | |
const T * | getNodeByName (const char *name) const |
virtual void | reset () |
virtual void | pause () |
virtual void | resume () |
virtual void | preempt () |
virtual void | start () |
void | setPriority (float priority) |
std::shared_ptr< BehaviorNode > | removeChild (Uint32 pos) |
void | addChild (const std::shared_ptr< BehaviorNode > child) |
Additional Inherited Members | |
Public Types inherited from cugl::ai::BehaviorNode | |
enum | State : unsigned int { State::INACTIVE = 0, State::RUNNING = 1, State::PAUSED = 2, State::FINISHED = 3 } |
Static Public Member Functions inherited from cugl::ai::BehaviorNode | |
static bool | compareSiblings (const std::shared_ptr< BehaviorNode > &a, const std::shared_ptr< BehaviorNode > &b) |
Protected Attributes inherited from cugl::ai::BehaviorNode | |
std::string | _name |
std::string | _classname |
BehaviorNode * | _parent |
BehaviorNode::State | _state |
float | _priority |
std::function< float()> | _prioritizer |
std::vector< std::shared_ptr< BehaviorNode > > | _children |
int | _activeChild |
int | _childOffset |
A class providing a decorator node for a behavior tree.
A decorator node is a node that has exactly one child. The decorator node may alter the execution status of its child or use an altered version of its child's priority. The exact method of performing these modifications is defined within the different subclasses of this node. The status of the decorator node is related to the status of its child.
A composite node can be given a priority function to call when updating its own priority. If a function is not provided, the composite node will set its priority using a default algorithm, which is specified by its subclasses. Hence the priority function is a way of overriding the behavior of this node.
|
inline |
Creates an uninitialized decorator node.
You should never call this constructor directly. Instead, you should allocate a node with the BehaviorManager instance.
|
inline |
Deletes this node, disposing all resources.
|
inline |
Returns a (weak) pointer to this node's child.
The purpose of this pointer is to allow access to the subtree of a behavior tree. It does not grant ownership, as ownership is confined to BehaviorManager.
|
inline |
Returns a (weak) pointer to this node's child.
The purpose of this pointer is to allow access to the subtree of a behavior tree. It does not grant ownership, as ownership is confined to BehaviorManager.
This version of the method performs a dynamic typecast to the correct type.
|
overridevirtual |
Updates the priority value(s) for this node.
This method recursively determines the priority of this node and all of its children. The priority may be determined by a user-provided priority function or by the default priority function of the class.
When this method is complete, it will chose a child node to run, but will not run it. Unlike update, this method is guaranteed to run every time step in BehaviorManager, provided that the root node is running.
dt | The elapsed time since the last frame. |
Implements cugl::ai::BehaviorNode.
Reimplemented in cugl::ai::TimerNode, and cugl::ai::InverterNode.
|
overridevirtual |
Updates this node and any nodes under it.
This method runs the update function, which selects a child (if not a leaf) or an action (if a leaf) to execture. The method setPriority may be run as part of this function, especially if it is a composite node supporting preemption.
Calling update on a composite node whose children all have zero priority will have unpredictable effects.
dt | The elapsed time since the last frame. |
Implements cugl::ai::BehaviorNode.
Reimplemented in cugl::ai::TimerNode.