Torque2D Reference
Loading...
Searching...
No Matches
SimObject Class Reference

#include <simObject.h>

Inheritance diagram for SimObject:

Classes

struct  Notify

Public Types

enum  WriteFlags { SelectedOnly = BIT(0) }

Public Member Functions

StringTableEntry getClassNamespace () const
StringTableEntry getSuperClassNamespace () const
void setClassNamespace (const char *classNamespace)
void setSuperClassNamespace (const char *superClassNamespace)
void pushScriptCallbackGuard (void)
void popScriptCallbackGuard (void)
S32 getScriptCallbackGuard (void)
virtual SimObjectfindObject (const char *name)
NamespacegetNamespace ()
 Return the object's namespace.
const char * tabComplete (const char *prevText, S32 baseLen, bool)
virtual void dump ()
virtual void dumpClassHierarchy ()
SimObjectclone (const bool copyDynamicFields)
virtual void copyTo (SimObject *object)
SimObjectdeepClone ()
template<typename T>
bool isType (void)
virtual bool handlesConsoleMethod (const char *fname, S32 *routingId)
 DECLARE_CONOBJECT (SimObject)
Public Member Functions inherited from ConsoleObject
const AbstractClassRep::FieldfindField (StringTableEntry fieldName) const
 Get a reference to a field by name.
virtual AbstractClassRepgetClassRep () const
 Gets the ClassRep.
bool setField (const char *fieldName, const char *value)
 Set the value of a field.
virtual ~ConsoleObject ()
const AbstractClassRep::FieldListgetFieldList () const
 Get a list of all the fields. This information cannot be modified.
AbstractClassRep::FieldListgetModifiableFieldList ()
bool & getDynamicGroupExpand ()
S32 getClassId (U32 netClassGroup) const
const char * getClassName () const

Static Public Member Functions

static void initPersistFields ()
Static Public Member Functions inherited from ConsoleObject
static const char * lookupClassName (const U32 in_classTag)
 Get the classname from a class tag.
static void initPersistFields ()
static void consoleInit ()
static AbstractClassRepgetStaticClassRep ()
 Get the abstract class information for this class.
static AbstractClassRepgetParentStaticClassRep ()
 Get the abstract class information for this class's superclass.
static ConsoleObjectcreate (const char *in_pClassName)
static ConsoleObjectcreate (const U32 groupId, const U32 typeId, const U32 in_classId)

Protected Member Functions

virtual void onTamlPreWrite (void)
 Taml callbacks.
virtual void onTamlPostWrite (void)
 Called after Taml has finished writing the object.
virtual void onTamlPreRead (void)
 Called prior to Taml reading the object.
virtual void onTamlPostRead (const TamlCustomNodes &customNodes)
virtual void onTamlAddParent (SimObject *pParentObject)
 Called after Taml has finished reading the object and has added the object to any parent.
virtual void onTamlCustomWrite (TamlCustomNodes &customNodes)
 Called during the writing of the object to allow custom properties to be written.
virtual void onTamlCustomRead (const TamlCustomNodes &customNodes)
 Called during the reading of the object to allow custom properties to be read.
void linkNamespaces ()
void unlinkNamespaces ()
virtual SimObjectallocClone ()
 A registered but empty object of this object's class.
void cloneInto (SimObject *clone)
virtual void deepCloneChildren (SimObject *clone)
Protected Member Functions inherited from ConsoleObject
 ConsoleObject ()
 ConsoleObject (const ConsoleObject &)

Static Protected Member Functions

static bool setClass (void *obj, const char *data)
static bool setSuperClass (void *obj, const char *data)
static bool writeObjectName (void *obj, StringTableEntry pFieldName)
static bool writeCanSaveDynamicFields (void *obj, StringTableEntry pFieldName)
static bool writeInternalName (void *obj, StringTableEntry pFieldName)
static bool setParentGroup (void *obj, const char *data)
static bool writeParentGroup (void *obj, StringTableEntry pFieldName)
static bool writeSuperclass (void *obj, StringTableEntry pFieldName)
static bool writeClass (void *obj, StringTableEntry pFieldName)
static bool setProtectedName (void *obj, const char *data)
static const char * getProtectedName (void *obj, const char *data)
static void addGroup (const char *in_pGroupname, const char *in_pGroupDocs=NULL)
static void endGroup (const char *in_pGroupname)
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::WriteDataNotify in_writeDataFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, const char *in_pFieldDocs)
static void addField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::WriteDataNotify in_writeDataFn, const char *in_pFieldDocs)
static void addFieldV (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, ConsoleTypeValidator *v, const char *in_pFieldDocs=NULL)
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, AbstractClassRep::WriteDataNotify in_writeDataFn=&defaultProtectedWriteFn, const U32 in_elementCount=1, EnumTable *in_table=NULL, const char *in_pFieldDocs=NULL)
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, const char *in_pFieldDocs=NULL)
static void addProtectedField (const char *in_pFieldname, const U32 in_fieldType, const dsize_t in_fieldOffset, AbstractClassRep::SetDataNotify in_setDataFn, AbstractClassRep::GetDataNotify in_getDataFn=&defaultProtectedGetFn, AbstractClassRep::WriteDataNotify in_writeDataFn=&defaultProtectedWriteFn, const char *in_pFieldDocs=NULL)
static void addDepricatedField (const char *fieldName)
static bool removeField (const char *in_pFieldname)

Protected Attributes

SimObjectId mId
 Id number for this object.
StringTableEntry mIdString
NamespacemNameSpace
U32 mTypeMask
S32 mScriptCallbackGuard
 Whether the object is executing a script callback.
bool mCanSaveFieldDictionary
 true if dynamic fields (added at runtime) should be saved, defaults to true
StringTableEntry mInternalName
 Stores object Internal Name.
StringTableEntry mClassName
 Stores the class name to link script class namespaces.
StringTableEntry mSuperClassName
 Stores super class name to link script class namespaces.

Friends

class SimManager
class SimGroup
class SimNameDictionary
class SimManagerNameDictionary
class SimIdDictionary

Serialization

enum  CopyFieldsFlags { CopyFields_SkipName = BIT(0) , CopyFields_SkipParentGroup = BIT(1) , CopyFields_SkipScriptClass = BIT(2) }
 What copyFieldsFrom may be told to leave alone. More...
virtual bool writeField (StringTableEntry fieldname, const char *value)
virtual void write (Stream &stream, U32 tabStop, U32 flags=0)
virtual void writeFields (Stream &stream, U32 tabStop)
virtual bool writeObject (Stream *stream)
virtual bool readObject (Stream *stream)
virtual void buildFilterList ()
void addFieldFilter (const char *fieldName)
void removeFieldFilter (const char *fieldName)
void clearFieldFilters ()
bool isFiltered (const char *fieldName)
void assignFieldsFrom (SimObject *obj)
void copyFieldsFrom (SimObject *obj, const U32 flags)
void assignDynamicFieldsFrom (SimObject *obj)

Notification

static SimObject::NotifymNotifyFreeList = NULL
static SimObject::NotifyallocNotify ()
 Get a free Notify structure.
static void freeNotify (SimObject::Notify *)
 Mark a Notify structure as free.
NotifyremoveNotify (void *ptr, Notify::Type)
 Remove a notification from the list.
void deleteNotify (SimObject *obj)
 Notify an object when we are deleted.
void clearNotify (SimObject *obj)
 Notify an object when we are cleared.
void clearAllNotifications ()
 Remove all notifications for this object.
void processDeleteNotifies ()
 Send out deletion notifications.
void registerReference (SimObject **obj)
void unregisterReference (SimObject **obj)
void addListener (std::string objID)
void removeListener (std::string objID)
void removeAllListeners ()
void postEvent (std::string eventName, std::string data)

Accessors

static bool disableNameChanging = false
const char * getDataField (StringTableEntry slotName, const char *array)
virtual void setDataField (StringTableEntry slotName, const char *array, const char *value)
const char * getPrefixedDataField (StringTableEntry fieldName, const char *array)
void setPrefixedDataField (StringTableEntry fieldName, const char *array, const char *value)
const char * getPrefixedDynamicDataField (StringTableEntry fieldName, const char *array, const S32 fieldType=-1)
void setPrefixedDynamicDataField (StringTableEntry fieldName, const char *array, const char *value, const S32 fieldType=-1)
StringTableEntry getDataFieldPrefix (StringTableEntry fieldName)
U32 getDataFieldType (StringTableEntry slotName, const char *array)
SimFieldDictionarygetFieldDictionary ()
void clearDynamicFields (void)
 Clear all dynamic fields.
void setCanSaveDynamicFields (bool bCanSave)
 Set whether fields created at runtime should be saved. Default is true.
bool getCanSaveDynamicFields (void) const
 Get whether fields created at runtime should be saved. Default is true.
void setInternalName (const char *newname)
StringTableEntry getInternalName ()
 Get the internal of of this control.
virtual bool save (const char *pcFilePath, bool bOnlySelected=false)
 Save object as a TorqueScript File.
virtual bool isMethod (const char *methodName)
 Check if a method exists in the objects current namespace.
SimObjectId getId (void) const
StringTableEntry getIdString (void) const
U32 getType () const
const StringTableEntry getName (void) const
void setId (SimObjectId id)
void assignName (const char *name)
SimGroupgetGroup () const
bool isChildOfGroup (SimGroup *pGroup)
bool isProperlyAdded () const
bool isDeleted () const
bool isRemoved () const
bool isLocked () const
void setLocked (bool b)
bool isHidden () const
void setHidden (bool b)
void setProgenitorFile (const char *pFile)
StringTableEntry getProgenitorFile (void) const
void setPeriodicTimerID (const S32 timerID)
S32 getPeriodicTimerID (void) const
bool isPeriodicTimerActive (void) const
bool isSelected () const
bool isExpanded () const
void setSelected (bool sel)
void setExpanded (bool exp)
void setModDynamicFields (bool dyn)
void setModStaticFields (bool sta)

Initialization

 SimObject ()
virtual ~SimObject ()
virtual bool processArguments (S32 argc, const char **argv)
 Process constructor options. (ie, new SimObject(1,2,3)).

Events

virtual bool onAdd ()
 Called when the object is added to the sim.
virtual void onRemove ()
 Called when the object is removed from the sim.
virtual void onGroupAdd ()
 Called when the object is added to a SimGroup.
virtual void onGroupRemove ()
 Called when the object is removed from a SimGroup.
virtual void onNameChange (const char *name)
 Called when the object's name is changed.
virtual void onStaticModified (const char *slotName, const char *newValue=NULL)
virtual void inspectPreApply ()
virtual void inspectPostApply ()
virtual void onDeleteNotify (SimObject *object)
virtual void onEditorEnable ()
 Called when the editor is activated.
virtual void onEditorDisable ()
 Called when the editor is deactivated.

Registration

SimObjects must be registered with the object system.

bool registerObject ()
bool registerObject (U32 id)
bool registerObject (const char *name)
bool registerObject (const char *name, U32 id)
void unregisterObject ()
void deleteObject ()

Sets

The object must be properly registered before you can add/remove it to/from a set.

All these functions accept either a name or ID to identify the set you wish to operate on. Then they call addObject or removeObject on the set, which sets up appropriate notifications.

An object may be in multiple sets at a time.

bool addToSet (SimObjectId)
bool addToSet (const char *)
bool removeFromSet (SimObjectId)
bool removeFromSet (const char *)

Detailed Description

Base class for objects involved in the simulation.

Introduction

SimObject is a base class for most of the classes you'll encounter working in Torque. It provides fundamental services allowing "smart" object referencing, creation, destruction, organization, and location. Along with SimEvent, it gives you a flexible event-scheduling system, as well as laying the foundation for the in-game editors, GUI system, and other vital subsystems.

Subclassing

You will spend a lot of your time in Torque subclassing, or working with subclasses of, SimObject. SimObject is designed to be easy to subclass.

You should not need to override anything in a subclass except:

Of course, if you know what you're doing, go nuts! But in most cases, you shouldn't need to touch things not on that list.

When you subclass, you should define a typedef in the class, called Parent, that references the class you're inheriting from.

class mySubClass : public SimObject {
typedef SimObject Parent;
...
SimObject()
Definition simObject.cc:52

Then, when you override a method, put in:

bool mySubClass::onAdd()
{
if(!Parent::onAdd())
return false;
// ... do other things ...
}

Of course, you want to replace onAdd with the appropriate method call.

A SimObject's Life Cycle

SimObjects do not live apart. One of the primary benefits of using a SimObject is that you can uniquely identify it and easily find it (using its ID). Torque does this by keeping a global hierarchy of SimGroups - a tree - containing every registered SimObject. You can then query for a given object using Sim::findObject() (or SimSet::findObject() if you want to search only a specific set).

// Three examples of registering an object.
// Method 1:
AIClient *aiPlayer = new AIClient();
aiPlayer->registerObject();
// Method 2:
ActionMap* globalMap = new ActionMap;
globalMap->registerObject("GlobalActionMap");
// Method 3:
bool reg = mObj->registerObject(id);
Definition actionMap.h:50
bool registerObject()
Definition simObject.cc:94

Registering a SimObject performs these tasks:

  • Marks the object as not cleared and not removed.
  • Assigns the object a unique SimObjectID if it does not have one already.
  • Adds the object to the global name and ID dictionaries so it can be found again.
  • Calls the object's onAdd() method. Note: SimObject::onAdd() performs some important initialization steps. See here for details on how to properly subclass SimObject.
  • If onAdd() fails (returns false), it calls unregisterObject().
  • Checks to make sure that the SimObject was properly initialized (and asserts if not).

Calling registerObject() and passing an ID or a name will cause the object to be assigned that name and/or ID before it is registered.

Congratulations, you have now registered your object! What now?

Well, hopefully, the SimObject will have a long, useful life. But eventually, it must die.

There are a two ways a SimObject can die.

  • First, the game can be shut down. This causes the root SimGroup to be unregistered and deleted. When a SimGroup is unregistered, it unregisters all of its member SimObjects; this results in everything that has been registered with Sim being unregistered, as everything registered with Sim is in the root group.
  • Second, you can manually kill it off, either by calling unregisterObject() or by calling deleteObject().

When you unregister a SimObject, the following tasks are performed:

  • The object is flagged as removed.
  • Notifications are cleaned up.
  • If the object is in a group, then it removes itself from the group.
  • Delete notifications are sent out.
  • Finally, the object removes itself from the Sim globals, and tells Sim to get rid of any pending events for it.

If you call deleteObject(), all of the above tasks are performed, in addition to some sanity checking to make sure the object was previously added properly, and isn't in the process of being deleted. After the object is unregistered, it de-allocates itself.

Torque Editors

SimObjects are one of the building blocks for the in-game editors. They provide a basic interface for the editor to be able to list the fields of the object, update them safely and reliably, and inform the object things have changed.

This interface is implemented in the following areas:

  • onNameChange() is called when the object is renamed.
  • onStaticModified() is called whenever a static field is modified.
  • inspectPreApply() is called before the object's fields are updated, when changes are being applied.
  • inspectPostApply() is called after the object's fields are updated.
  • onEditorEnable() is called whenever an editor is enabled (for instance, when you hit F11 to bring up the world editor).
  • onEditorDisable() is called whenever the editor is disabled (for instance, when you hit F11 again to close the world editor).

(Note: you can check the variable gEditingMission to see if the mission editor is running; if so, you may want to render special indicators. For instance, the fxFoliageReplicator renders inner and outer radii when the mission editor is running.)

The Console

SimObject extends ConsoleObject by allowing you to to set arbitrary dynamic fields on the object, as well as statically defined fields. This is done through two methods, setDataField and getDataField, which deal with the complexities of allowing access to two different types of object fields.

Static fields take priority over dynamic fields. This is to be expected, as the role of dynamic fields is to allow data to be stored in addition to the predefined fields.

The fields in a SimObject are like properties (or fields) in a class.

Some fields may be arrays, which is what the array parameter is for; if it's non-null, then it is parsed with dAtoI and used as an index into the array. If you access something as an array which isn't, then you get an empty string.

You don't need to read any further than this. Right now, set/getDataField are called a total of 6 times through the entire Torque codebase. Therefore, you probably don't need to be familiar with the details of accessing them. You may want to look at Con::setData instead. Most of the time you will probably be accessing fields directly, or using the scripting language, which in either case means you don't need to do anything special.

The functions to get/set these fields are very straightforward:

setDataField(StringTable->insert("locked", false), NULL, b ? "true" : "false" );
curObject->setDataField(curField, curFieldArray, STR.getStringValue());
setDataField(slotName, array, value);
virtual void setDataField(StringTableEntry slotName, const char *array, const char *value)
Definition simObject.cc:560

For advanced users: There are two flags which control the behavior of these functions. The first is ModStaticFields, which controls whether or not the DataField functions look through the static fields (defined with addField; see ConsoleObject for details) of the class. The second is ModDynamicFields, which controls dynamically defined fields. They are set automatically by the console constructor code.

Member Enumeration Documentation

◆ CopyFieldsFlags

What copyFieldsFrom may be told to leave alone.

Enumerator
CopyFields_SkipName 

Two objects answering to one name is a bug.

CopyFields_SkipParentGroup 

Writing it ADDS the object to that group.

CopyFields_SkipScriptClass 

class and superclass, which link namespaces.

◆ WriteFlags

enum WriteFlags
Enumerator
SelectedOnly 

Passed to SimObject::write to indicate that only objects

Constructor & Destructor Documentation

◆ SimObject()

SimObject ( )

◆ ~SimObject()

~SimObject ( )
virtual

Member Function Documentation

◆ addFieldFilter()

void addFieldFilter ( const char * fieldName)

◆ addListener()

void addListener ( std::string objID)

◆ addToSet() [1/2]

bool addToSet ( const char * ObjectName)

◆ addToSet() [2/2]

bool addToSet ( SimObjectId spid)

◆ allocClone()

SimObject * allocClone ( )
protectedvirtual

A registered but empty object of this object's class.

The three phases of a deep clone, separated because a child has to be added to its new parent BEFORE its fields are written: a container that places its own children takes what it wants from a child as it arrives (a GuiChainCtrl zeroes the position, a GuiGridCtrl forces the sizing off center), and doing that after the values were copied would undo them.

◆ allocNotify()

SimObject::Notify * allocNotify ( )
staticprotected

Get a free Notify structure.

◆ assignDynamicFieldsFrom()

void assignDynamicFieldsFrom ( SimObject * obj)

Copy dynamic fields from another object onto this one.

Everything from obj will overwrite what's in this object.

Parameters
objObject to copy from.

◆ assignFieldsFrom()

void assignFieldsFrom ( SimObject * obj)

Copy fields from another object onto this one.

Objects must be of same type. Everything from obj will overwrite what's in this object; extra fields in this object will remain. This includes dynamic fields.

Parameters
objObject to copy from.

◆ assignName()

void assignName ( const char * name)

◆ buildFilterList()

void buildFilterList ( )
virtual

◆ clearAllNotifications()

void clearAllNotifications ( )

Remove all notifications for this object.

◆ clearDynamicFields()

void clearDynamicFields ( void )
inline

Clear all dynamic fields.

◆ clearFieldFilters()

void clearFieldFilters ( )

◆ clearNotify()

void clearNotify ( SimObject * obj)

Notify an object when we are cleared.

◆ clone()

SimObject * clone ( const bool copyDynamicFields)

◆ cloneInto()

void cloneInto ( SimObject * clone)
protected

Fill in a shell from allocClone: fields, then children, then the class.

copyTo runs LAST, and that is the whole reason a deep clone is inert. It is what sets mClassName/mSuperClassName and links the namespaces, and until it has run the clone's script class is invisible: registerObject fires script onAdd (simObject.cc) and GuiControl::onChildAdded fires script onChildAdded (guiControl.cc), and neither can find a method on a namespace that is not linked yet. So a class whose onAdd builds children cannot build a second set of them on top of the ones being copied.

◆ copyFieldsFrom()

void copyFieldsFrom ( SimObject * obj,
const U32 flags )

assignFieldsFrom, with the option of leaving some fields out.

Every persist field is a field, including the two that decide where the object lives and what it is called - so a copy that wants to be a copy rather than a second reference to the same place has to say so.

Parameters
objObject to copy from; must be of the same class.
flagsCopyFieldsFlags, or 0 for everything.

◆ copyTo()

◆ DECLARE_CONOBJECT()

DECLARE_CONOBJECT ( SimObject )

◆ deepClone()

SimObject * deepClone ( )

Copy this object, everything in it, and everything below it.

Unlike clone(), which makes a shell of the right class and leaves the fields to the caller, a deep clone is finished when it returns: fields, dynamic fields and the whole child tree, with each child a new object of its own. The name and the parent group are deliberately not copied - the clone is nameless and belongs to nothing until someone adds it.

No script lifecycle callback fires on a deep clone. See cloneInto.

◆ deepCloneChildren()

virtual void deepCloneChildren ( SimObject * clone)
inlineprotectedvirtual

Copy this object's children into clone. Nothing to do here; SimGroup, which is where owned children live, does the work.

Reimplemented in GuiDropDownCtrl, GuiFrameSetCtrl, GuiListBoxCtrl, and SimGroup.

◆ deleteNotify()

void deleteNotify ( SimObject * obj)

Notify an object when we are deleted.

◆ deleteObject()

void deleteObject ( )

Unregister, mark as deleted, and free the object.

◆ dump()

void dump ( )
virtual

◆ dumpClassHierarchy()

void dumpClassHierarchy ( )
virtual

◆ findObject()

SimObject * findObject ( const char * name)
virtual

Find a named sub-object of this object.

This is subclassed in the SimGroup and SimSet classes.

For a single object, it just returns NULL, as normal objects cannot have children.

Reimplemented in SceneObjectSet, SimGroup, and SimSet.

◆ freeNotify()

void freeNotify ( SimObject::Notify * note)
staticprotected

Mark a Notify structure as free.

◆ getCanSaveDynamicFields()

bool getCanSaveDynamicFields ( void ) const
inline

Get whether fields created at runtime should be saved. Default is true.

◆ getClassNamespace()

StringTableEntry getClassNamespace ( ) const
inline

◆ getDataField()

const char * getDataField ( StringTableEntry slotName,
const char * array )

◆ getDataFieldPrefix()

StringTableEntry getDataFieldPrefix ( StringTableEntry fieldName)

◆ getDataFieldType()

U32 getDataFieldType ( StringTableEntry slotName,
const char * array )

Get the type of a field on the object.

Parameters
slotNameField to access.
arrayString containing index into array (if field is an array); if NULL, it is ignored.

◆ getFieldDictionary()

SimFieldDictionary * getFieldDictionary ( )
inline

Get reference to the dictionary containing dynamic fields.

See here for a detailed discussion of what this function does.

This dictionary can be iterated over using a SimFieldDictionaryIterator.

◆ getGroup()

SimGroup * getGroup ( ) const
inline

◆ getId()

SimObjectId getId ( void ) const
inline

◆ getIdString()

StringTableEntry getIdString ( void ) const
inline

◆ getInternalName()

StringTableEntry getInternalName ( )

Get the internal of of this control.

◆ getName()

const StringTableEntry getName ( void ) const

◆ getNamespace()

Namespace * getNamespace ( )
inline

Return the object's namespace.

◆ getPeriodicTimerID()

S32 getPeriodicTimerID ( void ) const
inline

◆ getPrefixedDataField()

const char * getPrefixedDataField ( StringTableEntry fieldName,
const char * array )

◆ getPrefixedDynamicDataField()

const char * getPrefixedDynamicDataField ( StringTableEntry fieldName,
const char * array,
const S32 fieldType = -1 )

◆ getProgenitorFile()

StringTableEntry getProgenitorFile ( void ) const
inline

◆ getProtectedName()

const char * getProtectedName ( void * obj,
const char * data )
staticprotected

◆ getScriptCallbackGuard()

S32 getScriptCallbackGuard ( void )
inline

◆ getSuperClassNamespace()

StringTableEntry getSuperClassNamespace ( ) const
inline

◆ getType()

U32 getType ( ) const
inline

◆ handlesConsoleMethod()

virtual bool handlesConsoleMethod ( const char * fname,
S32 * routingId )
inlinevirtual

◆ initPersistFields()

void initPersistFields ( )
static

◆ inspectPostApply()

void inspectPostApply ( )
virtual

Called after any property of the object is changed in the world editor.

See also
inspectPreApply

Reimplemented in GuiChainCtrl, GuiControl, GuiFrameSetCtrl, GuiGridCtrl, GuiInspector, GuiMenuBarCtrl, GuiMenuItemCtrl, GuiMessageVectorCtrl, GuiSceneObjectCtrl, GuiScrollCtrl, and GuiTextEditCtrl.

◆ inspectPreApply()

void inspectPreApply ( )
virtual

Specifically, this is called by setDataField when a static field is modified, see the console details. Called before any property of the object is changed in the world editor.

The calling order here is:

Reimplemented in GuiChainCtrl, and GuiControl.

◆ isChildOfGroup()

bool isChildOfGroup ( SimGroup * pGroup)

◆ isDeleted()

bool isDeleted ( ) const
inline

◆ isExpanded()

bool isExpanded ( ) const
inline

◆ isFiltered()

bool isFiltered ( const char * fieldName)

◆ isHidden()

bool isHidden ( ) const
inline

◆ isLocked()

bool isLocked ( ) const
inline

◆ isMethod()

bool isMethod ( const char * methodName)
virtual

Check if a method exists in the objects current namespace.

◆ isPeriodicTimerActive()

bool isPeriodicTimerActive ( void ) const
inline

◆ isProperlyAdded()

bool isProperlyAdded ( ) const
inline

◆ isRemoved()

bool isRemoved ( ) const
inline

◆ isSelected()

bool isSelected ( ) const
inline

◆ isType()

template<typename T>
bool isType ( void )
inline

◆ linkNamespaces()

void linkNamespaces ( )
protected

◆ onAdd()

◆ onDeleteNotify()

void onDeleteNotify ( SimObject * object)
virtual

Called when a SimObject is deleted.

When you are on the notification list for another object and it is deleted, this method is called.

Reimplemented in BehaviorComponent, GuiBorderProfile, GuiControlProfile, GuiCursor, GuiEditorCursorCtrl, GuiProfileTheme, ModuleManager, ParticleAsset, Path, Scene, SceneObjectSet, SimSet, and UInputManager.

◆ onEditorDisable()

virtual void onEditorDisable ( )
inlinevirtual

Called when the editor is deactivated.

◆ onEditorEnable()

virtual void onEditorEnable ( )
inlinevirtual

Called when the editor is activated.

◆ onGroupAdd()

void onGroupAdd ( )
virtual

Called when the object is added to a SimGroup.

◆ onGroupRemove()

void onGroupRemove ( )
virtual

Called when the object is removed from a SimGroup.

Reimplemented in GuiControl.

◆ onNameChange()

void onNameChange ( const char * name)
virtual

Called when the object's name is changed.

◆ onRemove()

◆ onStaticModified()

void onStaticModified ( const char * slotName,
const char * newValue = NULL )
virtual

Called when a static field is modified.

Reimplemented in GuiBorderProfile, GuiControlProfile, GuiCursor, GuiEditorCursorCtrl, GuiProfileTheme, and SimDataBlock.

◆ onTamlAddParent()

virtual void onTamlAddParent ( SimObject * pParentObject)
inlineprotectedvirtual

Called after Taml has finished reading the object and has added the object to any parent.

Implements TamlCallbacks.

Reimplemented in ParticlePlayer.

◆ onTamlCustomRead()

virtual void onTamlCustomRead ( const TamlCustomNodes & customNodes)
inlineprotectedvirtual

Called during the reading of the object to allow custom properties to be read.

Implements TamlCallbacks.

Reimplemented in AssetQuery, AssetTagsManifest, BehaviorComponent, CompositeSprite, FontAsset, GuiDropDownCtrl, GuiFrameSetCtrl, GuiListBoxCtrl, ImageAsset, ParticleAsset, ParticleAssetEmitter, Scene, and SceneObject.

◆ onTamlCustomWrite()

virtual void onTamlCustomWrite ( TamlCustomNodes & customNodes)
inlineprotectedvirtual

Called during the writing of the object to allow custom properties to be written.

Implements TamlCallbacks.

Reimplemented in AssetQuery, AssetTagsManifest, BehaviorComponent, CompositeSprite, FontAsset, GuiDropDownCtrl, GuiFrameSetCtrl, GuiListBoxCtrl, ImageAsset, ParticleAsset, ParticleAssetEmitter, Scene, and SceneObject.

◆ onTamlPostRead()

virtual void onTamlPostRead ( const TamlCustomNodes & customNodes)
inlineprotectedvirtual

Called after Taml has finished reading the object. The custom properties is additionally passed here for object who want to process it at the end of reading.

Implements TamlCallbacks.

Reimplemented in GuiProfileTheme, and Scene.

◆ onTamlPostWrite()

virtual void onTamlPostWrite ( void )
inlineprotectedvirtual

Called after Taml has finished writing the object.

Implements TamlCallbacks.

Reimplemented in AudioAsset, FontAsset, and ImageAsset.

◆ onTamlPreRead()

virtual void onTamlPreRead ( void )
inlineprotectedvirtual

Called prior to Taml reading the object.

Implements TamlCallbacks.

Reimplemented in GuiProfileTheme, and Scene.

◆ onTamlPreWrite()

virtual void onTamlPreWrite ( void )
inlineprotectedvirtual

Taml callbacks.

Implements TamlCallbacks.

Reimplemented in AudioAsset, FontAsset, and ImageAsset.

◆ popScriptCallbackGuard()

void popScriptCallbackGuard ( void )
inline

◆ postEvent()

void postEvent ( std::string eventName,
std::string data )

◆ processArguments()

bool processArguments ( S32 argc,
const char ** argv )
virtual

Process constructor options. (ie, new SimObject(1,2,3)).

Reimplemented in ConsoleLogger, SimComponent, SimGroup, SimXMLDocument, and TCPObject.

◆ processDeleteNotifies()

void processDeleteNotifies ( )

Send out deletion notifications.

◆ pushScriptCallbackGuard()

void pushScriptCallbackGuard ( void )
inline

◆ readObject()

bool readObject ( Stream * stream)
virtual

Reimplemented in SimSet.

◆ registerObject() [1/4]

bool registerObject ( )

Register an object with the object system.

This must be called if you want to keep the object around. In the rare case that you will delete the object immediately, or don't want to be able to use Sim::findObject to locate it, then you don't need to register it.

registerObject adds the object to the global ID and name dictionaries, after first assigning it a new ID number. It calls onAdd(). If onAdd fails, it unregisters the object and returns false.

If a subclass's onAdd doesn't eventually call SimObject::onAdd(), it will cause an assertion.

◆ registerObject() [2/4]

bool registerObject ( const char * name)

Register the object, assigning the name.

See also
registerObject()
Parameters
nameName to assign to the object.

◆ registerObject() [3/4]

bool registerObject ( const char * name,
U32 id )

Register the object, assigning a name and ID.

See also
registerObject()
Parameters
nameName to assign to the object.
idID to assign to the object.

◆ registerObject() [4/4]

bool registerObject ( U32 id)

Register the object, forcing the id.

See also
registerObject()
Parameters
idID to assign to the object.

◆ registerReference()

void registerReference ( SimObject ** obj)

Register a reference to this object.

You pass a pointer to your reference to this object.

When the object is deleted, it will null your pointer, ensuring you don't access old memory.

Parameters
objPointer to your reference to the object.

◆ removeAllListeners()

void removeAllListeners ( )

◆ removeFieldFilter()

void removeFieldFilter ( const char * fieldName)

◆ removeFromSet() [1/2]

bool removeFromSet ( const char * objectName)

◆ removeFromSet() [2/2]

bool removeFromSet ( SimObjectId sid)

◆ removeListener()

void removeListener ( std::string objID)

◆ removeNotify()

SimObject::Notify * removeNotify ( void * ptr,
Notify::Type type )

Remove a notification from the list.

◆ save()

bool save ( const char * pcFilePath,
bool bOnlySelected = false )
virtual

Save object as a TorqueScript File.

◆ setCanSaveDynamicFields()

void setCanSaveDynamicFields ( bool bCanSave)
inline

Set whether fields created at runtime should be saved. Default is true.

◆ setClass()

bool setClass ( void * obj,
const char * data )
inlinestaticprotected

◆ setClassNamespace()

void setClassNamespace ( const char * classNamespace)

◆ setDataField()

void setDataField ( StringTableEntry slotName,
const char * array,
const char * value )
virtual

Set the value of a field on the object.

See here for a detailed discussion of what this function does.

Parameters
slotNameField to access.
arrayString containing index into array; if NULL, it is ignored.
valueValue to store.

Reimplemented in GuiControl.

◆ setExpanded()

void setExpanded ( bool exp)
inline

◆ setHidden()

void setHidden ( bool b = true)

◆ setId()

void setId ( SimObjectId id)

◆ setInternalName()

void setInternalName ( const char * newname)

These functions support internal naming that is not namespace bound for locating child controls in a generic way.

Set the internal name of this control (Not linked to a namespace)

◆ setLocked()

void setLocked ( bool b = true)

◆ setModDynamicFields()

void setModDynamicFields ( bool dyn)
inline

◆ setModStaticFields()

void setModStaticFields ( bool sta)
inline

◆ setParentGroup()

bool setParentGroup ( void * obj,
const char * data )
staticprotected

◆ setPeriodicTimerID()

void setPeriodicTimerID ( const S32 timerID)
inline

◆ setPrefixedDataField()

void setPrefixedDataField ( StringTableEntry fieldName,
const char * array,
const char * value )

◆ setPrefixedDynamicDataField()

void setPrefixedDynamicDataField ( StringTableEntry fieldName,
const char * array,
const char * value,
const S32 fieldType = -1 )

◆ setProgenitorFile()

void setProgenitorFile ( const char * pFile)
inline

◆ setProtectedName()

bool setProtectedName ( void * obj,
const char * data )
staticprotected

◆ setSelected()

void setSelected ( bool sel)
inline

◆ setSuperClass()

bool setSuperClass ( void * obj,
const char * data )
inlinestaticprotected

◆ setSuperClassNamespace()

void setSuperClassNamespace ( const char * superClassNamespace)

◆ tabComplete()

const char * tabComplete ( const char * prevText,
S32 baseLen,
bool fForward )

Get next matching item in namespace.

This wraps a call to Namespace::tabComplete; it gets the next thing in the namespace, given a starting value and a base length of the string. See Namespace::tabComplete for details.

◆ unlinkNamespaces()

void unlinkNamespaces ( )
protected

◆ unregisterObject()

void unregisterObject ( )

Unregister the object from Sim.

This performs several operations:

  • Sets the removed flag.
  • Call onRemove()
  • Clear out notifications.
  • Remove the object from...
  • Finally, cancel any pending events for this object (as it can't receive them now).

◆ unregisterReference()

void unregisterReference ( SimObject ** obj)

Unregister a reference to this object.

Remove a reference from the list, so that it won't get nulled inappropriately.

Call this when you're done with your reference to the object, especially if you're going to free the memory. Otherwise, you may erroneously get something overwritten.

See also
registerReference

◆ write()

void write ( Stream & stream,
U32 tabStop,
U32 flags = 0 )
virtual

Output the TorqueScript to recreate this object.

This calls writeFields internally.

Parameters
streamStream to output to.
tabStopIndentation level for this object.
flagsIf SelectedOnly is passed here, then only objects marked as selected (using setSelected) will output themselves.

Reimplemented in BehaviorComponent, GuiControl, NameTags, SimComponent, and SimSet.

◆ writeCanSaveDynamicFields()

bool writeCanSaveDynamicFields ( void * obj,
StringTableEntry pFieldName )
inlinestaticprotected

◆ writeClass()

bool writeClass ( void * obj,
StringTableEntry pFieldName )
inlinestaticprotected

◆ writeField()

bool writeField ( StringTableEntry fieldname,
const char * value )
virtual

Determine whether or not a field should be written.

Parameters
fieldnameThe name of the field being written.
valueThe value of the field.

Reimplemented in GuiBorderProfile, GuiControlProfile, GuiCursor, SceneObject, and SimComponent.

◆ writeFields()

void writeFields ( Stream & stream,
U32 tabStop )
virtual

Write the fields of this object in TorqueScript.

Parameters
streamStream for output.
tabStopIndentation level for the fields.

Reimplemented in GuiFrameSetCtrl, and NameTags.

◆ writeInternalName()

bool writeInternalName ( void * obj,
StringTableEntry pFieldName )
inlinestaticprotected

◆ writeObject()

bool writeObject ( Stream * stream)
virtual

Reimplemented in SimSet.

◆ writeObjectName()

bool writeObjectName ( void * obj,
StringTableEntry pFieldName )
inlinestaticprotected

◆ writeParentGroup()

bool writeParentGroup ( void * obj,
StringTableEntry pFieldName )
inlinestaticprotected

◆ writeSuperclass()

bool writeSuperclass ( void * obj,
StringTableEntry pFieldName )
inlinestaticprotected

◆ SimGroup

friend class SimGroup
friend

◆ SimIdDictionary

friend class SimIdDictionary
friend

◆ SimManager

friend class SimManager
friend

◆ SimManagerNameDictionary

friend class SimManagerNameDictionary
friend

◆ SimNameDictionary

friend class SimNameDictionary
friend

Member Data Documentation

◆ disableNameChanging

bool disableNameChanging = false
static

Get the value of a field on the object.

See here for a detailed discussion of what this function does.

Parameters
slotNameField to access.
arrayString containing index into array (if field is an array); if NULL, it is ignored.

◆ mCanSaveFieldDictionary

bool mCanSaveFieldDictionary
protected

true if dynamic fields (added at runtime) should be saved, defaults to true

◆ mClassName

StringTableEntry mClassName
protected

Stores the class name to link script class namespaces.

◆ mId

SimObjectId mId
protected

Id number for this object.

◆ mIdString

StringTableEntry mIdString
protected

◆ mInternalName

StringTableEntry mInternalName
protected

Stores object Internal Name.

◆ mNameSpace

Namespace* mNameSpace
protected

◆ mNotifyFreeList

SimObject::Notify * mNotifyFreeList = NULL
staticprotected

◆ mScriptCallbackGuard

S32 mScriptCallbackGuard
protected

Whether the object is executing a script callback.

◆ mSuperClassName

StringTableEntry mSuperClassName
protected

Stores super class name to link script class namespaces.

◆ mTypeMask

U32 mTypeMask
protected

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