BWAPI  4.2.0
An API for interacting with Starcraft: Broodwar (1.16.1)
Public Member Functions | List of all members
BWAPI::Interface< T > Class Template Reference
Inheritance diagram for BWAPI::Interface< T >:
Inheritance graph

Public Member Functions

void * getClientInfo (int key=0) const
template<typename CT >
CT getClientInfo (int key=0) const
void registerEvent (const std::function< void(T *)> &action, const std::function< bool(T *)> &condition=nullptr, int timesToRun=-1, int framesToCheck=0)
template<typename V >
void setClientInfo (const V &clientInfo, int key=0)

Detailed Description

template<typename T>
class BWAPI::Interface< T >

This generalized class allows the application of features that are common to all interface classes.

Template Parameters
TThe class that inherits this interface.

Member Function Documentation

void* BWAPI::Interface< T >::getClientInfo (int key = 0) const

Retrieves a pointer or value at an index that was stored for this interface using setClientInfo.

keyThe key containing the value to retrieve. Default is 0.
Return values
nullptrif index is out of bounds.
The client info at the given index.
See also

Referenced by BWAPI::Interface< T >::getClientInfo().

CT BWAPI::Interface< T >::getClientInfo (int key = 0) const
void BWAPI::Interface< T >::setClientInfo (const V & clientInfo, int key = 0 )

Associates one or more pointers or values with any BWAPI interface.

This client information is managed entirely by the AI module. It is not modified by BWAPI.

If a pointer to allocated memory is used, then the AI module is responsible for deallocating the memory when the game ends.

If client info at the given index has already been set, then it will be overwritten.

clientInfoThe data to associate with this interface.
keyThe key to use for this data. Default is 0.
See also
void BWAPI::Interface< T >::registerEvent (const std::function< void(T *)> & action, const std::function< bool(T *)> & condition = nullptr, int timesToRun = -1, int framesToCheck = 0 )

Registers an event and associates it with the current Interface object.

Events can be used to automate tasks (like train X Marines until Y of them have been created by the given Barracks) or to create user-defined callbacks.

actionThe action callback to be executed when the event conditions are true. It is of type void fn(T *inst) where fn is the function name and inst is a pointer to the instance of the object performing the action.
condition(optional) The condition callback which will return true if the action is intended to be executed. It is of type bool fn(T *inst) where fn is the function name and inst is a pointer to the instance of the object performing the check. The condition will always be true if omitted.
timesToRun(optional) The number of times to execute the action before the event is removed. If the value is negative, then the event will never be removed. The value will be -1 if omitted, causing the event to execute until the game ends.
framesToCheck(optional) The number of frames to skip between checks. If this value is 0, then a condition check is made once per frame. If this value is 1, then the condition for this event is only checked every other frame. This value is 0 by default, meaning the event's condition is checked every frame.