CUGL 1.2
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | List of all members
cugl::ai::SelectorNode Class Reference

#include <CUSelectorNode.h>

Inheritance diagram for cugl::ai::SelectorNode:
cugl::ai::CompositeNode cugl::ai::BehaviorNode

Public Member Functions

 SelectorNode ()
 
 ~SelectorNode ()
 
virtual int selectChild () const override
 
- Public Member Functions inherited from cugl::ai::CompositeNode
 CompositeNode ()
 
 ~CompositeNode ()
 
virtual void dispose () override
 
bool isPreemptive () const
 
void setPreemptive (bool preemptive)
 
const BehaviorNodegetChildByPriorityIndex (Uint32 index) const
 
template<typename T >
const T * getChildByPriorityIndex (Uint32 index) const
 
const BehaviorNodegetActiveChild () const
 
template<typename T >
const T * getActiveChild () const
 
virtual void query (float dt) override
 
BehaviorNode::State update (float dt) override
 
- Public Member Functions inherited from cugl::ai::BehaviorNode
 BehaviorNode ()
 
 ~BehaviorNode ()
 
bool init (const std::string &name)
 
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::CompositeNode
bool _preemptive
 
- 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 a selector composite node for a behavior tree.

A selector node is a composite node that is designed to select and run the first child with a non-zero priority and run it. If the selector node is allowed to preempt, a child that is running may be overridden by an earlier child with a non-zero priority during the update function.

If the selector node is not assigned a priority function, its priority will be assigned as the priority of the running child if this node is currently running, or as the priority of first of its children with a non-zero priority.

A selector node's state is directly based upon the child node currently running or the child node that has finished running. Only one child node will finish running as part of the SelectorNode.

Constructor & Destructor Documentation

cugl::ai::SelectorNode::SelectorNode ( )
inline

Creates an uninitialized selector node.

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

cugl::ai::SelectorNode::~SelectorNode ( )
inline

Deletes this node, disposing all resources.

Member Function Documentation

virtual int cugl::ai::SelectorNode::selectChild ( ) const
overridevirtual

Returns a (possibly new) active child for this node.

This method is subclass dependent, and uses the rules of that subclass to select a child. If no child is selected, this method returns -1.

Returns
a (possibly new) active child for this node.

Implements cugl::ai::CompositeNode.


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