CUGL 1.2
Cornell University Game Library
Public Member Functions | List of all members
cugl::ai::InverterNode Class Reference

#include <CUInverterNode.h>

Inheritance diagram for cugl::ai::InverterNode:
cugl::ai::DecoratorNode cugl::ai::BehaviorNode

Public Member Functions

 InverterNode ()
 
 ~InverterNode ()
 
virtual void query (float dt) override
 
- Public Member Functions inherited from cugl::ai::DecoratorNode
 DecoratorNode ()
 
 ~DecoratorNode ()
 
const BehaviorNodegetChild () const
 
template<typename T >
const T * getChild () const
 
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 BehaviorNodegetParent () const
 
void setParent (BehaviorNode *parent)
 
void removeFromParent ()
 
int getParentalOffset () const
 
size_t getChildCount () const
 
std::vector< const BehaviorNode * > getChildren () const
 
const BehaviorNodegetChild (Uint32 pos) const
 
template<typename T >
const T * getChild (Uint32 pos) const
 
const BehaviorNodegetNodeByName (const std::string &name) const
 
const BehaviorNodegetNodeByName (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< BehaviorNoderemoveChild (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
 

Detailed Description

A class providing an inverter decorator node for a behavior tree.

An inverter node is a decorator node that sets its priority value equal to the opposite of its child's priority. As the priority values for behavior tree nodes are between 0 to 1, the priority of this node is 1 - the child's priority value.

An inverter node's state is directly based on its child's state. When an inverter node starts, it immediately starts its child. When the child finishes execution, the inverter node also finishes execution.

Constructor & Destructor Documentation

cugl::ai::InverterNode::InverterNode ( )
inline

Creates an uninitialized inverter node.

You should never call this constructor directly. Instead, you should allocate a node with the BehaviorManager instance.

cugl::ai::InverterNode::~InverterNode ( )
inline

Deletes this node, disposing all resources.

Member Function Documentation

virtual void cugl::ai::InverterNode::query ( float  dt)
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.

Parameters
dtThe elapsed time since the last frame.

Reimplemented from cugl::ai::DecoratorNode.


The documentation for this class was generated from the following file: