BS_NMSP::Controller Class Reference

Class for manipulating Emitter objects at a high level. More...

#include <bsController.h>

List of all members.

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.


Detailed Description

Class for manipulating Emitter objects at a high level.

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.


Constructor & Destructor Documentation

BS_NMSP::Controller::Controller ( ScriptMachine *  machine  )  [explicit]

Constructor.

Parameters:
machine pointer to an active ScriptMachine.


Member Function Documentation

bool BS_NMSP::Controller::_raiseEvent ( int  index,
const bstype *  args 
)

Triggers an event in the Controller.

This function is for internal use.

Parameters:
index index of the event to raise.
args array of values to pass as arguments.
Returns:
true if the event changed the Controller state, or not.

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.

Parameters:
block the value to act as a block.

void BS_NMSP::Controller::enable ( bool  enable  ) 

Enables or disables the Controller, and its Emitters.

Parameters:
enable enables if true, disables if false.

void BS_NMSP::Controller::enableEmitter ( int  index,
bool  enable 
)

Enables or disables the Emitter.

When disabled, an Emitter does no processing: its script state and member variables do not change. This function is for internal use.

Parameters:
index index of the Emitter.
enable true to enable, false to disable.

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).

Parameters:
emitter index of the emitter instance.
member index of the user member variable.
Returns:
the value of the Emitter 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.

Returns:
the user object.

bool BS_NMSP::Controller::isEnabled (  )  const

Tests whether the Controller is currently enabled or disabled.

Returns:
true is enabled, false otherwise.

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.

Parameters:
evt name of the event to raise.
args array of values to pass as arguments.
Returns:
BS_OK or BS_BadEvent if the event was not found

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.

Parameters:
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.

Parameters:
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).

Parameters:
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).

Parameters:
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.

Parameters:
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.

Parameters:
member index of the user member variable.
value value to set it to.

void BS_NMSP::Controller::setPosition ( bstype  x,
bstype  y 
)

Set the position of this Controller.

Parameters:
x new x position.
y new y position.

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.

Parameters:
state index of the state.

void BS_NMSP::Controller::setUserObject ( void *  userObject  ) 

Set the user-supplied object for this Controller.

Parameters:
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  ) 

Set the X position of this Controller.

Parameters:
x new x position.

void BS_NMSP::Controller::setY ( bstype  y  ) 

Set the Y position of this Controller.

Parameters:
y new y position.

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.

Parameters:
block the value to act as a block.

void BS_NMSP::Controller::update ( float  frameTime  ) 

Update the Controller.

This function is for internal use.

Parameters:
frameTime the time interval since last update, in seconds.


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

Generated on Wed Mar 31 12:49:05 2010 for bulletscript by  doxygen 1.5.9