#include <bsMachine.h>
Public Member Functions | |
Machine () | |
Constructor. | |
~Machine () | |
Destructor. | |
const Log & | getLog () const |
Get the bulletscript log. | |
int | registerGlobalVariable (const String &name, bool readOnly, bstype initialValue) |
Register a global variable, for use in script. | |
void | setGlobalVariableValue (const String &name, bstype value) |
Set the named global variable. | |
int | compileScript (const uint8 *buffer, size_t bufferSize) |
Compile a script. | |
void | preUpdate (float frameTime) |
Called at the start of a bulletscript update section. | |
void | postUpdate (float frameTime) |
Called at the end of a bulletscript update section. | |
void | createType (const String &name) |
Create a new EmitType. | |
int | getTypeId (const String &name) const |
Get the unique id of the named EmitType. | |
void | releaseType (UserTypeBase *object) |
Releases the object's internal memory. | |
void | updateType (UserTypeBase *object, bstype x, bstype y, bstype angle, float frameTime) |
Update the user object. | |
int | registerEmitFunction (const String &type, const String &name, int numArgs, EmitFunction func) |
Register an EmitFunction for the specified type. | |
void | setDieFunction (const String &type, DieFunction func) |
Give the EmitType a user-defined DieFunction callback, for destroying emitted objects. | |
int | setAnchorX (const String &type, SetFunction set, GetFunction get) |
Set the 'x' property for this EmitType,. | |
int | setAnchorY (const String &type, SetFunction set, GetFunction get) |
Set the 'y' property for this EmitType,. | |
int | setAnchorAngle (const String &type, SetFunction set, GetFunction get) |
Set the 'angle' property for this EmitType,. | |
int | registerProperty (const String &type, const String &name, SetFunction set, GetFunction get) |
Register a controllable property for this EmitType. | |
int | registerAffector (const String &type, const String &name, AffectorFunction func) |
Registers a user AffectorFunction with this type. | |
int | registerNativeFunction (const String &name, bool returnsValue, int numArguments, NativeFunction func) |
Registers native function. | |
int | declareControllerMemberVariable (const String &ctrl, const String &var, bstype value) |
Declares a member variable for a Controller, which can then be used in script. | |
Emitter * | createEmitter (const String &definition, bstype x, bstype y, bstype angle, void *userObject=0) |
Create an Emitter. | |
void | destroyEmitter (Emitter *emit) |
Destroy the specified Emitter. | |
bool | emitterDefinitionExists (const String &name) const |
See whether the named EmitterDefinition exists. | |
Controller * | createController (const String &definition, bstype x, bstype y, bstype angle, void *userObject=0) |
Create a Controller. | |
void | destroyController (Controller *ctrl) |
Destroy the specified Controller. | |
bool | controllerDefinitionExists (const String &name) const |
See whether the named ControllerDefinition exists. |
This class is used to control all aspects of bulletscript relevant to the user. There can be more than one Machine running at one time, although there is little need for this, as objects within the machine do not communicate with each other.
int BS_NMSP::Machine::compileScript | ( | const uint8 * | buffer, | |
size_t | bufferSize | |||
) |
Compile a script.
buffer | buffer in which the script is stored. | |
bufferSize | the length of the script buffer. |
bool BS_NMSP::Machine::controllerDefinitionExists | ( | const String & | name | ) | const |
See whether the named ControllerDefinition exists.
name | name of the ControllerDefinition. |
Controller* BS_NMSP::Machine::createController | ( | const String & | definition, | |
bstype | x, | |||
bstype | y, | |||
bstype | angle, | |||
void * | userObject = 0 | |||
) |
Create a Controller.
definition | name of the ControllerDefinition to use (as defined in script). | |
x | initial x position. | |
y | initial y position. | |
angle | initial angle. | |
userObject | an object which the user can pass in. |
Emitter* BS_NMSP::Machine::createEmitter | ( | const String & | definition, | |
bstype | x, | |||
bstype | y, | |||
bstype | angle, | |||
void * | userObject = 0 | |||
) |
Create an Emitter.
definition | name of the EmitterDefinition to use (as defined in script). | |
x | initial x position. | |
y | initial y position. | |
angle | initial angle. | |
userObject | an object which the user can pass in, and can later access from any object created by this Emitter. |
void BS_NMSP::Machine::createType | ( | const String & | name | ) |
Create a new EmitType.
This does not check to see if the type already exists.
name | name of the EmitType. |
int BS_NMSP::Machine::declareControllerMemberVariable | ( | const String & | ctrl, | |
const String & | var, | |||
bstype | value | |||
) |
Declares a member variable for a Controller, which can then be used in script.
ctrl | name of the Controller. | |
var | name of the variable. | |
value | initial value. |
void BS_NMSP::Machine::destroyController | ( | Controller * | ctrl | ) |
void BS_NMSP::Machine::destroyEmitter | ( | Emitter * | emit | ) |
bool BS_NMSP::Machine::emitterDefinitionExists | ( | const String & | name | ) | const |
See whether the named EmitterDefinition exists.
name | name of the EmitterDefinition. |
int BS_NMSP::Machine::getTypeId | ( | const String & | name | ) | const |
Get the unique id of the named EmitType.
This can be used to retrieve an EmitType, to manipulate it directly.
name | name of the EmitType. |
void BS_NMSP::Machine::postUpdate | ( | float | frameTime | ) |
Called at the end of a bulletscript update section.
frameTime | the time interval since last update, in seconds. |
void BS_NMSP::Machine::preUpdate | ( | float | frameTime | ) |
Called at the start of a bulletscript update section.
frameTime | the time interval since last update, in seconds. |
int BS_NMSP::Machine::registerAffector | ( | const String & | type, | |
const String & | name, | |||
AffectorFunction | func | |||
) |
Registers a user AffectorFunction with this type.
Affector functions are stored per-EmitType. If the name is already in use, it will be overwritten.
type | EmitType to register for. | |
name | name of the function in script. | |
func | AffectorFunction function pointer. |
int BS_NMSP::Machine::registerEmitFunction | ( | const String & | type, | |
const String & | name, | |||
int | numArgs, | |||
EmitFunction | func | |||
) |
Register an EmitFunction for the specified type.
type | name of the EmitType | |
name | function name to be used in script. | |
numArgs | number of arguments, to be used in parsing. | |
func | pointer to the EmitFunction to use. |
int BS_NMSP::Machine::registerGlobalVariable | ( | const String & | name, | |
bool | readOnly, | |||
bstype | initialValue | |||
) |
Register a global variable, for use in script.
name | variable name. | |
readOnly | whether the variable can be modified in script, or not. | |
initialValue | initial value. |
int BS_NMSP::Machine::registerNativeFunction | ( | const String & | name, | |
bool | returnsValue, | |||
int | numArguments, | |||
NativeFunction | func | |||
) |
Registers native function.
name | name of the function in script. | |
returnsValue | whether the function returns a value or nothing. | |
numArguments | the number of arguments the function takes. | |
func | NativeFunction function pointer. |
int BS_NMSP::Machine::registerProperty | ( | const String & | type, | |
const String & | name, | |||
SetFunction | set, | |||
GetFunction | get | |||
) |
Register a controllable property for this EmitType.
You can only set BS_MAX_USER_PROPERTIES properties, defined in bsConfig.h, due to performance reasons.
type | EmitType to register for. | |
name | property name. | |
set | user-defined SetFunction. | |
get | user-defined GetFunction. |
void BS_NMSP::Machine::releaseType | ( | UserTypeBase * | object | ) |
Releases the object's internal memory.
The user should call this function on an object when they delete that object.
object | pointer to user object. |
int BS_NMSP::Machine::setAnchorAngle | ( | const String & | type, | |
SetFunction | set, | |||
GetFunction | get | |||
) |
Set the 'angle' property for this EmitType,.
This property must be set differently, because it is built-in, and used as an anchor.
type | EmitType to register for. | |
set | user-defined SetFunction. | |
get | user-defined GetFunction. |
int BS_NMSP::Machine::setAnchorX | ( | const String & | type, | |
SetFunction | set, | |||
GetFunction | get | |||
) |
Set the 'x' property for this EmitType,.
This property must be set differently, because it is built-in, and used as an anchor.
type | EmitType to register for. | |
set | user-defined SetFunction. | |
get | user-defined GetFunction. |
int BS_NMSP::Machine::setAnchorY | ( | const String & | type, | |
SetFunction | set, | |||
GetFunction | get | |||
) |
Set the 'y' property for this EmitType,.
This property must be set differently, because it is built-in, and used as an anchor.
type | EmitType to register for. | |
set | user-defined SetFunction. | |
get | user-defined GetFunction. |
void BS_NMSP::Machine::setDieFunction | ( | const String & | type, | |
DieFunction | func | |||
) |
Give the EmitType a user-defined DieFunction callback, for destroying emitted objects.
Unlike EmitFunctions, there can only be one DieFunction registered per EmitType.
type | EmitType to register for. | |
func | pointer to the function. |
void BS_NMSP::Machine::setGlobalVariableValue | ( | const String & | name, | |
bstype | value | |||
) |
Set the named global variable.
If the variable is not found, nothing happens.
name | variable name. | |
value | value to set to. |
void BS_NMSP::Machine::updateType | ( | UserTypeBase * | object, | |
bstype | x, | |||
bstype | y, | |||
bstype | angle, | |||
float | frameTime | |||
) |
Update the user object.
The user should call this on each object that they want bulletscript to update. It should be called between preUpdate() and postUpdate().
object | pointer to user object. | |
x | x position of the user object. | |
y | y position of the user object. | |
angle | angle of the user object. | |
frameTime | the time interval since last update, in seconds. |