![]() |
CUGL 1.2
Cornell University Game Library
|
#include <CUPriorityNode.h>
Public Member Functions | |
PriorityNode () | |
~PriorityNode () | |
![]() | |
CompositeNode () | |
~CompositeNode () | |
virtual void | dispose () override |
bool | isPreemptive () const |
void | setPreemptive (bool preemptive) |
const BehaviorNode * | getChildByPriorityIndex (Uint32 index) const |
template<typename T > | |
const T * | getChildByPriorityIndex (Uint32 index) const |
const BehaviorNode * | getActiveChild () const |
template<typename T > | |
const T * | getActiveChild () const |
virtual void | query (float dt) override |
BehaviorNode::State | update (float dt) override |
![]() | |
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 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) |
Protected Member Functions | |
virtual int | selectChild () const override |
Additional Inherited Members | |
![]() | |
enum | State : unsigned int { State::INACTIVE = 0, State::RUNNING = 1, State::PAUSED = 2, State::FINISHED = 3 } |
![]() | |
static bool | compareSiblings (const std::shared_ptr< BehaviorNode > &a, const std::shared_ptr< BehaviorNode > &b) |
![]() | |
bool | _preemptive |
![]() | |
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 priority composite node for a behavior tree.
A priority node is a composite node that chooses a child to run with the highest priority value. If a priority node is allowed to preempt, a child node that is running may be interrupted by another child node that has a higher priority value during the update function.
If the priority 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 the child with the highest priority if this node is not currently running.
A priority 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 PriorityNode.
|
inline |
Creates an uninitialized priority 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.
|
overrideprotectedvirtual |
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.
Implements cugl::ai::CompositeNode.