Game Development Community

ClassName TGEA

by Nathan Bowhay - ESAL · in Torque Game Engine Advanced · 04/20/2009 (11:32 am) · 3 replies

setting the class use to work in TGE and it appears they took it out in TGEA.

I found out that there is a mNSLinkMask in engine under SimObject that tells it how to use class and superclass and currently it just looks up by ObjectName->ClassName.

In the constructor you can pass in namespaceLinkMask to change this.

What I am wondering is is there any way in script (using something like new SimObject(:MyClassName) to set this mask or do I have to hard code it in engine? Cause I understand this may have been changed to speed up function lookups so it would be cool if I can could in script tell it to use class lookup per object or better yet when you give it a class either in the constructor or by calling setClassName, it would set the bits and do a namespace linking.

Anyone know how it works now in TGEA, if there is a way to set it in script or if in engine I just have to set it on that class by saying:
mNSLinkMask = LinkSuperClassName | LinkClassName;

#1
04/20/2009 (12:05 pm)
Each individual class is now responsible for allowing class and superClass changes. You need to set it in the class constructor in C++ or, if you cannot change the source, limit yourself to the classes that already have it enabled (ScriptObject, ScriptGroup and pretty much every GUI class).
#2
04/20/2009 (12:21 pm)
From what I can tell you have to set the flag someplace in engine code (isn't already open to script). So I just added some checks in setClassNamespace and SetSuperClassNamespace:

ConsoleMethod(SimObject, setClassNamespace, void, 2, 4, "(string ClassName, bool makeClassLink = true)")
{
   object->setClassNamespace(argv[2]);
   
   if ( object->isProperlyAdded() )
	{
		if( argc == 3 || (argc == 4 && dAtob(argv[3])) )
			object->mNSLinkMask = (object->mNSLinkMask & object->LinkSuperClassName) ? object->LinkSuperClassName | object->LinkClassName : object->LinkClassName;

      object->linkNamespaces();
	}
}

ConsoleMethod(SimObject, setSuperClassNamespace, void, 2, 3, "(string SuperClassName, bool makeSuperClassLink = true)")
{
   object->setSuperClassNamespace(argv[2]);
   
   if ( object->isProperlyAdded() )
	{
		if( argc == 3 || (argc == 4 && dAtob(argv[3])) )
			object->mNSLinkMask = (object->mNSLinkMask & object->LinkClassName) ? object->LinkSuperClassName | object->LinkClassName : object->LinkSuperClassName;

      object->linkNamespaces();
	}
}
#3
04/20/2009 (12:23 pm)
Oh just got your reply Manoel Neto thanks, that sounds good. I also added the code above so that I can set it on a per instance basis which is nice. So I just have to call the method instead of setting it in the constructor in script (new...).

It is nice to know that those object already support it and it make sense why those do. Thanks for the reply!