SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
ai::ITimedNode Class Reference

A timed node is a TreeNode that is executed until a given time (millis) is elapsed. More...

#include <ITimedNode.h>

Inheritance diagram for ai::ITimedNode:
[legend]
Collaboration diagram for ai::ITimedNode:
[legend]

Public Member Functions

 ITimedNode (const std::string &name, const std::string &parameters, const ConditionPtr &condition)
 
TreeNodeStatus execute (const AIPtr &entity, int64_t deltaMillis) override
 
virtual TreeNodeStatus executeStart (const AIPtr &, int64_t)
 Called whenever the timer is started or restarted. More...
 
virtual TreeNodeStatus executeRunning (const AIPtr &, int64_t)
 Called whenever the timer is running. Not called in the frame where the timer is started or in the frame where it expired. More...
 
virtual TreeNodeStatus executeExpired (const AIPtr &, int64_t)
 Called in the frame where the timer expired. More...
 
- Public Member Functions inherited from ai::TreeNode
 TreeNode (const std::string &name, const std::string &parameters, const ConditionPtr &condition)
 
int getId () const
 Return the unique id for this node. More...
 
const std::string & getName () const
 Each node can have a user defines name that can be retrieved with this method.
 
const std::string & getParameters () const
 Return the raw parameters for this node.
 
void setName (const std::string &name)
 Updates the custom name of this TreeNode. More...
 
const std::string & getType () const
 The node type - this usually matches the class name of the TreeNode.
 
const ConditionPtr & getCondition () const
 
void setCondition (const ConditionPtr &condition)
 
const TreeNodes & getChildren () const
 
TreeNodes & getChildren ()
 
virtual void getRunningChildren (const AIPtr &entity, std::vector< bool > &active) const
 Get the state of all child nodes for the given entity. More...
 
int64_t getLastExecMillis (const AIPtr &ai) const
 Returns the time in milliseconds when this node was last run. This is only updated if execute() was called.
 
TreeNodeStatus getLastStatus (const AIPtr &ai) const
 
virtual void resetState (const AIPtr &entity)
 Reset the states in the node and also in the entity.
 
virtual bool addChild (const TreeNodePtr &child)
 
TreeNodePtr getChild (int id) const
 
bool replaceChild (int id, const TreeNodePtr &newNode)
 Replace the given child node with a new one (or removes it) More...
 
TreeNodePtr getParent (const TreeNodePtr &self, int id) const
 Get the parent node for a given TreeNode id - This should only be called on the root node of the behaviour. More...
 
- Public Member Functions inherited from ai::_MemObject< AllocatorClass >
void * operator new (size_t size)
 
void * operator new (size_t, void *ptr)
 
void * operator new[] (size_t size)
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *)
 
void operator delete[] (void *ptr)
 

Protected Attributes

int64_t _timerMillis
 
int64_t _millis
 
- Protected Attributes inherited from ai::TreeNode
int _id
 Every node has an id to identify it. It's unique per type.
 
TreeNodes _children
 
std::string _name
 
std::string _type
 
std::string _parameters
 
ConditionPtr _condition
 

Additional Inherited Members

- Protected Member Functions inherited from ai::TreeNode
TreeNodeStatus state (const AIPtr &entity, TreeNodeStatus treeNodeState)
 
int getSelectorState (const AIPtr &entity) const
 
void setSelectorState (const AIPtr &entity, int selected)
 
int getLimitState (const AIPtr &entity) const
 
void setLimitState (const AIPtr &entity, int amount)
 
void setLastExecMillis (const AIPtr &entity)
 
TreeNodePtr getParent_r (const TreeNodePtr &parent, int id) const
 
- Static Protected Member Functions inherited from ai::TreeNode
static int getNextId ()
 

Detailed Description

A timed node is a TreeNode that is executed until a given time (millis) is elapsed.

Member Function Documentation

TreeNodeStatus ai::ITimedNode::execute ( const AIPtr &  entity,
int64_t  deltaMillis 
)
inlineoverridevirtual
Parameters
entityThe entity to execute the TreeNode for
deltaMillisThe delta since the last execution
Returns
TreeNodeStatus

Reimplemented from ai::TreeNode.

virtual TreeNodeStatus ai::ITimedNode::executeExpired ( const AIPtr &  ,
int64_t   
)
inlinevirtual

Called in the frame where the timer expired.

Note
The returned TreeNodeStatus is recorded automatically
virtual TreeNodeStatus ai::ITimedNode::executeRunning ( const AIPtr &  ,
int64_t   
)
inlinevirtual

Called whenever the timer is running. Not called in the frame where the timer is started or in the frame where it expired.

Note
If you have a timer started, don't get into the timer callbacks for some time (e.g. the attached ICondition evaluation prevents the action from being executed), you will not get into executeRunning, but directly into executeExpired.
The returned TreeNodeStatus is recorded automatically
virtual TreeNodeStatus ai::ITimedNode::executeStart ( const AIPtr &  ,
int64_t   
)
inlinevirtual

Called whenever the timer is started or restarted.

Note
The returned TreeNodeStatus is recorded automatically

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