Exemple #1
0
            virtual bool RegisterTypes( int nFactoryType, bool bUnregister )
            {
                bool bRet = CPluginBaseMinimal::RegisterTypes( nFactoryType, bUnregister );

                if ( bRet )
                {
                    eFactoryType enFactoryType = eFactoryType( nFactoryType );

                    if ( enFactoryType == FT_All || enFactoryType == FT_Flownode )
                    {
                        IFlowSystem* pFlow = NULL;

                        if ( gEnv && gEnv->pSystem && !gEnv->pSystem->IsQuitting() && gEnv->pGameFramework && ( pFlow = gEnv->pGameFramework->GetIFlowSystem() ) )
                        {
                            if ( !bUnregister )
                            {
                                // Register all flownodes of this plugin in the crygame loading this plugin
                                for ( CG2AutoRegFlowNodeBase* pFactory = CG2AutoRegFlowNodeBase::m_pFirst; pFactory; pFactory = pFactory->m_pNext )
                                {
                                    TFlowNodeTypeId nTypeId = pFlow->RegisterType( pFactory->m_sClassName, pFactory );

                                    if ( nTypeId != InvalidFlowNodeTypeId )
                                    {
                                        LogAlways( "Flownode Class(%s) Ptr(%p) TypeId(%d) registered.", SAFESTR( pFactory->m_sClassName ), pFactory, ( int )nTypeId );
                                    }

                                    else
                                    {
                                        LogError( "Flownode Class(%s) Ptr(%p) couldn't register.", SAFESTR( pFactory->m_sClassName ), pFactory );
                                        //bRet = false;
                                    }
                                }
                            }

                            else
                            {
                                // Unregister all flownodes of this plugin
                                for ( CG2AutoRegFlowNodeBase* pFactory = CG2AutoRegFlowNodeBase::m_pFirst; pFactory; pFactory = pFactory->m_pNext )
                                {
                                    // A shame unregistering flownodes types still will produce errors later on in sandbox (then when clicked on)
                                    // it would be much better if UnregisterTypes would automatically unload and set related flownodes to missing status.
                                    bool bUnregistered = pFlow->UnregisterType( pFactory->m_sClassName );

                                    LogAlways( "Flownode Class(%s) Ptr(%p) Ret(%s) unregistered.", SAFESTR( pFactory->m_sClassName ), pFactory );
                                }
                            }
                        }

                        else if ( CG2AutoRegFlowNodeBase::m_pFirst )
                        {
                            LogWarning( "Flownodes couldn't be un/registered" );
                            //bRet = false;
                        }

                        // else there where no flownodes to register
                    }
                }

                return bRet;
            };
void CGame::RegisterGameFlowNodes()
{
	IFlowSystem* pFlowSystem = m_pGameFramework->GetIFlowSystem();
	if (pFlowSystem)
	{
		CAutoRegFlowNodeBaseZero* pFactory = CAutoRegFlowNodeBaseZero::m_pFirst;

		while (pFactory)
		{
			pFlowSystem->RegisterType(pFactory->m_sClassName, pFactory);
			pFactory = pFactory->m_pNext;
		}

		CGameFactory::RegisterEntityFlowNodes();
	}
}
Exemple #3
0
void CFlowManager::RegisterNode(mono::string monoTypeName)
{
    IFlowSystem *pFlowSystem = gEnv->pGameFramework->GetIFlowSystem();
    if(!pFlowSystem)
        return;

    const char *typeName = ToCryString(monoTypeName);

    CFlowManager *pFlowManager = g_pScriptSystem->GetFlowManager();
    if(!pFlowManager)
    {
        MonoWarning("Aborting registration of node type %s, flow manager was null!", typeName);
        return;
    }

    pFlowSystem->RegisterType(typeName, (IFlowNodeFactoryPtr)pFlowManager);
}
Exemple #4
0
bool CFlowGraphModule::LoadModuleGraph(const char* moduleName, const char* fileName)
{
	assert(m_name == moduleName);
	assert(m_fileName == fileName);

	XmlNodeRef moduleRef = gEnv->pSystem->LoadXmlFromFile(fileName);

	if (!moduleRef)
	{
		CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "Unable to load Flowgraph Module Graph: %s", moduleName);
		return false;
	}

	assert(!stricmp(moduleRef->getTag(), "Graph"));

	bool module = false;
	moduleRef->getAttr("isModule", module);
	assert(module);

	bool bResult = (m_pRootGraph != NULL);
	assert(m_pRootGraph == NULL);

	if (!m_pRootGraph)
	{
		IFlowSystem* pSystem = gEnv->pFlowSystem;
		assert(pSystem);

		// Create graph
		m_pRootGraph = pSystem->CreateFlowGraph();
		if (m_pRootGraph)
		{
			m_pRootGraph->SerializeXML(moduleRef, true);

			// Root graph is for cloning, so not active!
			m_pRootGraph->UnregisterFromFlowSystem();
			m_pRootGraph->SetEnabled(false);
			m_pRootGraph->SetActive(false);
			bResult = true;
		}
	}

	return bResult;
}