TSTK Reference: TGB General Functions

From RGWiki

Jump to: navigation, search

Contents

TSTK Reference: TGB - General Functions

Access Method Generators

The following section documents all of the functions found in the file: TSTK/TGB/accessMethodGenerators.cs.

generateBasicAccessMethods( %namespace , %fieldName )

Description: Utility function to generate a get/set method in a specified namespace for a specified field name.
Ex:
This call => generateBasicAccessMethods( "SimObject", "SomeField");
Generates two methods
// Returns value of 'SomeField' on %this.
function SimObject::getSomeField(%this)
{
return %this.SomeField;

|- | |- |// Sets value of 'SomeField' on %this and returns new value. |- |function SimObject::getSomeField(%this, %value) |- |{ |- | %this.SomeField = %value; |- | return %this.SomeField; |- |} |} Top

generateBasicGetMethod( %namespace , %fieldName )

Description: Utility function to generate a get method in a specified namespace for a specified field name.
Ex:
This call => generateBasicGetMethod( "SimObject", "SomeField");
Generates one method
// Returns value of 'SomeField' on %this.
function SimObject::getSomeField(%this)
{
return %this.SomeField;

|} Top

generateBasicSetMethod( %namespace , %fieldName )

Description: Utility function to generate a set method in a specified namespace for a specified field name.
Ex:
This call => generateBasicSetMethod( "SimObject", "SomeField");
Generates one method
// Sets value of 'SomeField' on %this and returns new value.
function SimObject::getSomeField(%this, %value)
{
%this.SomeField = %value;
return %this.SomeField;

|} Top


Behaviors

The following section documents all of the functions found in the file: TSTK/TGB/behaviors.cs.

SimObject::broadcastMethod(%this, %methodName, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9)

Description:
Calls named method on all other behaviors in current owner that
implement this method.
This is designed to allow behaviors to blindly access
callbacks in other behaviors (with the same owner) and can be thought
of as a rudimentary message system. It allows for the design
of complex behavior interaction without knowing the name of those behaviors
in advance.
This feature is used by many of the RG damage & energy behaviors.
EFM =>
This should work, but doesn't (bug?) =>
function BehaviorInstance::broadcastMethod(%this, %methodName, ...
Using SimObject:: for now until this is resolved.

Top

t2dSceneObject::broadcastBehaviorMethod(%this, %methodName, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9)

Description:
Same as broadcastMethod() but used by t2dSceneObject and its children to
call a named method on all of that objects' behaviors.

Top

t2dSceneObject::setConfigDatablock( %this, %newDB )

Description:
Fix for TGB 1.7.4 setConfigDatablock() quirk.
Without this fix, if we use a config datablock to initialize an object in the editor (or in the game), that object doesn't get any behaviors stored in the config datablock record.
Saving and reloading a level after assigning a datablock (w/ behaviors) works, but that is far too late.
We need the setConfigDatablock() method to attach the behaviors to the object right away.

Top

Effects

The following section documents all of the functions found in the file: TSTK/TGB/effects.cs.

findEffectsFileNames()

Description: Returns a list of event files in the local path.
Warning: This is depricated because the path is local to the TSTK root and may not find the files you really want to locate.

Top

EventManager

The following section documents all of the functions found in the file: TSTK/TGB/EventManager.cs.

createTGBEventManager(%name)

Description: Create an instance TGB event manager, extra work required to make the manager work properly.

Top

ActionMap::bindTGBEvent( %this, %device, %action, %object, %callback )

Description: Bind an input event to an (optional) object and a (required) callback (method/function), using a TGB event manager.
Warning: I've had problems with this, to the extent of encountering crashes. I suggest you use the Roaming Gamer bindMulti feature instead.

Top

ActionMap::unbindTGBEvent( %this, %device, %action, %object, %callback )

Description: Unbind an input event from an (optional) object and a (required) callback (method/function), using a TGB event manager.
Warning: I've had problems with this, to the extent of encountering crashes. I suggest you use the Roaming Gamer bindMulti feature instead.

Top

testEM()

Description: Internal only. Used to test TGB event manager.

Top

ImageMapDB

The following section documents all of the functions found in the file: TSTK/TGB/ImageMaps.cs.

createImageMapDB( %name , %path , %imageMode , %smoothing , %cellWidth, %cellHeight )

Description: This function is a worker function designed to simplify the creation of new imagemaps.
%name () - Name to give new image map. (Must be unique.)
%path () - Path + filename where image file for this image map is located.
%imageMode (FULL) - Mode to use for generating this image map: FULL or CELL
%smoothing (SMOOTH) - Smoothing technique to use: SMOOTH or NONE
%cellWidth (0) - Width to use for CELL image mode.
%cellHeight (%cellWidth) - Height to use for CELL image mode.
Note: This is used extensively in the Roaming Gamer TGB art packs.

Top

Level Loading

The following section documents all of the functions found in the file: TSTK/TGB/levelLoading.cs.

sceneWindow2D::loadLevel( %this, %level )

Description: This method overloads loadLevel() and captures data about the level file that was loaded for future use by various Roaming Gamer level loading scripts.

Top

sceneWindow2D::reloadCurrentLevel(%this)

Description: This method re-loads the current level.

Top

sceneWindow2D::loadNamedLevel(%this,%levelName)

Description: This method loads a named level.
Note: The path need not bee complete as this method will find the level anywhere in the path of the current game.

Top

sceneWindow2D::loadNumberedLevel(%this,%levelNumber)

%level = findFirstFile( %levelPath );
if(!isFile(%level))
{
error("loadNamedLevel() - Level File Not Found! => ", %levelPath );
return false;
}
%this.schedule( 100, endlevel );
%this.schedule( 200, loadLevel, %level );
}
/*
Description: This method loads a file having the same name pre-fix as the last level, but having a (possibly) different ending number.
Ex: Level1.t2d, Level.t2d, etc.
Note: The path need not bee complete as this method will find the level anywhere in the path of the current game.

Top

sceneWindow2D::loadNextNumberedLevel(%this)

Description: This method loads a file having the same name pre-fix as the last level, and ending in a number one greater than the last numbered level to be loaded.
Ex: If we last loaded Level1.t2d, means a call to this method will load Level2.t2d.
Note: The path need not bee complete as this method will find the level anywhere in the path of the current game.
Note2: A numbered level must have been previously loaded for this to work.

Top

sceneWindow2D::loadLastNumberedLevel(%this)

Description: This method loads a file having the same name pre-fix as the last level, and ending in a number on less than the last numbered level to be loaded.
Ex: If we last loaded Level2.t2d, means a call to this method will load Level1.t2d.
Note: The path need not bee complete as this method will find the level anywhere in the path of the current game.
Note2: A numbered level must have been previously loaded for this to work.

Top


Special

The following section documents all of the functions found in the file: TSTK/TGB/special.cs.

getSafeSpawnPosition( %container , %size , %boundingBox , %maxIter)

Description: Returns a random position somewhere inside of the specified bounding box where an object can be safely placed, such that it does not overlap any of the objects in %container.
This function will try to find a random position that satisfies this requirement up to %maxIter times. If it doesn't find one, a NULL string ("") is returned.
Note: Objects that do not receive or send collisions are ignored.

Top

calculateLinkPoints()

Description: Returns a list of eight link-points evenly distributed in a circle.
Note: This was written to simplify the creation of shield mounts in a starcastle remake.

Top


t2dSceneObject

The following section documents all of the functions found in the file: TSTK/TGB/t2dSceneObject.cs.

t2dSceneObject::distanceBetween( %this, %dstObject )

Description: Return the distance between this object and %dstObject.

Top

t2dSceneObject::vectorTo( %this, %dstObject )

Description: Return a vector between this object and %dstObject.

Top

t2dSceneObject::inFrontOfMe( %this, %dstObject )

Description: Return true if %distObject is in-front of this object.
To be in-front, %dstObject must be within a 180-degree field of view.

Top

t2dSceneObject::behindMe( %this, %dstObject )

Description: Return true if %distObject is behind of this object.
To be in-front, %dstObject must be outside a 180-degree field of view.

Top

Targeting

The following section documents all of the functions found in the file: TSTK/TGB/targeting.cs.

t2dSceneObject::inDistance( %this, %target, %distance )

Description: Returns true if a this object and %target are farther than %distance apart.

Top

t2dSceneObject::inFOV( %this, %target, %fov )

Description: Returns true if %target is withing %fov angle of this object's 'forward vector' (facing).

Top

t2dSceneObject::inLOS( %this, %target, %groupsMask )

Description: Returns true if a vector drawn between this object and %target does not intersect any objects.
Objects are ignored if they don't match the %groupMask. i.e. If they are not in any of the groups specified by that bitmask.

Top

t2dSceneObject::getTargets( %this, %fov, %distance, %groups )

Description:
Returns a list of target objects, separated by spaces. This
list will contain all objects within the specified
field-of-view (FOV) and distance. Furthermore, the list will
only include objects whose group numbers are included in
the %groups argument.
Arguments and (defaults) if not specified:
%this () - ID (or name) of caller.
%fov (360.0) - Field of view in which to search for targets.
%distance (10000.0) - Maximum distance at which to search for targets.
%groups ("0..31") - Groups that targets can be in.

Top

t2dSceneObject::getNearestTarget( %this, %fov, %distance, %groups )

Description:
Returns the nearest target matching the following (default) paramters:
%this () - ID (or name) of caller.
%fov (360.0) - Field of view in which to search for targets.
%distance (10000.0) - Maximum distance at which to search for targets.
%groups ("0..31") - Groups that targets can be in.

Top

t2dSceneObject::getFurthestTarget( %this, %fov, %distance, %groups )

Description:
Returns the furthest target matching the following (default) paramters:
%this () - ID (or name) of caller.
%fov (360.0) - Field of view in which to search for targets.
%distance (10000.0) - Maximum distance at which to search for targets.
%groups ("0..31") - Groups that targets can be in.

Top

t2dSceneObject::getRandomTarget( %this, %fov, %distance, %groups )

Description:
Returns a random target matching the following (default) paramters:
%this () - ID (or name) of caller.
%fov (360.0) - Field of view in which to search for targets.
%distance (10000.0) - Maximum distance at which to search for targets.
%groups ("0..31") - Groups that targets can be in.

Top

World Limit

The following section documents all of the functions found in the file: TSTK/TGB/WorldLimit.cs.

limitTeleport( %obj , %limit )

Description: Causes objects to wrap around axis. Assumes that screen is centered. i.e. Does not account for cases where the camera is offset.

Top

copyWorldLimit( %srcObj, %dstObj, %scaleFactor , %newMode , %newCallback )

Description: Copy the world-limit settings from %srcObject to %dstObject.
Optionally scale the bounds by %scaleFactor.
Optionally set a specified new mode.
Optionally specify a new callback.

Top

t2dSceneObject::getWorldLimitMode(%this)

Description: Get the current world limit mode for this object.

Top

t2dSceneObject::setWorldLimitMode(%this, %mode)

Description: Set the current world limit mode for this object.

Top

t2dSceneObject::getWorldLimitMinX(%this)

Description: Get the current world limit min-X bound for this object.

Top

t2dSceneObject::setWorldLimitMinX(%this, %val)

Description: Set the current world limit min-X bound for this object.

Top

t2dSceneObject::getWorldLimitMinY(%this)

Description: Get the current world limit min-Y bound for this object.

Top

t2dSceneObject::setWorldLimitMinY(%this, %val)

Description: Set the current world limit min-Y bound for this object.

Top

t2dSceneObject::getWorldLimitMaxX(%this)

Description: Get the current world limit max-X bound for this object.

Top

t2dSceneObject::setWorldLimitMaxX(%this, %val)

Description: Set the current world limit max-X bound for this object.

Top

t2dSceneObject::getWorldLimitMaxY(%this)

Description: Get the current world limit max-Y bound for this object.

Top

t2dSceneObject::setWorldLimitMaxY(%this, %val)

Description: set the current world limit max-Y bound for this object.

Top

t2dSceneObject::getWorldLimitCallback(%this)

Description: Get the current world limit callback for this object.

Top

t2dSceneObject::setWorldLimitCallback(%this, %callback)

Description: Set the current world limit callback for this object.

Top

Personal tools