CUGL 1.3
Cornell University Game Library
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cugl::ai::BehaviorActionDef Class Reference

#include <CUBehaviorAction.h>

Public Member Functions

 BehaviorActionDef ()
 

Static Public Member Functions

static std::shared_ptr< BehaviorActionDefalloc ()
 

Public Attributes

std::string name
 
std::function< void()> start
 
std::function< bool(float dt)> update
 
std::function< void()> terminate
 

Detailed Description

A reusable definition for BehaviorAction.

This definition format allows us to have a single action definition that is used across mutliple instances. The motivation is the same as the difference between a Body and BodyDef in Box2d.

Constructor & Destructor Documentation

◆ BehaviorActionDef()

cugl::ai::BehaviorActionDef::BehaviorActionDef ( )
inline

Creates an uninitialized behavior action definition.

To create a definition for an action, access the attributes directly.

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use the static constructor instead.

Member Function Documentation

◆ alloc()

static std::shared_ptr<BehaviorActionDef> cugl::ai::BehaviorActionDef::alloc ( )
inlinestatic

Returns a newly allocated (uninitialized) behavior action definition.

To create a definition for an action, access the attributes directly.

Returns
a newly allocated (uninitialized) behavior action definition.

Member Data Documentation

◆ name

std::string cugl::ai::BehaviorActionDef::name

The descriptive, identifying name of the action.

◆ start

std::function<void()> cugl::ai::BehaviorActionDef::start

The initialization function to begin running an action.

This function should set up the inital action state for the update function.

◆ terminate

std::function<void()> cugl::ai::BehaviorActionDef::terminate

The terminate function to manage interruptions.

This function is to handle any interruptions that occur before the action has completed. This function should ensure that the actor returns to a stable state when the action is interrupted.

◆ update

std::function<bool(float dt)> cugl::ai::BehaviorActionDef::update

The update function processing the action over time.

This returns true if the action is finished and false otherwise. If the function returns true, it is assumed that any necessary clean-up has already happened and no further function calls are necessary.


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