Beispiel #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();
	}
}
Beispiel #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);
}