当前位置: 首页>>代码示例>>C++>>正文


C++ SimObject类代码示例

本文整理汇总了C++中SimObject的典型用法代码示例。如果您正苦于以下问题:C++ SimObject类的具体用法?C++ SimObject怎么用?C++ SimObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dSprintf

void SimSet::write(Stream &stream, U32 tabStop, U32 flags)
{
   MutexHandle handle;
   handle.lock(mMutex);

   // export selected only?
   if((flags & SelectedOnly) && !isSelected())
   {
      for(U32 i = 0; i < size(); i++)
         (*this)[i]->write(stream, tabStop, flags);

      return;

   }

   stream.writeTabs( tabStop );
   char buffer[ 2048 ];
   const U32 bufferWriteLen = dSprintf( buffer, sizeof( buffer ), "new %s(%s) {\r\n", getClassName(), getName() && !( flags & NoName ) ? getName() : "" );
   stream.write( bufferWriteLen, buffer );
   writeFields( stream, tabStop + 1 );

   if(size())
   {
      stream.write(2, "\r\n");
      for(U32 i = 0; i < size(); i++)
      {
         SimObject* child = ( *this )[ i ];
         if( child->getCanSave() )
            child->write(stream, tabStop + 1, flags);
      }
   }

   stream.writeTabs(tabStop);
   stream.write(4, "};\r\n");
}
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:35,代码来源:simSet.cpp

示例2: createModel

void CustomModel::createModel(bool ignorePhysicsManager) {

	QString pathName = "/";
	pathName = pathName.append(getName());

	for(QListIterator<SimObject*> i(mSimObjects); i.hasNext();) {
		SimObject *object = i.next();
		object->setName(object->getName().prepend("/"));

		if(!ignorePhysicsManager) {
			QList<Value*> parameters = object->getParameters();
			for(QListIterator<Value*> j(parameters); j.hasNext();) {
				StringValue *stringValue = dynamic_cast<StringValue*>(j.next());
				if(stringValue != 0) {
					if(stringValue->get().contains("$name$")) {
						QString replacedString = stringValue->get().replace("$name$", pathName);
						stringValue->set(replacedString);
					}
				}
			}
		}
		mAgent->addObject(object);
	}

	if(!ignorePhysicsManager) {
		Physics::getPhysicsManager()->addSimObjectGroup(mAgent);
	}
	else {
		delete mAgent;
	}
}
开发者ID:nerd-toolkit,项目名称:nerd,代码行数:31,代码来源:CustomModel.cpp

示例3: run

 void run()
 {
    for( AbstractClassRep* classRep = AbstractClassRep::getClassList();
         classRep != NULL;
         classRep = classRep->getNextClass() )
    {
       // Create object.
       
       ConsoleObject* object = classRep->create();
       test( object, avar( "AbstractClassRep::create failed for class '%s'", classRep->getClassName() ) );
       if( !object )
          continue;
       
       // Make sure it's a SimObject.
       
       SimObject* simObject = dynamic_cast< SimObject* >( object );
       if( !simObject )
       {
          SAFE_DELETE( object );
          continue;
       }
       
       // Register the object.
       
       bool result = simObject->registerObject();
       test( result, avar( "registerObject failed for object of class '%s'", classRep->getClassName() ) );
       
       if( result )
          simObject->deleteObject();
       else
          SAFE_DELETE( simObject );
    }
 }
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:33,代码来源:testDefaultConstruction.cpp

示例4:

SimObject *loadObjectStream(Stream *stream)
{
   const char *className = stream->readSTString(true);
   ConsoleObject *conObj = ConsoleObject::create(className);
   if(conObj == NULL)
   {
      Con::errorf("Sim::restoreObjectStream - Could not create object of class \"%s\"", className);
      return NULL;
   }

   SimObject *simObj = dynamic_cast<SimObject *>(conObj);
   if(simObj == NULL)
   {
      Con::errorf("Sim::restoreObjectStream - Object of class \"%s\" is not a SimObject", className);
      delete simObj;
      return NULL;
   }

   if( simObj->readObject(stream)
       && simObj->registerObject() )
      return simObj;

   delete simObj;
   return NULL;
}
开发者ID:Dwarf-King,项目名称:OmniEngine.Net,代码行数:25,代码来源:simSerialize.cpp

示例5: if

SimObject* SimSet::findObjectByLineNumber(const char* fileName, S32 declarationLine, bool searchChildren)
{
   if (!fileName)
      return NULL;

   if (declarationLine < 0)
      return NULL;

   StringTableEntry fileEntry = StringTable->insert(fileName);

   for (iterator i = begin(); i != end(); i++)
   {
      SimObject *childObj = static_cast<SimObject*>(*i);

      if(childObj->getFilename() == fileEntry && childObj->getDeclarationLine() == declarationLine)
         return childObj;
      else if (searchChildren)
      {
         SimSet* childSet = dynamic_cast<SimSet*>(*i);

         if (childSet)
         {
            SimObject* found = childSet->findObjectByLineNumber(fileName, declarationLine, searchChildren);
            if (found)
               return found;
         }
      }
   }

   return NULL;
}
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:31,代码来源:simSet.cpp

示例6: script_simobject_find

   S32 script_simobject_find(const char* classname, const char* name)
   {
      SimObject *object;
      if( Sim::findObject( name, object ) )
      {
         // if we specified a classname do type checking
         if (classname && dStrlen(classname))
         {
            AbstractClassRep* ocr = object->getClassRep();
            while (ocr)
            {
               if (!dStricmp(ocr->getClassName(), classname))
                  return object->getId();
               ocr = ocr->getParentClass();
            }

         }

         // invalid type
         return 0;
      }

      // didn't find object
      return 0;
   }
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:25,代码来源:c_scripting.cpp

示例7: AssertWarn

void SimGroup::popObject()
{
   MutexHandle handle;
   handle.lock( mMutex );

   if( objectList.empty() )
   {
      AssertWarn( false, "SimGroup::popObject - Stack underflow" );
      return;
   }

   SimObject* object = objectList.last();
   objectList.pop_back();

   object->onGroupRemove();
   object->mGroup = NULL;

   clearNotify( object );
   mNameDictionary.remove( object );
      
   getSetModificationSignal().trigger( SetObjectAdded, this, object );
   if( object->isProperlyAdded() )
      onObjectRemoved_callback( object );
   
   object->decRefCount();
}
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:26,代码来源:simSet.cpp

示例8: lock

void SimGroup::clear()
{
   lock();
   while( size() > 0 )
   {
      SimObject* object = objectList.last();
      object->onGroupRemove();
      
      objectList.pop_back();
      mNameDictionary.remove( object );
      object->mGroup = 0;

      getSetModificationSignal().trigger( SetObjectRemoved, this, object );
      if( object->isProperlyAdded() )
         onObjectRemoved_callback( object );

      if( engineAPI::gUseConsoleInterop )
         object->deleteObject();
      else
         object->decRefCount();      
   }
   unlock();

   getSetModificationSignal().trigger( SetCleared, this, NULL );
}
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:25,代码来源:simSet.cpp

示例9: lockComponentList

//-----------------------------------------------------------
// Function name:  SimComponent::handlesConsoleMethod
// Summary:
//-----------------------------------------------------------
bool DynamicConsoleMethodComponent::handlesConsoleMethod( const char *fname, S32 *routingId )
{
   // CodeReview: Host object is now given priority over components for method
   // redirection. [6/23/2007 Pat]

   // On this object?
   if( isMethod( fname ) )
   {
      *routingId = -1; // -1 denotes method on object
      return true;
   }

   // on this objects components?
   S32 nI = 0;
   VectorPtr<SimComponent*> &componentList = lockComponentList();
   for( SimComponentIterator nItr = componentList.begin(); nItr != componentList.end(); nItr++, nI++ )
   {
      SimObject *pComponent = dynamic_cast<SimObject*>(*nItr);
      if( pComponent != NULL && pComponent->isMethod( fname ) )
      {
         *routingId = -2; // -2 denotes method on component
         unlockComponentList();
         return true;
      }
   }
   unlockComponentList();

   return false;
}
开发者ID:404james,项目名称:Torque2D,代码行数:33,代码来源:dynamicConsoleMethodComponent.cpp

示例10: advanceToTime

void advanceToTime(SimTime targetTime)
{
   AssertFatal(targetTime >= getCurrentTime(), 
      "Sim::advanceToTime() - Target time is less than the current time." );

   Mutex::lockMutex(gEventQueueMutex);

   gTargetTime = targetTime;
   while(gEventQueue && gEventQueue->time <= targetTime)
   {
      SimEvent *event = gEventQueue;
      gEventQueue = gEventQueue->nextEvent;
      AssertFatal(event->time >= gCurrentTime,
         "Sim::advanceToTime() - Event time is less than current time.");
      gCurrentTime = event->time;
      SimObject *obj = event->destObject;

      if(!obj->isDeleted())
         event->process(obj);
      delete event;
   }
	gCurrentTime = targetTime;

   Mutex::unlockMutex(gEventQueueMutex);
}
开发者ID:belzilep,项目名称:Torque3D,代码行数:25,代码来源:simManager.cpp

示例11: script_simobject_setfield_bool

 void script_simobject_setfield_bool(U32 objectId, const char* fieldName, bool v)
 {
    SimObject *object = Sim::findObject( objectId );
    if( object )
    {
       object->setDataField(fieldName, "", v ? "1" : "0");
    }
 }
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:8,代码来源:c_scripting.cpp

示例12: script_simobject_setfield_string

 void script_simobject_setfield_string(U32 objectId, const char* fieldName, const char* v)
 {
    SimObject *object = Sim::findObject( objectId );
    if( object )
    {
       object->setDataField(fieldName, "", v);
    }
 }
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:8,代码来源:c_scripting.cpp

示例13: script_simobject_getfield_string

 const char* script_simobject_getfield_string(U32 id, const char* fieldName)
 {
    SimObject *object = Sim::findObject( id );
    if( object )
    {
       return (const char *) object->getDataField(fieldName, "");
    }
    return "";
 }
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:9,代码来源:c_scripting.cpp

示例14: unpack

void SimDataBlockEvent::unpack(NetConnection *cptr, BitStream *bstream)
{
   if(bstream->readFlag())
   {
      mProcess = true;
      id = bstream->readInt(DataBlockObjectIdBitSize) + DataBlockObjectIdFirst;
      S32 classId = bstream->readClassId(NetClassTypeDataBlock, cptr->getNetClassGroup());
      mIndex = bstream->readInt(DataBlockObjectIdBitSize);
      mTotal = bstream->readInt(DataBlockObjectIdBitSize + 1);
      
      SimObject* ptr;
      if( Sim::findObject( id, ptr ) )
      {
         // An object with the given ID already exists.  Make sure it has the right class.
         
         AbstractClassRep* classRep = AbstractClassRep::findClassRep( cptr->getNetClassGroup(), NetClassTypeDataBlock, classId );
         if( classRep && dStrcmp( classRep->getClassName(), ptr->getClassName() ) != 0 )
         {
            Con::warnf( "A '%s' datablock with id: %d already existed. "
                        "Clobbering it with new '%s' datablock from server.",
                        ptr->getClassName(), id, classRep->getClassName() );
            ptr->deleteObject();
            ptr = NULL;
         }
      }
      
      if( !ptr )
         ptr = ( SimObject* ) ConsoleObject::create( cptr->getNetClassGroup(), NetClassTypeDataBlock, classId );
         
      mObj = dynamic_cast< SimDataBlock* >( ptr );
      if( mObj != NULL )
      {
         #ifdef DEBUG_SPEW
         Con::printf(" - SimDataBlockEvent: unpacking event of type: %s", mObj->getClassName());
         #endif
         
         mObj->unpackData( bstream );
      }
      else
      {
         #ifdef DEBUG_SPEW
         Con::printf(" - SimDataBlockEvent: INVALID PACKET!  Could not create class with classID: %d", classId);
         #endif
         
         delete ptr;
         cptr->setLastError("Invalid packet in SimDataBlockEvent::unpack()");
      }

#ifdef TORQUE_DEBUG_NET
      U32 checksum = bstream->readInt(32);
      AssertISV( (checksum ^ DebugChecksum) == (U32)classId,
         avar("unpack did not match pack for event of class %s.",
            mObj->getClassName()) );
#endif

   }
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:57,代码来源:gameConnectionEvents.cpp

示例15: script_simobject_setfield_float

 void script_simobject_setfield_float(U32 objectId, const char* fieldName, F32 v)
 {
    SimObject *object = Sim::findObject( objectId );
    if( object )
    {
       char buf[256];
       dSprintf(buf, 256, "%g", v );
       object->setDataField(fieldName, "", buf);
    }
 }
开发者ID:BadBehavior,项目名称:BadBehavior_T3D,代码行数:10,代码来源:c_scripting.cpp


注:本文中的SimObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。