overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Static Public Member Functions
gameplay::AIMessage Class Reference

#include <AIMessage.h>

List of all members.

Classes

struct  Parameter

Public Types

enum  ParameterType {
  UNDEFINED, INTEGER, LONG, FLOAT,
  DOUBLE, BOOLEAN, STRING
}

Public Member Functions

unsigned int getId () const
const char * getSender () const
const char * getReceiver () const
int getInt (unsigned int index) const
void setInt (unsigned int index, int value)
long getLong (unsigned int index) const
void setLong (unsigned int index, long value)
float getFloat (unsigned int index) const
void setFloat (unsigned int index, float value)
double getDouble (unsigned int index) const
void setDouble (unsigned int index, double value)
bool getBoolean (unsigned int index) const
void setBoolean (unsigned int index, bool value)
const char * getString (unsigned int index) const
void setString (unsigned int index, const char *value)
unsigned int getParameterCount () const
ParameterType getParameterType (unsigned int index) const

Static Public Member Functions

static AIMessagecreate (unsigned int id, const char *sender, const char *receiver, unsigned int parameterCount)
static void destroy (AIMessage *message)

Detailed Description

Defines a simple message structure used for passing messages through the AI system.

Messages can store an arbitrary number of parameters. For the sake of simplicity, each parameter is stored as type double, which is flexible enough to store most data that needs to be passed.


Member Enumeration Documentation

Enumeration of supported AIMessage parameter types.


Member Function Documentation

static AIMessage* gameplay::AIMessage::create ( unsigned int  id,
const char *  sender,
const char *  receiver,
unsigned int  parameterCount 
) [static]

Creates a new message.

Once a message is constructed and populated with data, it can be routed to its intended recipient(s) by calling AIController::sendMessage(AIMessage*). The AIController will then handle scheduling and delivery of the message and it will also destroy the message after it has been successfully delivered. For this reason, once a message has been sent through AIController, it is unsafe to use or destroy the message pointer.

Parameters:
idThe message ID.
senderAIAgent sender ID (can be empty or null for an anonymous message).
receiverAIAgent receiver ID (can be empty or null for a broadcast message).
parameterCountNumber of parameters for this message.
Returns:
A new AIMessage.
static void gameplay::AIMessage::destroy ( AIMessage message) [static]

Destroys an AIMessage.

Under normal circumstances this method does not need to be called since the AIController will automatically destroy an AIMessage once it has been sent. However, in the rare case where an AIMessage is constructed and not passed to AIController::sendMessage, this method should be called to destroy the message.

bool gameplay::AIMessage::getBoolean ( unsigned int  index) const

Returns the value of the specified parameter as a boolean.

Parameters:
indexIndex of the parameter to get.
Returns:
The parameter value.
double gameplay::AIMessage::getDouble ( unsigned int  index) const

Returns the value of the specified parameter as a double.

Parameters:
indexIndex of the parameter to get.
Returns:
The parameter value.
float gameplay::AIMessage::getFloat ( unsigned int  index) const

Returns the value of the specified parameter as a float.

Parameters:
indexIndex of the parameter to get.
Returns:
The parameter value.
unsigned int gameplay::AIMessage::getId ( ) const

Returns the message ID.

Returns:
The message ID.
int gameplay::AIMessage::getInt ( unsigned int  index) const

Returns the value of the specified parameter as an integer.

Parameters:
indexIndex of the parameter to get.
Returns:
The parameter value.
long gameplay::AIMessage::getLong ( unsigned int  index) const

Returns the value of the specified parameter as a long integer.

Parameters:
indexIndex of the parameter to get.
Returns:
The parameter value.

Returns the number of parameters for this message.

Returns:
The number of message parameters.

Returns the type of the specified parameter.

Parameters:
indexIndex of the parameter to query.
Returns:
The parameter type.
const char* gameplay::AIMessage::getReceiver ( ) const

Returns the receiver for the message.

Returns:
The message receiver.
const char* gameplay::AIMessage::getSender ( ) const

Returns the sender for the message.

Returns:
The message sender ID.
const char* gameplay::AIMessage::getString ( unsigned int  index) const

Returns the value of the specified parameter as a string.

Parameters:
indexIndex of the parameter to get.
Returns:
The parameter value.
void gameplay::AIMessage::setBoolean ( unsigned int  index,
bool  value 
)

Sets a long parameter.

Parameters:
indexIndex of the parameter to set.
valueThe parameter value.
void gameplay::AIMessage::setDouble ( unsigned int  index,
double  value 
)

Sets a double parameter.

Parameters:
indexIndex of the parameter to set.
valueThe parameter value.
void gameplay::AIMessage::setFloat ( unsigned int  index,
float  value 
)

Sets a float parameter.

Parameters:
indexIndex of the parameter to set.
valueThe parameter value.
void gameplay::AIMessage::setInt ( unsigned int  index,
int  value 
)

Sets an integer parameter.

Parameters:
indexIndex of the parameter to set.
valueThe parameter value.
void gameplay::AIMessage::setLong ( unsigned int  index,
long  value 
)

Sets a long integer parameter.

Parameters:
indexIndex of the parameter to set.
valueThe parameter value.
void gameplay::AIMessage::setString ( unsigned int  index,
const char *  value 
)

Sets a string parameter.

Parameters:
indexIndex of the parameter to set.
valueThe parameter value.
 All Classes Functions Variables Typedefs Enumerations Enumerator