SimObject
Engine/source/console/simObject.h
Base class for objects involved in the simulation.
Classes:
Serialization
bool
writeField(StringTableEntry fieldname, const char * value)
Determine whether or not a field should be written.
writeFields(Stream & stream, U32 tabStop)
Write the fields of this object in TorqueScript.
bool
writeObject(Stream * stream)
bool
readObject(Stream * stream)
setCanSaveDynamicFields(bool bCanSave)
Set whether fields created at runtime should be saved. Default is true.
bool
Get whether fields created at runtime should be saved. Default is true.
Return the object that this object is copying fields from.
setCopySource(SimObject * object)
Set the object that this object should be copying fields from.
assignFieldsFrom(SimObject * obj)
Copy fields from another object onto this one.
assignDynamicFieldsFrom(SimObject * obj)
Copy dynamic fields from another object onto this one.
The line number that the object was declared on if it was loaded from a file.
bool
Whether dynamic fields should be saved out in serialization. Defaults to true.
Notification
Get a free Notify structure.
Mark a Notify structure as free.
Notify *
removeNotify(void * ptr, Notify::Type )
Remove a notification from the list.
deleteNotify(SimObject * obj)
Notify an object when we are deleted.
clearNotify(SimObject * obj)
Notify an object when we are cleared.
Remove all notifications for this object.
Send out deletion notifications.
registerReference(SimObject ** obj)
Register a reference to this object.
unregisterReference(SimObject ** obj)
Unregister a reference to this object.
Notify *
List of notifications added to this object.
Persistent IDs
Return the persistent ID assigned to this object or NULL.
Return the persistent ID assigned to this object or assign one to it if it has none.
bool
_setPersistentID(void * object, const char * index, const char * data)
Persistent ID assigned to this object.
Namespace management
Return name of class namespace set on this object.
Return name of superclass namespace set on this object.
setClassNamespace(const char * classNamespace)
setSuperClassNamespace(const char * superClassNamespace)
Perform namespace linking on this object.
Undo namespace linking on this object.
The namespace in which method lookup for this object begins.
Name of namespace to use as class namespace.
Name of namespace to use as class super namespace.
Cloning
Accessors
const char *
getDataField(StringTableEntry slotName, const char * array)
Get the value of a field on the object.
setDataField(StringTableEntry slotName, const char * array, const char * value)
Set the value of a field on the object.
const char *
getPrefixedDataField(StringTableEntry fieldName, const char * array)
setPrefixedDataField(StringTableEntry fieldName, const char * array, const char * value)
const char *
getPrefixedDynamicDataField(StringTableEntry fieldName, const char * array, const S32 fieldType)
setPrefixedDynamicDataField(StringTableEntry fieldName, const char * array, const char * value, const S32 fieldType)
getDataFieldPrefix(StringTableEntry fieldName)
getDataFieldType(StringTableEntry slotName, const char * array)
Get the type of a field on the object.
setDataFieldType(const U32 fieldTypeId, StringTableEntry slotName, const char * array)
Set the type of a dynamic field on the object.
setDataFieldType(const char * typeName, StringTableEntry slotName, const char * array)
Get reference to the dictionary containing dynamic fields.
setInternalName(const char * newname)
These functions support internal naming that is not namespace bound for locating child controls in a generic way.
Get the internal name of this control.
setOriginalName(const char * originalName)
Set the original name of this control.
Get the original name of this control.
setFilename(const char * file)
These functions allow you to set and access the filename where this object was created.
Get the filename.
setDeclarationLine(U32 lineNumber)
These functions are used to track the line number (1-based) on which the object was created if it was loaded from script.
Get the declaration line number.
bool
bool
getId()
Return the unique numeric object ID.
const char *
Return the object ID as a string.
getName()
Return the name of this object.
assignName(const char * name)
Assign the given name to this object.
setId(SimObjectId id)
bool
isChildOfGroup(SimGroup * pGroup)
bool
bool
bool
bool
isLocked()
bool
isHidden()
bool
bool
bool
bool
bool
setSelected(bool sel)
setExpanded(bool exp)
setModDynamicFields(bool dyn)
setModStaticFields(bool sta)
bool
bool
setAutoDelete(bool val)
setEditorOnly(bool val)
setNameChangeAllowed(bool val)
bool
Returns boolean specifying if the object can be serialized.
setCanSave(bool val)
Set serialization flag.
bool
Returns true if this object is selected or any group it is a member of is.
Force an Id on the next registered object.
Initialization
bool
processArguments(S32 argc, ConsoleValueRef * argv)
Process constructor options. (ie, new SimObject(1,2,3))
Events
bool
onAdd()
Called when the object is added to the sim.
Called when the object is added to a SimGroup.
Called when the object is removed from a SimGroup.
onNameChange(const char * name)
Called when the object's name is changed.
Called when the adding of the object to the sim is complete, all sub-objects have been processed as well.
onStaticModified(const char * slotName, const char * newValue)
Specifically, these are called by setDataField when a static or dynamic field is modified, see the console details.
onDynamicModified(const char * slotName, const char * newValue)
Called when a dynamic field is modified.
Called before any property of the object is changed in the world editor.
Called after any property of the object is changed in the world editor.
onDeleteNotify(SimObject * object)
Called when a SimObject is deleted.
Called when the editor is activated.
Called when the editor is deactivated.
Called when the object is inspected via a GuiInspector control.
Registration
SimObjects must be registered with the object system.
bool
Register an object with the object system.
bool
registerObject(U32 id)
Register the object, forcing the id.
bool
registerObject(const char * name)
Register the object, assigning the name.
bool
registerObject(const char * name, U32 id)
Register the object, assigning a name and ID.
Unregister the object from Sim.
Unregister, mark as deleted, and free the object.
Performs a safe delayed delete of the object using a sim event.
Special-case deletion behaviors, largely intended for cleanup in particular cases where it wouldn't happen automatically(like cleanup of associated files)
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.
Debugging
Return a textual description of the object.
dumpToConsole(bool includeFunctions)
Dump the contents of this object to the console.
added this so that you can print the entire class hierarchy, including script objects,
Print the SimGroup hierarchy of this object to the console.
Public Types
WriteFlags { SelectedOnly = BIT( 0 ) NoName = BIT( 1 ) IgnoreCanSave = BIT( 2 ) }
Flags passed to SimObject::write.
Parent
Private Types
_Anonymous_ { Deleted = BIT( 0 ) Removed = BIT( 1 ) Added = BIT( 3 ) Selected = BIT( 4 ) Expanded = BIT( 5 ) ModStaticFields = BIT( 6 ) ModDynamicFields = BIT( 7 ) AutoDelete = BIT( 8 ) CannotSave = BIT( 9 ) EditorOnly = BIT( 10 ) NoNameChange = BIT( 11 ) Hidden = BIT( 12 ) Locked = BIT( 13 ) }
Flags for use in mFlags.
Public Friends
class
class
class
class
class
Private Attributes
Object we are copying fields from.
Table of dynamic fields assigned to this object.
char
mIdString [11]
Buffer to store textual representation of this object's numeric ID in.
Protected Attributes
bool
Id number for this object.
Internal name assigned to the object. Not set by default.
return
Protected Static Attributes
The Id to force upon the object. Poor object.
bool
Force a registered object to use the given Id. Cleared upon use.
Public Static Attributes
bool
Private Static Functions
const char *
_getCanSave(void * object, const char * data)
const char *
_getHidden(void * object, const char * data)
const char *
_getLocked(void * object, const char * data)
bool
_setCanSave(void * object, const char * index, const char * data)
bool
_setHidden(void * object, const char * index, const char * data)
bool
_setLocked(void * object, const char * index, const char * data)
bool
setParentGroup(void * obj, const char * data)
bool
setProtectedName(void * object, const char * index, const char * data)
bool
setProtectedParent(void * object, const char * index, const char * data)
bool
setSuperClass(void * object, const char * index, const char * data)
bool
writeCanSaveDynamicFields(void * obj, StringTableEntry pFieldName)
bool
writeClass(void * obj, StringTableEntry pFieldName)
bool
writeClassName(void * obj, StringTableEntry pFieldName)
bool
writeInternalName(void * obj, StringTableEntry pFieldName)
bool
writeObjectName(void * obj, StringTableEntry pFieldName)
bool
writeParentGroup(void * obj, StringTableEntry pFieldName)
bool
writeSuperclass(void * obj, StringTableEntry pFieldName)
Public Functions
bool
assignDynamicFieldsFrom(SimObject * , const char * filter, bool no_replace)
DECLARE_CALLBACK(void , onInspectPostApply , (SimObject *obj) )
object destroy self call (from StrongRefPtr). Override if this class has specially allocated memory.
findObject(const char * name)
Find a named sub-object of this object.
Return the object's namespace.
bool
handlesConsoleMethod(const char * fname, S32 * routingId)
bool
setProgenitorFile(const char * pFile)
const char *
tabComplete(const char * prevText, S32 baseLen, bool )
Get next matching item in namespace.
Protected Functions
Subclasses should overload this method instead of the public destroySelf().
_getLogMessage(const char * fmt, va_list args)
We can provide more detail, like object name and id.
Called when the object is selected in the editor.
Called when the object is unselected in the editor.
onTamlAddParent(SimObject * pParentObject)
Called after Taml has finished reading the object and has added the object to any parent.
onTamlCustomRead(const TamlCustomNodes & customNodes)
Called during the reading of the object to allow custom properties to be read.
onTamlCustomWrite(TamlCustomNodes & customNodes)
Called during the writing of the object to allow custom properties to be written.
onTamlPostRead(const TamlCustomNodes & customNodes)
Called after Taml has finished reading the object.
Called after Taml has finished writing the object.
Called prior to Taml reading the object.
Taml callbacks.
Public Static Functions
__findObject(const char * id)
const char *
__getObjectId(ConsoleObject * object)
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:
The constructor/destructor.
onAdd()/onRemove()
onGroupAdd()/onGroupRemove()
onEditorEnable()/onEditorDisable()
inspectPreApply()/inspectPostApply()
things from ConsoleObject (see ConsoleObject docs for specifics)
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; ...
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);
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 deallocates 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 runnning.)
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);
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.
Serialization
writeField(StringTableEntry fieldname, const char * value)
Determine whether or not a field should be written.
Parameters:
fiedname | The name of the field being written. |
value | The value of the field. |
Reimplemented by: afxMagicSpellData, afxAnimClipData, DecalRoad, MeshRoad, River, Material, SceneObject, SceneZoneSpace, ConvexShape, ReflectionProbe, Portal, TSShapeConstructor, ScenePolyhedralObject, ScenePolyhedralObject
write(Stream & stream, U32 tabStop, U32 flags)
Output the TorqueScript to recreate this object.
This calls writeFields internally. Parameters:
stream | Stream to output to. |
tabStop | Indentation level for this object. |
flags | If SelectedOnly is passed here, then only objects marked as selected (using setSelected) will output themselves. |
Reimplemented by: GuiControl, NavMesh, SimDataBlock, SimPersistSet, SimSet
writeFields(Stream & stream, U32 tabStop)
Write the fields of this object in TorqueScript.
Parameters:
stream | Stream for output. |
tabStop | Indentation level for the fields. |
Reimplemented by: VPath, DecalRoad, MeshRoad, River, ScenePolyhedralObject, ScenePolyhedralObject, ConvexShape
writeObject(Stream * stream)
Reimplemented by: SimSet
readObject(Stream * stream)
Reimplemented by: SimSet
setCanSaveDynamicFields(bool bCanSave)
Set whether fields created at runtime should be saved. Default is true.
getCanSaveDynamicFields()
Get whether fields created at runtime should be saved. Default is true.
getCopySource()
Return the object that this object is copying fields from.
setCopySource(SimObject * object)
Set the object that this object should be copying fields from.
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:
obj | Object to copy from. |
assignDynamicFieldsFrom(SimObject * obj)
Copy dynamic fields from another object onto this one.
Everything from obj will overwrite what's in this object.
Parameters:
obj | Object to copy from. |
StringTableEntry mFilename
Path to file this SimObject was loaded from.
S32 mDeclarationLine
The line number that the object was declared on if it was loaded from a file.
bool mCanSaveFieldDictionary
Whether dynamic fields should be saved out in serialization. Defaults to true.
Notification
allocNotify()
Get a free Notify structure.
freeNotify(SimObject::Notify * )
Mark a Notify structure as free.
removeNotify(void * ptr, Notify::Type )
Remove a notification from the list.
deleteNotify(SimObject * obj)
Notify an object when we are deleted.
clearNotify(SimObject * obj)
Notify an object when we are cleared.
clearAllNotifications()
Remove all notifications for this object.
processDeleteNotifies()
Send out deletion notifications.
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:
obj | Pointer to your reference to the object. |
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.
Notify * mNotifyList
List of notifications added to this object.
SimObject::Notify * mNotifyFreeList
Persistent IDs
getPersistentId()
Return the persistent ID assigned to this object or NULL.
getOrCreatePersistentId()
Return the persistent ID assigned to this object or assign one to it if it has none.
_setPersistentID(void * object, const char * index, const char * data)
SimPersistID * mPersistentId
Persistent ID assigned to this object.
Allows to unambiguously refer to this object in serializations regardless of stream object ordering.
Namespace management
getClassNamespace()
Return name of class namespace set on this object.
getSuperClassNamespace()
Return name of superclass namespace set on this object.
setClassNamespace(const char * classNamespace)
setSuperClassNamespace(const char * superClassNamespace)
linkNamespaces()
Perform namespace linking on this object.
unlinkNamespaces()
Undo namespace linking on this object.
Namespace * mNameSpace
The namespace in which method lookup for this object begins.
StringTableEntry mClassName
Name of namespace to use as class namespace.
StringTableEntry mSuperClassName
Name of namespace to use as class super namespace.
Cloning
clone()
Return a shallow copy of this object.
Reimplemented by: SimSet, SimGroup
deepClone()
Return a deep copy of this object.
Reimplemented by: SimGroup
Accessors
getDataField(StringTableEntry slotName, const char * array)
Get the value of a field on the object.
See here for a detailed discussion of what this function does.
Parameters:
slotName | Field to access. |
array | String containing index into array (if field is an array); if NULL, it is ignored. |
setDataField(StringTableEntry slotName, const char * array, const char * value)
Set the value of a field on the object.
See here for a detailed discussion of what this function does.
Parameters:
slotName | Field to access. |
array | String containing index into array; if NULL, it is ignored. |
value | Value to store. |
getPrefixedDataField(StringTableEntry fieldName, const char * array)
setPrefixedDataField(StringTableEntry fieldName, const char * array, const char * value)
getPrefixedDynamicDataField(StringTableEntry fieldName, const char * array, const S32 fieldType)
setPrefixedDynamicDataField(StringTableEntry fieldName, const char * array, const char * value, const S32 fieldType)
getDataFieldPrefix(StringTableEntry fieldName)
getDataFieldType(StringTableEntry slotName, const char * array)
Get the type of a field on the object.
Parameters:
slotName | Field to access. |
array | String containing index into array (if field is an array); if NULL, it is ignored. |
setDataFieldType(const U32 fieldTypeId, StringTableEntry slotName, const char * array)
Set the type of a dynamic field on the object.
Parameters:
typeName/Id | Console base type name/id to assign to a dynamic field. |
slotName | Field to access. |
array | String containing index into array (if field is an array); if NULL, it is ignored. |
setDataFieldType(const char * typeName, StringTableEntry slotName, const char * array)
getFieldDictionary()
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.
getComponentName()
Reimplemented by: CubemapAsset
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)
getInternalName()
Get the internal name of this control.
setOriginalName(const char * originalName)
Set the original name of this control.
getOriginalName()
Get the original name of this control.
setFilename(const char * file)
These functions allow you to set and access the filename where this object was created.
Set the filename
getFilename()
Get the filename.
setDeclarationLine(U32 lineNumber)
These functions are used to track the line number (1-based) on which the object was created if it was loaded from script.
Set the declaration line number
getDeclarationLine()
Get the declaration line number.
save(const char * pcFilePath, bool bOnlySelected, const char * preappend)
Save object as a TorqueScript File.
isMethod(const char * methodName)
Check if a method exists in the objects current namespace.
isField(const char * fieldName, bool includeStatic, bool includeDynamic)
Return true if the field is defined on the object.
getId()
Return the unique numeric object ID.
getIdString()
Return the object ID as a string.
getName()
Return the name of this object.
getGroup()
Return the SimGroup that this object is contained in.
Never NULL except for RootGroup and unregistered objects.
assignName(const char * name)
Assign the given name to this object.
setId(SimObjectId id)
isChildOfGroup(SimGroup * pGroup)
isProperlyAdded()
isDeleted()
isRemoved()
isLocked()
setLocked(bool b)
isHidden()
Reimplemented by: GuiControl
setHidden(bool b)
Reimplemented by: SceneObject, WayPoint, ShapeBase, GuiControl
isSelected()
isExpanded()
isEditorOnly()
isNameChangeAllowed()
isAutoDeleted()
setSelected(bool sel)
setExpanded(bool exp)
setModDynamicFields(bool dyn)
setModStaticFields(bool sta)
canModDynamicFields()
canModStaticFields()
setAutoDelete(bool val)
setEditorOnly(bool val)
setNameChangeAllowed(bool val)
getCanSave()
Returns boolean specifying if the object can be serialized.
setCanSave(bool val)
Set serialization flag.
Reimplemented by: WorldEditorSelection
isSelectedRecursive()
Returns true if this object is selected or any group it is a member of is.
setForcedId(SimObjectId id)
Force an Id on the next registered object.
Initialization
SimObject()
~SimObject()
processArguments(S32 argc, ConsoleValueRef * argv)
Process constructor options. (ie, new SimObject(1,2,3))
Reimplemented by: TCPObject, ConsoleLogger, SimPersistSet, SimGroup, SimXMLDocument, WaterObject, GuiControl, SFXSource, SFXTrack
Events
onAdd()
Called when the object is added to the sim.
Reimplemented by: afxCamera, afxChoreographer, afxEffectronData, afxEffectron, afxEffectWrapperData, afxMagicMissileData, afxMagicMissile, afxMagicSpellData, afxMagicSpell, afxSelectronData, afxSelectron, afxSpellBook, afxAnimClipData, afxAnimLockData, afxAreaDamageData, afxAudioBank, afxBillboard, afxCameraPuppetData, afxCameraShakeData, afxConsoleMessageData, afxDamageData, afxGuiControllerData, afxGuiTextData, afxT3DLightBaseData, afxMachineGunData, afxModel, afxMooringData, afxMooring, afxParticleEmitterData, afxParticleEmitterVectorData, afxParticleEmitterConeData, afxParticleEmitterPathData, afxParticleEmitterDiscData, afxParticleEmitter, afxParticleEmitterPath, afxPhraseEffectData, afxPlayerMovementData, afxPlayerPuppetData, afxT3DPointLightData, afxProjectileData, afxProjectile, afxT3DSpotLightData, afxZodiacData, afxZodiacPlane, afxForceData, afxRPGMagicSpellData, afxGuiSubstitutionField, afxSpellButton, afxParticlePool, afxPathData, afxXM_MountedImageNodeData, afxXM_PathConformData, afxXM_RandomRotData, afxXM_SpinData, TCPObject, AssetManager, PersistenceManager, ScriptObject, ScriptTickObject, ScriptGroup, SimDataBlock, SimXMLDocument, FileStreamObject, StreamObject, BasicClouds, CloudLayer, DecalRoad, GuiMeshRoadEditorCtrl, GuiRiverEditorCtrl, GuiRoadEditorCtrl, MeshRoad, River, ScatterSky, SkyBox, Sun, TimeOfDay, VolumetricFog, WaterBlock, WaterObject, WaterPlane, ForestBrush, ForestBrushTool, ForestEditorCtrl, Forest, ForestItemData, ForestWindEmitter, TSForestItemData, CubemapData, GFXStateBlockData, GuiFrameSetCtrl, GuiRolloutCtrl, GuiSplitContainer, guiAnimBitmapCtrl, GuiGameListMenuCtrl, GuiGameListMenuProfile, GuiGameListOptionsCtrl, GuiGradientCtrl, GuiMLTextCtrl, GuiPopUpMenuCtrl, GuiPopUpMenuCtrlEx, GuiTextCtrl, GuiTextEditCtrl, GuiTreeViewCtrl, GuiCanvas, GuiControl, GuiOffscreenCanvas, GuiControlProfile, GuiEditCtrl, GuiInspectorTypeBitMask32, GuiInspectorCustomField, GuiInspectorDynamicField, GuiInspectorField, GuiInspectorGroup, GuiInspectorVariableField, PopupMenu, GuiMessageVectorCtrl, MessageVector, EditManager, EditTSCtrl, GizmoProfile, Gizmo, GuiConvexEditorCtrl, GuiDecalEditorCtrl, GuiMissionAreaCtrl, GuiMissionAreaEditorCtrl, GuiTerrPreviewCtrl, TerrainEditor, EditorTool, WorldEditor, CustomMaterial, Material, ShaderData, SimResponseCurve, ModuleManager, CoverPoint, GuiNavEditorCtrl, NavMesh, NavPath, Taml, LeapMotionFrame, OpenVROverlay, OpenVRTrackedObjectData, OpenVRTrackedObject, RazerHydraFrame, DInputManager, UInputManager, PostEffect, RenderFormatToken, RenderProbeMgr, RenderTexTargetBinManager, ScenePolyhedralObject, ScenePolyhedralObject, SceneObject, SceneSpace, SimPath::Path, Marker, ScenePolyhedralZone, SceneRootZone, SFXFMODEvent, SFXFMODEventGroup, SFXFMODProject, SFXAmbience, SFXDescription, SFXEnvironment, SFXParameter, SFXProfile, SFXSource, SFXState, SFXTrack, CustomShaderFeatureData, ActionMap, NetObject, SQLiteObject, AccumulationVolume, AIPlayer, AssetImportConfig, AssetImportObject, AssetImporter, Camera, ConvexShape, DebrisData, Debris, DecalData, RenderMeshExample, RenderObjectExample, RenderShapeExample, ExplosionData, Explosion, fxFoliageReplicator, fxShapeReplicator, GroundCover, LightningData, Lightning, ParticleData, ParticleEmitterData, ParticleEmitter, ParticleEmitterNodeData, ParticleEmitterNode, Precipitation, RibbonData, Ribbon, RibbonNode, SplashData, Splash, GameBaseData, GameBase, GameConnection, GameTSCtrl, GroundPlane, Item, LevelInfo, LightBase, LightDescription, BoxEnvironmentProbe, ReflectionProbe, Skylight, SphereEnvironmentProbe, MissionArea, MissionMarker, WayPoint, SpawnSphere, CameraBookmark, NotesObject, OcclusionVolume, PathCamera, PathShape, PhysicalZone, PhysicsDebrisData, PhysicsDebris, PhysicsForce, PhysicsShapeData, PhysicsShape, Player, Prefab, ProjectileData, Projectile, ProximityMine, RigidShapeData, RigidShape, Scene, SFXEmitter, ShapeBaseImageData, ShapeBase, StaticShape, TriggerData, Trigger, TSStatic, AITurretShapeData, AITurretShape, TurretShape, FlyingVehicle, HoverVehicleData, HoverVehicle, Vehicle, VehicleBlocker, WheeledVehicle, TerrainBlock, TerrainMaterial, TSShapeConstructor, Message, ScriptMsgListener, UndoScriptAction, GuiCursor, VEditorWindow, VActor, VPath, VPathEditor
onRemove()
Called when the object is removed from the sim.
Reimplemented by: afxCamera, afxChoreographer, afxMagicMissile, afxMagicSpell, afxSelectron, afxSpellBook, afxBillboard, afxModel, afxMooring, afxParticleEmitter, afxParticleEmitterPath, afxProjectile, afxZodiacPlane, afxParticlePool, afxPathData, AssetManager, FieldBrushObject, PersistenceManager, ScriptObject, ScriptTickObject, ScriptGroup, SimSet, SimGroup, SimXMLDocument, BasicClouds, CloudLayer, DecalRoad, MeshRoad, River, ScatterSky, SkyBox, Sun, TimeOfDay, VolumetricFog, VolumetricFogRTManager, WaterBlock, WaterObject, WaterPlane, ForestBrushTool, Forest, ForestWindEmitter, TSForestItemData, GuiTextListCtrl, GuiCanvas, GuiControl, GuiOffscreenCanvas, GuiCursor, GuiEditCtrl, GuiInspector, GuiMenuBar, PopupMenu, GuiMessageVectorCtrl, MessageVector, EditTSCtrl, Gizmo, GuiConvexEditorCtrl, EditorTool, CustomMaterial, Material, ShaderData, SimResponseCurve, ModuleManager, CoverPoint, NavMesh, NavPath, Taml, LeapMotionFrame, OpenVROverlay, OpenVRTrackedObject, RazerHydraFrame, DInputManager, UInputManager, PostEffect, RenderBinManager, RenderFormatToken, RenderProbeMgr, SceneObject, SceneSpace, SimPath::Path, Marker, SceneRootZone, SFXFMODEvent, SFXFMODEventGroup, SFXFMODProject, SFXParameter, SFXProfile, SFXSound, SFXSource, CustomShaderFeatureData, NetConnection, NetObject, SQLiteObject, AccumulationVolume, AIPlayer, AssetImportConfig, AssetImportObject, AssetImporter, Camera, ConvexShape, Debris, DecalData, RenderMeshExample, RenderObjectExample, RenderShapeExample, Explosion, fxFoliageReplicator, fxShapeReplicator, GroundCover, Lightning, ParticleEmitter, ParticleEmitterNode, Precipitation, Ribbon, RibbonNode, Splash, GameBase, GameConnection, GroundPlane, Item, LevelInfo, LightBase, BoxEnvironmentProbe, ReflectionProbe, Skylight, SphereEnvironmentProbe, MissionArea, MissionMarker, CameraBookmark, NotesObject, PathCamera, PathShape, PhysicalZone, PhysicsDebris, PhysicsForce, PhysicsShapeData, PhysicsShape, Player, Prefab, Projectile, ProximityMine, RigidShape, Scene, SFXEmitter, ShapeBase, StaticShape, Trigger, TSStatic, AITurretShape, TurretShape, FlyingVehicle, HoverVehicle, Vehicle, VehicleBlocker, WheeledVehicle, TerrainBlock, Message, ScriptMsgListener, UndoScriptAction, VActor, VPath
onGroupAdd()
Called when the object is added to a SimGroup.
Reimplemented by: Marker, SFXSource, CameraBookmark
onGroupRemove()
Called when the object is removed from a SimGroup.
Reimplemented by: GuiControl, CameraBookmark
onNameChange(const char * name)
Called when the object's name is changed.
Reimplemented by: ForestItemData
onPostAdd()
Called when the adding of the object to the sim is complete, all sub-objects have been processed as well.
Reimplemented by: Scene
onStaticModified(const char * slotName, const char * newValue)
Specifically, these are called by setDataField when a static or dynamic field is modified, see the console details.
Called when a static field is modified.
Reimplemented by: SkyBox, afxAnimClipData, afxZodiacData, afxSpellCastBar, afxPathData, SimDataBlock, DecalRoad, MeshRoad, River, WaterBlock, WaterPlane, GuiIconButtonCtrl, GuiTextEditCtrl, GuiControlProfile, DecalData, PhysicalZone, SFXEmitter, TSStatic, GuiObjectView
onDynamicModified(const char * slotName, const char * newValue)
Called when a dynamic field is modified.
Reimplemented by: TSStatic
inspectPreApply()
Called before any property of the object is changed in the world editor.
The calling order here is:
...
calls to setDataField()
...
Reimplemented by: GuiGradientCtrl, GuiControl
inspectPostApply()
Called after any property of the object is changed in the world editor.
Reimplemented by: afxSpellButton, BasicClouds, CloudLayer, DecalRoad, MeshRoad, River, ScatterSky, SkyBox, Sun, TimeOfDay, VolumetricFog, WaterBlock, WaterObject, WaterPlane, Forest, ForestWindEmitter, TSForestItemData, GuiBitmapButtonCtrl, GuiIconButtonCtrl, GuiToolboxButtonCtrl, GuiAutoScrollCtrl, GuiControlArrayControl, GuiDynamicCtrlArrayControl, GuiBitmapCtrl, GuiGradientCtrl, GuiMaterialCtrl, GuiMLTextCtrl, GuiTabPageCtrl, GuiTextCtrl, GuiControl, GuiMessageVectorCtrl, Material, CoverPoint, NavMesh, NavPath, OpenVRTrackedObject, SceneObject, Marker, SFXAmbience, SFXDescription, SFXEnvironment, SFXPlayList, SFXTrack, AccumulationVolume, ConvexShape, DecalData, RenderMeshExample, RenderShapeExample, fxFoliageReplicator, fxShapeReplicator, GroundCover, ParticleEmitterNode, Precipitation, RibbonNode, GameBaseData, GameBase, GroundPlane, LevelInfo, LightAnimData, LightBase, LightDescription, LightFlareData, BoxEnvironmentProbe, ReflectionProbe, Skylight, SphereEnvironmentProbe, MissionArea, MissionMarker, WayPoint, SpawnSphere, CameraBookmark, NotesObject, PhysicalZone, PhysicsShape, Prefab, SFXEmitter, ShapeBaseImageData, Trigger, TSStatic, TerrainBlock
onDeleteNotify(SimObject * object)
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 by: afxChoreographer, afxShapeConstraint, afxShapeNodeConstraint, afxObjectConstraint, afxShapeHistConstraint, afxShapeNodeHistConstraint, afxObjectHistConstraint, afxMagicMissile, afxMagicSpell, afxEA_Billboard, afxEA_CollisionEvent, afxEA_Debris, afxEA_Model, afxEA_Mooring, afxEA_ParticleEmitter, afxEA_PhysicalZone, afxEA_T3DPointLight, afxEA_Projectile, afxEA_Sound, afxEA_T3DSpotLight, afxEA_StaticShape, afxEA_ZodiacPlane, afxSpellButton, afxStatusBar, Item, ShapeBase, Trigger, afxCamera, afxResidueMgr, Camera, SimSet, ForestWindEmitter, Gui3DProjectionCtrl, GuiControl, GuiControlProfile, GuiInspector, TerrainEditor, ModuleManager, NavPath, DInputManager, UInputManager, SceneObject, SFXSound, SFXSource, CompoundUndoAction, VPath
onEditorEnable()
Called when the editor is activated.
Reimplemented by: afxCamera, DecalRoad, MeshRoad, ForestWindEmitter, WorldEditor, CoverPoint, NavMesh, NavPath, SceneSpace, Marker, Camera, MissionMarker, PathCamera, Prefab, TerrainBlock
onEditorDisable()
Called when the editor is deactivated.
Reimplemented by: afxCamera, DecalRoad, MeshRoad, ForestWindEmitter, GuiDecalEditorCtrl, CoverPoint, NavMesh, NavPath, SceneSpace, Marker, Camera, MissionMarker, PathCamera, Prefab, TerrainBlock
onInspect(GuiInspector * )
Called when the object is inspected via a GuiInspector control.
Reimplemented by: TSStatic
Registration
SimObjects must be registered with the object system.
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(U32 id)
Register the object, forcing the id.
id | ID to assign to the object. |
registerObject(const char * name)
Register the object, assigning the name.
name | Name to assign to the object. |
registerObject(const char * name, U32 id)
Register the object, assigning a name and ID.
name | Name to assign to the object. |
id | ID to assign to the object. |
unregisterObject()
Unregister the object from Sim.
This performs several operations:
Sets the removed flag.
Call onRemove()
Clear out notifications.
Remove the object from...
its group, if any. (via getGroup)
Sim::gIDDictionary
Finally, cancel any pending events for this object (as it can't receive them now).
deleteObject()
Unregister, mark as deleted, and free the object.
safeDeleteObject()
Performs a safe delayed delete of the object using a sim event.
handleDeleteAction()
Special-case deletion behaviors, largely intended for cleanup in particular cases where it wouldn't happen automatically(like cleanup of associated files)
Reimplemented by: ReflectionProbe
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.
addToSet(SimObjectId )
addToSet(const char * )
removeFromSet(SimObjectId )
removeFromSet(const char * )
Debugging
describeSelf()
Reimplemented from: EngineObject
Reimplemented by: SceneRootZone, SceneSimpleZone, NetObject, Portal
dumpToConsole(bool includeFunctions)
Dump the contents of this object to the console.
Use the Torque Script dump() and dumpF() functions to call this.
dumpClassHierarchy()
added this so that you can print the entire class hierarchy, including script objects,
Print the AbstractClassRep hierarchy of this object to the console.
dumpGroupHierarchy()
Print the SimGroup hierarchy of this object to the console.
Public Types
WriteFlags
Enumerator
- SelectedOnly = BIT( 0 )
Indicates that only objects marked as selected should be outputted. Used in SimSet.
- NoName = BIT( 1 )
Indicates that the object name should not be saved.
- IgnoreCanSave = BIT( 2 )
Write out even if CannotSave=true.
Flags passed to SimObject::write.
typedef ConsoleObject Parent
Private Types
@63
Enumerator
- Deleted = BIT( 0 )
This object is marked for deletion.
- Removed = BIT( 1 )
This object has been unregistered from the object system.
- Added = BIT( 3 )
This object has been registered with the object system.
- Selected = BIT( 4 )
This object has been marked as selected. (in editor)
- Expanded = BIT( 5 )
This object has been marked as expanded. (in editor)
- ModStaticFields = BIT( 6 )
The object allows you to read/modify static fields.
- ModDynamicFields = BIT( 7 )
The object allows you to read/modify dynamic fields.
- AutoDelete = BIT( 8 )
Delete this object when the last ObjectRef is gone.
- CannotSave = BIT( 9 )
Object should not be saved.
- EditorOnly = BIT( 10 )
This object is for use by the editor only.
- NoNameChange = BIT( 11 )
Whether changing the name of this object is allowed.
- Hidden = BIT( 12 )
Object is hidden in editors.
- Locked = BIT( 13 )
Object is locked in editors.
Flags for use in mFlags.
Public Friends
Private Attributes
SimObject * mCopySource
Object we are copying fields from.
SimFieldDictionary * mFieldDictionary
Table of dynamic fields assigned to this object.
BitSet32 mFlags
Flags internal to the object management system.
SimGroup * mGroup
SimGroup we're contained in, if any.
char mIdString [11]
Buffer to store textual representation of this object's numeric ID in.
StringTableEntry mObjectName
StringTableEntry mOriginalName
StringTableEntry mProgenitorFile
SimObject * nextIdObject
SimObject * nextManagerNameObject
SimObject * nextNameObject
Protected Attributes
DEFINE_CREATE_METHOD
bool is_temp_clone
SimObjectId mId
Id number for this object.
StringTableEntry mInternalName
Internal name assigned to the object. Not set by default.
return object
Protected Static Attributes
SimObjectId smForcedId
The Id to force upon the object. Poor object.
bool smForceId
Force a registered object to use the given Id. Cleared upon use.
Public Static Attributes
bool preventNameChanging
Private Static Functions
_getCanSave(void * object, const char * data)
_getHidden(void * object, const char * data)
_getLocked(void * object, const char * data)
_setCanSave(void * object, const char * index, const char * data)
_setHidden(void * object, const char * index, const char * data)
_setLocked(void * object, const char * index, const char * data)
setClass(void * object, const char * index, const char * data)
setParentGroup(void * obj, const char * data)
setProtectedName(void * object, const char * index, const char * data)
setProtectedParent(void * object, const char * index, const char * data)
setSuperClass(void * object, const char * index, const char * data)
writeCanSaveDynamicFields(void * obj, StringTableEntry pFieldName)
writeClass(void * obj, StringTableEntry pFieldName)
writeClassName(void * obj, StringTableEntry pFieldName)
writeInternalName(void * obj, StringTableEntry pFieldName)
writeObjectName(void * obj, StringTableEntry pFieldName)
writeParentGroup(void * obj, StringTableEntry pFieldName)
writeSuperclass(void * obj, StringTableEntry pFieldName)
Public Functions
SimObject(const SimObject & , bool )
allowSubstitutions()
Reimplemented by: afxEffectGroupData, afxEffectronData, afxEffectWrapperData, afxMagicMissileData, afxMagicSpellData, afxSelectronData, afxAnimClipData, afxAreaDamageData, afxAudioBank, afxBillboardData, afxCameraPuppetData, afxCameraShakeData, afxCollisionEventData, afxConsoleMessageData, afxDamageData, afxFootSwitchData, afxGuiControllerData, afxGuiTextData, afxMachineGunData, afxModelData, afxMooringData, afxParticleEmitterData, afxParticleEmitterVectorData, afxParticleEmitterConeData, afxParticleEmitterPathData, afxParticleEmitterDiscData, afxPhraseEffectData, afxPhysicalZoneData, afxPlayerMovementData, afxPlayerPuppetData, afxT3DPointLightData, afxProjectileData, afxScriptEventData, afxT3DSpotLightData, afxStaticShapeData, afxZodiacData, afxZodiacPlaneData, afxForceData, afxXM_ForceData, afxParticlePoolData, afxPathData, afxXM_AimData, afxXM_FreezeData, afxXM_GroundConformData, afxXM_HeightSamplerData, afxXM_MountedImageNodeData, afxXM_LocalOffsetData, afxXM_WorldOffsetData, afxXM_OscillateData, afxXM_PathConformData, afxXM_PivotNodeOffsetData, afxXM_RandomRotData, afxXM_ScaleData, afxXM_ShockwaveData, afxXM_SpinData, afxXM_VelocityOffsetData, afxXM_WaveColorData, afxXM_WaveRiderColorData, afxXM_WaveScalarData, afxXM_WaveRiderScalarData, SFXDescription, SFXProfile, DebrisData, ExplosionData, ParticleData, ParticleEmitterData, ProjectileData, StaticShapeData
assignDynamicFieldsFrom(SimObject * , const char * filter, bool no_replace)
copyTo(SimObject * object)
Copy SimObject to another SimObject (Originally designed for T2D).
Reimplemented by: AssetBase, CppAsset, CubemapAsset, ExampleAsset, GameObjectAsset, GUIAsset, ImageAsset, LevelAsset, MaterialAsset, ParticleAsset, PostEffectAsset, ScriptAsset, ShapeAnimationAsset, ShapeAsset, SoundAsset, StateMachineAsset, TerrainAsset, TerrainMaterialAsset
DECLARE_CALLBACK(void , onInspectPostApply , (SimObject *obj) )
DECLARE_CONOBJECT(SimObject )
destroySelf()
Reimplemented from: EngineObject
findObject(const char * name)
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 by: SimSet, SimGroup
getConsoleMethodData(const char * fname, S32 routingId, S32 * type, S32 * minArgs, S32 * maxArgs, void ** callback, const char ** usage)
getNamespace()
Return the object's namespace.
getProgenitorFile(void )
handlesConsoleMethod(const char * fname, S32 * routingId)
isTempClone()
reloadReset()
Reimplemented by: afxEffectGroupData, afxEffectronData, afxMagicSpellData, afxSelectronData, afxPhraseEffectData
setProgenitorFile(const char * pFile)
tabComplete(const char * prevText, S32 baseLen, bool )
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.
Protected Functions
_destroySelf()
Reimplemented from: EngineObject
_getLogMessage(const char * fmt, va_list args)
Reimplemented from: ConsoleObject
_onSelected()
Called when the object is selected in the editor.
Reimplemented by: ScatterSky, Sun, LightBase
_onUnselected()
Called when the object is unselected in the editor.
Reimplemented by: ScatterSky, Sun, LightBase
incRefCount()
onTamlAddParent(SimObject * pParentObject)
Reimplemented from: TamlCallbacks
onTamlCustomRead(const TamlCustomNodes & customNodes)
Reimplemented from: TamlCallbacks
Reimplemented by: AssetQuery, AssetTagsManifest
onTamlCustomWrite(TamlCustomNodes & customNodes)
Reimplemented from: TamlCallbacks
Reimplemented by: AssetQuery, AssetTagsManifest
onTamlPostRead(const TamlCustomNodes & customNodes)
Reimplemented from: TamlCallbacks
onTamlPostWrite(void )
Reimplemented from: TamlCallbacks
onTamlPreRead(void )
Reimplemented from: TamlCallbacks
onTamlPreWrite(void )
Reimplemented from: TamlCallbacks
Public Static Functions
__findObject(const char * id)
__getObjectId(ConsoleObject * object)
initPersistFields()