virtual IBehaviorTree* GetTree( const char* name )
	{
		IBehaviorTree* pTree = NULL;

		TTreeMap::iterator it = m_trees.find(name);
		if (it != m_trees.end())
		{
			IObjectUtils::GetObject( &pTree, it->second );
		}
		else
		{
			IObject* pObj = IObjectUtils::CreateUniqueObject( name );
			if (pObj)
			{
				IObjectUtils::GetObject( &pTree, pObj->GetObjectId() );
			}
			
			if (pTree)
			{
				m_trees[name] = pTree->GetObjectId();
			}		
		}

		return pTree;
	}
bool ConsoleGame::Init()
{
	//Initialise the RuntimeObjectSystem
	m_pRuntimeObjectSystem = new RuntimeObjectSystem;
	m_pCompilerLogger = new StdioLogSystem();
	if( !m_pRuntimeObjectSystem->Initialise(m_pCompilerLogger, 0) )
    {
        m_pRuntimeObjectSystem = 0;
        return false;
    }
	m_pRuntimeObjectSystem->GetObjectFactorySystem()->AddListener(this);


	// construct first object
	IObjectConstructor* pCtor = m_pRuntimeObjectSystem->GetObjectFactorySystem()->GetConstructor( "RuntimeObject01" );
	if( pCtor )
	{
		IObject* pObj = pCtor->Construct();
		pObj->GetInterface( &m_pUpdateable );
		if( 0 == m_pUpdateable )
		{
			delete pObj;
			m_pCompilerLogger->LogError("Error - no updateable interface found\n");
			return false;
		}
		m_ObjectId = pObj->GetObjectId();

	}

	return true;
}
	virtual void SetBehavior( const char* behavior )
	{
		if (!m_pBehavior || _stricmp(behavior, m_pBehavior->GetTypeName()))
		{
			IBehavior* pBehavior = 0;
			IObject* pObj = IObjectUtils::CreateObject( behavior );
			if (pObj)
			{
				IObjectUtils::GetObject( &pBehavior, pObj->GetObjectId() );
			}
			
			// Only destroy and replace existing behavior if we successfully created new one
			if (pBehavior)
			{
				if (m_pBehavior)
				{
					m_pBehavior->EndBehavior();
					delete m_pBehavior;
				}
				
				m_pBehavior = pBehavior;
				m_pBehavior->SetGameObject(this);
				m_pBehavior->StartBehavior();
			}
		}
	}
	IGameObject* DoSpawnGameObject( const GameObjectSpawnParams& params )
	{
		IGameObject* pGameObject = 0;
		EGameObject type = params.type;

		if (type < EGO_COUNT)
		{
			std::string name = m_GlobalParameters.go[type].base_name;
			char buff[16];
            _snprintf_s(buff, sizeof(buff), _TRUNCATE, "%d",++(m_NextGameObjectNumber[type]));
			name += buff;

			IObject* pObj = IObjectUtils::CreateObjectAndEntity( "GameObject", name.c_str() );
			IObjectUtils::GetObject( &pGameObject, pObj->GetObjectId() );

			AUVec3f pos = (params.spawnPosition.IsInfinite()) ? GetSpawnPosition(type) : params.spawnPosition;
			pGameObject->Init(type, pos);
			m_GameObjects[type].insert(pGameObject);
		}

		// Notify any listeners that object was created
		for (size_t i=0; i<m_Listeners.size(); ++i)
		{
			m_Listeners[i]->OnGameObjectCreated(pGameObject);
		}

		return pGameObject;
	}
	void CreateSplashScreen( const char* file, float fMinTime, float fFadeInTime, float fFadeOutTime, bool bAutoClose )
	{
		DestroySplashScreen();

		IObject* pObj = IObjectUtils::CreateObjectAndEntity( "SplashScreen", "SplashScreen" );
		IObjectUtils::GetObject( &m_pSplashScreen, pObj->GetObjectId() );
		m_pSplashScreen->SetImage(file);
		m_pSplashScreen->SetMinViewTime(fMinTime);
		m_pSplashScreen->SetFadeInTime(fFadeInTime);
		m_pSplashScreen->SetFadeOutTime(fFadeOutTime);
		m_pSplashScreen->SetAutoClose(bAutoClose);
	}
	void DoDestroyGameObject( ObjectId id )
	{
		IObjectFactorySystem* pFactory = PerModuleInterface::g_pSystemTable->pObjectFactorySystem;
		IObject* pObj = pFactory->GetObject(id);
		if (pObj)
		{
			IGameObject* pGameObject = 0;
			IObjectUtils::GetObject( &pGameObject, pObj->GetObjectId() );

			// Notify any listeners that object is about to be destroyed
			for (size_t i=0; i<m_Listeners.size(); ++i)
			{
				m_Listeners[i]->OnGameObjectAboutToDestroy(pGameObject);
			}

			m_GameObjects[pGameObject->GetGameObjectType()].erase(pGameObject);
			IObjectUtils::DestroyObjectAndEntity( pGameObject->GetEntityId() );
		}
	}
示例#7
0
void ofLive::setup()
{
  rCPP.Initialise(&rLOG, NULL);

# ifdef TARGET_LINUX
# ifdef NDEBUG
  rCPP.AddLibraryDir("../of/lib-linux/release-x86-64");
# else
  rCPP.AddLibraryDir("../of/lib-linux/debug-x86-64");
# endif
# endif

# ifdef TARGET_LINUX
  rCPP.AddIncludeDir("/usr/include/AL");
  rCPP.AddIncludeDir("/usr/include/cairo");
  rCPP.AddIncludeDir("/usr/include/gtk-3.0");
  rCPP.AddIncludeDir("/usr/include/atk-1.0");
  rCPP.AddIncludeDir("/usr/include/glib-2.0");
  rCPP.AddIncludeDir("/usr/lib/glib-2.0/include/");
  rCPP.AddIncludeDir("/usr/include/harfbuzz");
  rCPP.AddIncludeDir("/usr/include/pixman-1");
  rCPP.AddIncludeDir("/usr/include/libpng12");
  rCPP.AddIncludeDir("/usr/include/pango-1.0");
  rCPP.AddIncludeDir("/usr/include/freetype2");
  rCPP.AddIncludeDir("/usr/include/gio-unix-2.0");
  rCPP.AddIncludeDir("/usr/include/gstreamer-1.0");
  rCPP.AddIncludeDir("/usr/lib/gstreamer-1.0/include");
  rCPP.AddIncludeDir("/usr/lib/gstreamer-1.0/include/gst");
  rCPP.AddIncludeDir("/usr/include/gdk-pixbuf-2.0");
  rCPP.AddIncludeDir("/usr/include/at-spi2-atk/2.0");
  rCPP.AddIncludeDir("/usr/lib/x86_64-linux-gnu/glib-2.0/include");
# endif

  rCPP.AddIncludeDir("../of/src/freeimage");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/Half");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/Iex");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/IlmImf");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/IlmThread");
  rCPP.AddIncludeDir("../of/src/freeimage/OpenEXR/Imath");
  rCPP.AddIncludeDir("../of/src/rtaudio");
  rCPP.AddIncludeDir("../of/src/rtaudio/include");
  rCPP.AddIncludeDir("../of/src/utf8cpp");
  rCPP.AddIncludeDir("../of/src/utf8cpp/include");
  rCPP.AddIncludeDir("../of/src/utf8cpp/include/utf8");
  rCPP.AddIncludeDir("../of/src/glew");
  rCPP.AddIncludeDir("../of/src/glew/include");
  rCPP.AddIncludeDir("../of/src/glfw");
  rCPP.AddIncludeDir("../of/src/glfw/include");
  rCPP.AddIncludeDir("../of/src/glfw/include/GLFW");
  rCPP.AddIncludeDir("../of/src/kissfft");
  rCPP.AddIncludeDir("../of/src/kissfft/tools");
  rCPP.AddIncludeDir("../of/src/poco");
  rCPP.AddIncludeDir("../of/src/poco/Crypto/include");
  rCPP.AddIncludeDir("../of/src/poco/Foundation/include");
  rCPP.AddIncludeDir("../of/src/poco/Net/include");
  rCPP.AddIncludeDir("../of/src/poco/NetSSL_OpenSSL/include");
  rCPP.AddIncludeDir("../of/src/poco/Util/include");
  rCPP.AddIncludeDir("../of/src/poco/XML/include");
  rCPP.AddIncludeDir("../of/src/poco/Zip/include");
  rCPP.AddIncludeDir("../of/src/rtaudio");
  rCPP.AddIncludeDir("../of/src/rtaudio/include");
  rCPP.AddIncludeDir("../of/src/libtess2");
  rCPP.AddIncludeDir("../of/src/libtess2/Include");
  rCPP.AddIncludeDir("../of/src/libtess2/Sources");
  rCPP.AddIncludeDir("../of/src/openframeworks");
  rCPP.AddIncludeDir("of/src/openframeworks");
  rCPP.AddIncludeDir("../of/src/openframeworks/3d");
  rCPP.AddIncludeDir("../of/src/openframeworks/app");
  rCPP.AddIncludeDir("../of/src/openframeworks/communication");
  rCPP.AddIncludeDir("../of/src/openframeworks/events");
  rCPP.AddIncludeDir("../of/src/openframeworks/gl");
  rCPP.AddIncludeDir("../of/src/openframeworks/graphics");
  rCPP.AddIncludeDir("../of/src/openframeworks/math");
  rCPP.AddIncludeDir("../of/src/openframeworks/sound");
  rCPP.AddIncludeDir("../of/src/openframeworks/types");
  rCPP.AddIncludeDir("../of/src/openframeworks/utils");
  rCPP.AddIncludeDir("../of/src/openframeworks/video");

  rCPP.AddIncludeDir("RuntimeCompiledCPlusPlus/Aurora");
  rCPP.AddIncludeDir("addons/ofxImGui/src");
  rCPP.AddIncludeDir("addons/ofxImGui/libs/imgui/src");
  rCPP.AddIncludeDir("../of/addons/ofxAssimpModelLoader/src");
  rCPP.AddIncludeDir("../of/addons/ofxAssimpModelLoader/libs/assimp/include/");
  rCPP.AddIncludeDir("./");

  {
    ofDirectory dir(ofFilePath::getCurrentExeDir() + "..");
    dir.listDir();
    vector<ofFile> files = dir.getFiles();
    for (ofFile& file : files)
    {
      if (file.isDirectory() &&
          file.getBaseName().substr(0,3) == "ofx")
      {
        rCPP.AddIncludeDir(&(file.path())[0]);
        rCPP.AddIncludeDir(&(file.path() + "/src")[0]);
      }
    }
  }

  rCPP.GetObjectFactorySystem()->AddListener(this);

  {
    IObject* rObject = rCPP.GetObjectFactorySystem()->GetConstructor("ofApp")->Construct();
    rObject->GetInterface(&rAPP);
    rOID = rObject->GetObjectId();
  }

  rAPP->setup();
}