CUGL 1.3
Cornell University Game Library
|
#include <CUTimerNode.h>
Public Member Functions | |
TimerNode () | |
~TimerNode () | |
void | dispose () override |
std::string | toString (bool verbose=false) const override |
bool | isBackground () const |
void | setBackground (bool background) |
float | getDelay () const |
void | setDelay (float delay) |
float | getCurrentDelay () const |
void | setState (BehaviorNode::State state) override |
void | reset () override |
void | preempt () override |
virtual void | query (float dt) override |
BehaviorNode::State | update (float dt) override |
Public Member Functions inherited from cugl::ai::DecoratorNode | |
DecoratorNode () | |
~DecoratorNode () | |
const BehaviorNode * | getChild () const |
template<typename T > | |
const T * | getChild () const |
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 |
std::function< float()> | getPrioritizer () const |
void | setPrioritizer (const std::function< float()> &func) |
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 | pause () |
virtual void | resume () |
virtual void | start () |
void | setPriority (float priority) |
std::shared_ptr< BehaviorNode > | removeChild (Uint32 pos) |
void | addChild (const std::shared_ptr< BehaviorNode > child) |
Protected Attributes | |
bool | _background |
float | _delay |
bool | _delaying |
float | _timer |
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 |
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) |
A class decorating a behavior tree node with a timed delay.
There are two ways to delay a node. One is to chose the child, but not update the child until after a delay period. This is a "foreground" delay. The node is chosen, preventing other nodes from being chosen (if the parent is not preemptive), but it is delaying its completion.
The other type of delay is to delay when this node can be selected again once it has completed successfully. This is a "background" delay. It will set the priority to 0, and reassign this once the delay has passed.
cugl::ai::TimerNode::TimerNode | ( | ) |
Creates an uninitialized TimerNode.
You should never call this constructor directly. Instead, you should allocate a node with the BehaviorManager instance.
|
inline |
Deletes this node, disposing all resources.
|
overridevirtual |
Disposes all of the resources used by this node, including any descendants.
A disposed node can be safely reinitialized. Any children owned by this node will be released. They will be deleted if no other object owns them. This method should only be called by BehaviorManager.
Reimplemented from cugl::ai::BehaviorNode.
|
inline |
Returns the amount of time delayed so far (in seconds).
This value is reset to zero once the delay is complete.
|
inline |
Returns the delay time in seconds.
There are two ways to delay a node. One is to chose the child, but not update the child until after a delay period. This is a "foreground" delay. The node is chosen, preventing other nodes from being chosen (if the parent is not preemptive), but it is delaying its completion.
The other type of delay is to delay when this node can be selected again once it has completed successfully. This is a "background" delay. It will set the priority to 0, and reassign this once the delay has passed.
|
inline |
Returns true if this node implements a background delay.
There are two ways to delay a node. One is to chose the child, but not update the child until after a delay period. This is a "foreground" delay. The node is chosen, preventing other nodes from being chosen (if the parent is not preemptive), but it is delaying its completion.
The other type of delay is to delay when this node can be selected again once it has completed successfully. This is a "background" delay. It will set the priority to 0, and reassign this once the delay has passed.
|
overridevirtual |
Stops this node from running.
This method also stops any running nodes under this one if they exist.
Reimplemented from cugl::ai::BehaviorNode.
|
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. |
Reimplemented from cugl::ai::DecoratorNode.
|
overridevirtual |
Resets this node and all nodes below it to an uninitialized state.
This method also resets any class values to those set at the start of the tree. This method allows the node to be started again, as if it had not been run before.
Reimplemented from cugl::ai::BehaviorNode.
|
inline |
Sets whether this node implements a background delay.
There are two ways to delay a node. One is to chose the child, but not update the child until after a delay period. This is a "foreground" delay. The node is chosen, preventing other nodes from being chosen (if the parent is not preemptive), but it is delaying its completion.
The other type of delay is to delay when this node can be selected again once it has completed successfully. This is a "background" delay. It will set the priority to 0, and reassign this once the delay has passed.
background | Whether this node implements a background delay. |
|
inline |
Sets the delay time in seconds.
There are two ways to delay a node. One is to chose the child, but not update the child until after a delay period. This is a "foreground" delay. The node is chosen, preventing other nodes from being chosen (if the parent is not preemptive), but it is delaying its completion.
The other type of delay is to delay when this node can be selected again once it has completed successfully. This is a "background" delay. It will set the priority to 0, and reassign this once the delay has passed.
delay | the delay time in seconds. |
|
overridevirtual |
Sets the state of this node.
If this node has no parent, then this is the state of the behavior tree.
state | The state of this node. |
Reimplemented from cugl::ai::BehaviorNode.
|
overridevirtual |
Returns a string representation of this node for debugging purposes.
If verbose is true, the string will include class information. This allows us to unambiguously identify the class.
verbose | Whether to include class information. |
Reimplemented from cugl::ai::BehaviorNode.
|
overridevirtual |
Updates this node and any active children.
This method runs the update function, which executes to active child (if not a leaf) or the associated action (if a leaf). This method is not guaranteed to execute every time step; only if the node is the root of the tree or is selected as part of the active path.
If a node is not a leaf node and it has no active children, then the method will return INACTIVE.
dt | The elapsed time since the last frame. |
Reimplemented from cugl::ai::DecoratorNode.
|
protected |
Whether this node supports an sleepy delay.
|
protected |
The amount of time to delay execution of the child in seconds.
|
protected |
Whether this node is currently delaying (active or passive)
|
protected |
The amount of time delayed so far (active or passive)