#include <AIMessage.h>
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 AIMessage * | create (unsigned int id, const char *sender, const char *receiver, unsigned int parameterCount) |
static void | destroy (AIMessage *message) |
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.
Enumeration of supported AIMessage parameter types.
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.
id | The message ID. |
sender | AIAgent sender ID (can be empty or null for an anonymous message). |
receiver | AIAgent receiver ID (can be empty or null for a broadcast message). |
parameterCount | Number of parameters for this message. |
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.
index | Index of the parameter to get. |
double gameplay::AIMessage::getDouble | ( | unsigned int | index | ) | const |
Returns the value of the specified parameter as a double.
index | Index of the parameter to get. |
float gameplay::AIMessage::getFloat | ( | unsigned int | index | ) | const |
Returns the value of the specified parameter as a float.
index | Index of the parameter to get. |
unsigned int gameplay::AIMessage::getId | ( | ) | const |
Returns the message ID.
int gameplay::AIMessage::getInt | ( | unsigned int | index | ) | const |
Returns the value of the specified parameter as an integer.
index | Index of the parameter to get. |
long gameplay::AIMessage::getLong | ( | unsigned int | index | ) | const |
Returns the value of the specified parameter as a long integer.
index | Index of the parameter to get. |
unsigned int gameplay::AIMessage::getParameterCount | ( | ) | const |
Returns the number of parameters for this message.
ParameterType gameplay::AIMessage::getParameterType | ( | unsigned int | index | ) | const |
Returns the type of the specified parameter.
index | Index of the parameter to query. |
const char* gameplay::AIMessage::getReceiver | ( | ) | const |
Returns the receiver for the message.
const char* gameplay::AIMessage::getSender | ( | ) | const |
Returns the sender for the message.
const char* gameplay::AIMessage::getString | ( | unsigned int | index | ) | const |
Returns the value of the specified parameter as a string.
index | Index of the parameter to get. |
void gameplay::AIMessage::setBoolean | ( | unsigned int | index, |
bool | value | ||
) |
Sets a long parameter.
index | Index of the parameter to set. |
value | The parameter value. |
void gameplay::AIMessage::setDouble | ( | unsigned int | index, |
double | value | ||
) |
Sets a double parameter.
index | Index of the parameter to set. |
value | The parameter value. |
void gameplay::AIMessage::setFloat | ( | unsigned int | index, |
float | value | ||
) |
Sets a float parameter.
index | Index of the parameter to set. |
value | The parameter value. |
void gameplay::AIMessage::setInt | ( | unsigned int | index, |
int | value | ||
) |
Sets an integer parameter.
index | Index of the parameter to set. |
value | The parameter value. |
void gameplay::AIMessage::setLong | ( | unsigned int | index, |
long | value | ||
) |
Sets a long integer parameter.
index | Index of the parameter to set. |
value | The parameter value. |
void gameplay::AIMessage::setString | ( | unsigned int | index, |
const char * | value | ||
) |
Sets a string parameter.
index | Index of the parameter to set. |
value | The parameter value. |