#include <bsController.h>
Classes | |
struct | EmitterInstance |
struct | Event |
struct | MemberController |
Public Member Functions | |
Controller (ScriptMachine *machine) | |
Constructor. | |
void | onRelease () |
Callback for when the Controller is no longer needed. | |
void | setDefinition (ControllerDefinition *def, bstype x, bstype y, bstype angle) |
Set a Controller instance to use the specified ControllerDefinition. | |
void | enable (bool enable) |
Enables or disables the Controller, and its Emitters. | |
bool | isEnabled () const |
Tests whether the Controller is currently enabled or disabled. | |
void | setX (bstype x) |
Set the X position of this Controller. | |
void | setY (bstype y) |
Set the Y position of this Controller. | |
void | setPosition (bstype x, bstype y) |
Set the position of this Controller. | |
void | setAngle (bstype facing, bstype orbit) |
Set the angle of this Controller, in degrees. | |
void | setMember (int member, bstype value) |
Set the specified member of the Controller. | |
void | setUserObject (void *userObject) |
Set the user-supplied object for this Controller. | |
void * | getUserObject () const |
Get the user-supplied object for this Controller. | |
void | setState (int state) |
Set the Controller state. | |
void | setEmitterMember (int emitter, int member, bstype value) |
Set the specified member of an Emitter controlled by this Controller. | |
void | setEmitterMember (int emitter, int member, bstype value, float time) |
Interpolate the specified member of an Emitter controlled by this Controller. | |
bstype | getEmitterMember (int emitter, int member) const |
Get the value of an Emitter member variable. | |
void | setEmitterMemberState (int emitter, int state) |
Set an Emitter's state. | |
int | raiseEvent (const String &evt, const bstype *args) |
Triggers an event in the Controller. | |
bool | _raiseEvent (int index, const bstype *args) |
Triggers an event in the Controller. | |
void | addBlock (bstype block) |
Adds a block to the Controller. | |
void | signal (bstype block) |
Removes a block from the Controller. | |
void | resume () |
Resumes the Controller from a waiting state. | |
void | enableEmitter (int index, bool enable) |
Enables or disables the Emitter. | |
void | update (float frameTime) |
Update the Controller. |
Controllers are script objects which can control Emitters in a similar way that those emit objects. They have a concept of states, and can also be driven explicitly by the user via events. They can modify Emitter member variables, as well as enabling or disabling the Emitters themselves.
BS_NMSP::Controller::Controller | ( | ScriptMachine * | machine | ) | [explicit] |
Constructor.
machine | pointer to an active ScriptMachine. |
bool BS_NMSP::Controller::_raiseEvent | ( | int | index, | |
const bstype * | args | |||
) |
Triggers an event in the Controller.
This function is for internal use.
index | index of the event to raise. | |
args | array of values to pass as arguments. |
void BS_NMSP::Controller::addBlock | ( | bstype | block | ) |
Adds a block to the Controller.
Blocks are used to suspend a Controller state, and only resume when the blocks have been signalled to it, via an event, or code. This way states can wait upon multiple events before resuming. In the case that the block already exists, it is not added.
block | the value to act as a block. |
void BS_NMSP::Controller::enable | ( | bool | enable | ) |
Enables or disables the Controller, and its Emitters.
enable | enables if true, disables if false. |
void BS_NMSP::Controller::enableEmitter | ( | int | index, | |
bool | enable | |||
) |
bstype BS_NMSP::Controller::getEmitterMember | ( | int | emitter, | |
int | member | |||
) | const |
Get the value of an Emitter member variable.
This is used for built-in member variables as well as user-defined ones. Hence, the first user variable is at index NUM_SPECIAL_MEMBERS (defined in bsCore.h).
emitter | index of the emitter instance. | |
member | index of the user member variable. |
void* BS_NMSP::Controller::getUserObject | ( | ) | const |
Get the user-supplied object for this Controller.
The user object can be used to pass information to the emit function. This is useful because Controller are updated by the bulletscript machine in one go, and the user is otherwise unable to intercept the update to set Controller-specific parameters in their application. All Emitters controlled by this Controller use the same, specified user object.
bool BS_NMSP::Controller::isEnabled | ( | ) | const |
Tests whether the Controller is currently enabled or disabled.
void BS_NMSP::Controller::onRelease | ( | ) |
Callback for when the Controller is no longer needed.
Controllers are managed by a pool, and so need to be reused without being destroyed and recreated. This function overrides DeepMemoryPoolObject::onRelease to tidy up the parts of Controller that need it.
int BS_NMSP::Controller::raiseEvent | ( | const String & | evt, | |
const bstype * | args | |||
) |
Triggers an event in the Controller.
This function is for use by the user, hence the event is retrieved by name for convenience. It is currently up to the user to ensure that the number of arguments passed is correct.
evt | name of the event to raise. | |
args | array of values to pass as arguments. |
void BS_NMSP::Controller::resume | ( | ) |
Resumes the Controller from a waiting state.
This is used to implement signal functionality. While signals are generally used to resume from a suspend, they will also resume a state if it is currently waiting.
void BS_NMSP::Controller::setAngle | ( | bstype | facing, | |
bstype | orbit | |||
) |
Set the angle of this Controller, in degrees.
facing | the angle in which to orient the Controller and its Emitters. | |
orbit | the angle by which to rotate the position of the Controller's Emitters. |
void BS_NMSP::Controller::setDefinition | ( | ControllerDefinition * | def, | |
bstype | x, | |||
bstype | y, | |||
bstype | angle | |||
) |
Set a Controller instance to use the specified ControllerDefinition.
Sets the Controller to use the given ControllerDefinition. You do not want to call this function directly: doing so will leave the Controller in an undefined state. Use Machine::createController instead.
def | pointer to the ControllerDefinition to use to set the Controller up. | |
x | initial x position | |
y | initial y position | |
angle | initial angle |
void BS_NMSP::Controller::setEmitterMember | ( | int | emitter, | |
int | member, | |||
bstype | value, | |||
float | time | |||
) |
Interpolate the specified member of an Emitter controlled by this Controller.
This function changes the specified variable smoothly over time. Unlike setMember, this is used for built-in member variables as well as user-defined ones. Hence, the first user variable is at index NUM_SPECIAL_MEMBERS (defined in bsCore.h).
emitter | index of the emitter instance. | |
member | index of the member variable. | |
value | value to set it to. | |
time | length of time (in seconds) to set the variable over. |
void BS_NMSP::Controller::setEmitterMember | ( | int | emitter, | |
int | member, | |||
bstype | value | |||
) |
Set the specified member of an Emitter controlled by this Controller.
Unlike setMember, this is used for built-in member variables as well as user-defined ones. Hence, the first user variable is at index NUM_SPECIAL_MEMBERS (defined in bsCore.h).
emitter | index of the emitter instance. | |
member | index of the user member variable. | |
value | value to set it to. |
void BS_NMSP::Controller::setEmitterMemberState | ( | int | emitter, | |
int | state | |||
) |
Set an Emitter's state.
Sets the state to the specified index. This is an internal method which uses index for speed reasons.
emitter | index of the emitter instance. | |
state | index of the state. |
void BS_NMSP::Controller::setMember | ( | int | member, | |
bstype | value | |||
) |
Set the specified member of the Controller.
This is for user-defined member variables. Built-in members such as position and angle are not set this way, thus index 0 is refers to the first user-defined member.
member | index of the user member variable. | |
value | value to set it to. |
void BS_NMSP::Controller::setPosition | ( | bstype | x, | |
bstype | y | |||
) |
void BS_NMSP::Controller::setState | ( | int | state | ) |
Set the Controller state.
Sets the state to the specified index. This is an internal method which uses index for speed reasons.
state | index of the state. |
void BS_NMSP::Controller::setUserObject | ( | void * | userObject | ) |
Set the user-supplied object for this Controller.
userObject | pointer to a user-supplied object, which is passed back into any emit function that this Controller's Emitters call. |
void BS_NMSP::Controller::setX | ( | bstype | x | ) |
void BS_NMSP::Controller::setY | ( | bstype | y | ) |
void BS_NMSP::Controller::signal | ( | bstype | block | ) |
Removes a block from the Controller.
if the specified block exists in the Controller, it will be removed. This function helps implement signal functionality in scripts, for pausing scripts upon events.
block | the value to act as a block. |
void BS_NMSP::Controller::update | ( | float | frameTime | ) |
Update the Controller.
This function is for internal use.
frameTime | the time interval since last update, in seconds. |