/* ******************************************************************* * Function: int GetCIS( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GetCIS(const CKBehaviorContext& behcontext) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // Retrieving min data : CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=static_cast<CGBLCIConfigurationController*>(ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID)); IGBLCIAccessInterface *accessInterface = cman->GetCISAccessInterface(); CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_OUT_INDEX_ERROR); int idCIS = GBLCommon::BehaviorTools::GetInputParameterValue<int>(beh,BEH_IN_INDEX_CIS); CGBLCOError returnValue = accessInterface->GetCIS(idCIS); // check results and output error if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { TGBLError::SetTGBLError(parameterOutError,returnValue.GetType(),returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_SUCCESS, true); } else { CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } TGBLError::SetTGBLError(parameterOutError,tType,returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_ERROR, true); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLPFGetUserIdentity::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behaviour=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError returnValue; behaviour->ActivateInput(EGBLGetUserIdBehInputs::In, false); XString Username="******"; CGBLUserID PlayerId=123456; int ClientId=123456; CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(CGBLProfileManagerGUID); //returnValue = pm->GetUserIdentity(&PlayerId, &Username, ClientId); returnValue.SetType(CGBLCOError::EGBLCOErrorType::GBLCO_OK); if ((CGBLCOError::EGBLCOErrorType)returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { behaviour->ActivateOutput(EGBLGetUserIdBehOutputs::Success, true); behaviour->SetOutputParameterValue(EGBLGetUserIdParamOutputs::UserID, &PlayerId); behaviour->SetOutputParameterValue(EGBLGetUserIdParamOutputs::Username, &Username); behaviour->SetOutputParameterValue(EGBLGetUserIdParamOutputs::VirtoolsUserID, &ClientId); } else { behaviour->SetOutputParameterValue(EGBLGetUserIdParamOutputs::ErrorCode, &returnValue); behaviour->ActivateOutput(EGBLGetUserIdBehOutputs::Error, true); } return CKBR_OK; }
int LoadCIS(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; GBLConfigurationManager* cman=(GBLConfigurationManager*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); using namespace Customisation::typedefs; using namespace GBLCommon::BehaviorTools; int LA = GetInputParameterValue<int>(beh,0); Customisation::typedefs::CIS* currentCIS = cman->GetCISAccessInterface()->GetCIS(LA); if( beh->IsInputActive(0) ){ beh->ActivateInput(0,FALSE); beh->ActivateOutput(0); beh->ActivateOutput(1); return CKBR_OK; } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLPFGetTeamLeader::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behaviour=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError returnValue; behaviour->ActivateInput(EGBLGetTeamLeaderBehInputs::In, false); XString FieldName("TeamLeaderID"); CKDataArray* FieldData = (CKDataArray*)context->CreateObject(CKCID_DATAARRAY, "FieldData", CK_OBJECTCREATION_DYNAMIC); CGBLTeamID TeamId ; behaviour->GetInputParameterValue(EGBLGetTeamLeaderParamInputs::TeamId, &TeamId); CGBLUserID PlayerId; CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(GBLProfileManagerGUID); returnValue = pm->GetProfileField((CGBLProfileID)TeamId, FieldName, (CKDataArray*)FieldData); int value; if(!FieldData->GetElementValue(0,0,&value)) { returnValue = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; } else { PlayerId = value; } if ((int)returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { behaviour->ActivateOutput(EGBLGetTeamLeaderBehOutputs::Success, true); behaviour->SetOutputParameterValue(EGBLGetTeamLeaderParamOutputs::UserID, &PlayerId); } else { CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLGetTeamLeaderParamOutputs::ErrorCode); CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK ; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } const char*errorString = returnValue; TGBLError::SetTGBLError(pOut, tType,returnValue, (CKSTRING)errorString); behaviour->ActivateOutput(EGBLGetTeamLeaderBehOutputs::Error, true); } context->DestroyObject(FieldData); return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAESetLoadState::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; CGBLLAEManager *laeManager = (CGBLLAEManager *)ctx->GetManagerByGuid(GBLLAEManagerGUID); if (laeManager) { int state = 0; beh->GetInputParameterValue(0, &state); laeManager->SetLoadState(state); beh->ActivateInput(0, FALSE); beh->ActivateOutput(0); } else { beh->ActivateInput(0, FALSE); CKParameterOut *parameterOutError = beh->GetOutputParameter(0); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CANTSETLAEIDENTITY,GBLLAE_ERROR_CANTSETLAEIDENTITY_DESC); beh->ActivateOutput(1); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLLDGetSetup::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *beh; CKContext *context; GBLLDManager *GBLLDMan; XString DBName; CKBOOL logging; XString ODBCName; XString proxyLogin; XString proxyPassword; XString serverAddress; XString serverLogin; XString serverPassword; CKBOOL serverMode; XString userName; int virtoolsUserID; CKBOOL webPlayerMode; int ConnectionID; if ( (beh = behaviorContext.Behavior) == NULL ) return CKBR_BEHAVIORERROR; if ( (context = behaviorContext.Context) == NULL ) return CKBR_BEHAVIORERROR; if ( (GBLLDMan = (GBLLDManager*)context->GetManagerByGuid(GBLLDManagerGUID)) == NULL ) return CKBR_BEHAVIORERROR; beh->ActivateInput( POS_I_IN, FALSE ); // Force the reading of the attributes GBLLDMan->ReadSetup(); ConnectionID = GBLLDMan->GetConnectionID(); DBName = GBLLDMan->GetDBName(); logging = GBLLDMan->IsLogging(); ODBCName = GBLLDMan->GetODBCName(); proxyLogin = GBLLDMan->GetProxyLogin(); proxyPassword = GBLLDMan->GetProxyPassword(); serverAddress = GBLLDMan->GetServerAddress(); serverLogin = GBLLDMan->GetServerLogin(); serverPassword = GBLLDMan->GetServerPassword(); serverMode = GBLLDMan->GetServerMode(); userName = GBLLDMan->GetUserName(); webPlayerMode = GBLLDMan->IsWebplayerMode(); virtoolsUserID = GBLLDMan->GetVirtoolsUserID(); beh->SetOutputParameterValue( POS_OP_CONNECTIONID, &ConnectionID ); beh->SetOutputParameterValue( POS_OP_DBNAME, DBName.CStr(), DBName.Length() ); beh->SetOutputParameterValue( POS_OP_LOGGING, &logging ); beh->SetOutputParameterValue( POS_OP_ODBCNAME, ODBCName.CStr(), ODBCName.Length() ); beh->SetOutputParameterValue( POS_OP_PROXYLOGIN, proxyLogin.CStr(), proxyLogin.Length() ); beh->SetOutputParameterValue( POS_OP_PROXYPASSWORD, proxyPassword.CStr(), proxyPassword.Length() ); beh->SetOutputParameterValue( POS_OP_SERVERADDRESS, serverAddress.CStr(), serverAddress.Length() ); beh->SetOutputParameterValue( POS_OP_SERVERLOGIN, serverLogin.CStr(), serverLogin.Length() ); beh->SetOutputParameterValue( POS_OP_SERVERMODE, &serverMode ); beh->SetOutputParameterValue( POS_OP_SERVERPASSWORD, serverPassword.CStr(), serverPassword.Length() ); beh->SetOutputParameterValue( POS_OP_USERNAME, userName.CStr(), userName.Length() ); beh->SetOutputParameterValue( POS_OP_WEBPLAYERMODE, &webPlayerMode ); beh->SetOutputParameterValue( POS_OP_VIRTOOLSUSERID, &virtoolsUserID ); beh->ActivateOutput( POS_O_OUT, TRUE ); return CKBR_OK; }
int SetCIConnectionDetails(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; GBLConfigurationManager* cman=(GBLConfigurationManager*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); CGBLSyncInterface *CINetworkInterface = cman->GetSynInterface(); /************************************************************************/ /* check interface : */ /* */ if (!CINetworkInterface->isValidInterface()) { //try to init the network interface : if (!CINetworkInterface->Init(ctx)) { return CKBR_BEHAVIORERROR; } } /************************************************************************/ /* process building block events : */ /* */ if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); XString message((CKSTRING) beh->GetInputParameterReadDataPtr(0)); int connectionID = -1; beh->GetInputParameterValue(1,&CINetworkInterface->connectionID); CKAttributeManager *aMan = static_cast<CKAttributeManager*>(ctx->GetAttributeManager()); ////////////////////////////////////////////////////////////////////////// //store connection details in the scipt dummies attribute : CKAttributeType gblNetworkAtt = aMan->GetAttributeTypeByName( GBL_API_ENTRY("NetworkDetails")); if (!CINetworkInterface->messageDummy->HasAttribute(gblNetworkAtt) ) { CINetworkInterface->messageDummy->SetAttribute(gblNetworkAtt); } GBLCommon::ParameterTools::SetParameterStructureValue<int>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),0,CINetworkInterface->connectionID); GBLCommon::ParameterTools::SetParameterStructureValue<CKSTRING>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),1,CINetworkInterface->messageName.Str()); ////////////////////////////////////////////////////////////////////////// //activate and execute the script : behcontext.CurrentScene->Activate(CINetworkInterface->synchronizeScript,true); behcontext.CurrentScene->Activate(CINetworkInterface->messageDummy,FALSE); CINetworkInterface->synchronizeScript->Execute(1); beh->ActivateOutput(0); } return CKBR_OK; }
/* ******************************************************************* * Function: int CISIteratorCB( const CKBehaviorContext& behaviorContext ) * * Description : The Behavior Callback function is called by Virtools when various events happen * in the life of a BuildingBlock. Exactly which events trigger a call to the * Behavior Callback function is defined in the Behavior Prototype, along with the * declaration of the function pointer * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * * Returns : int, The return value of the callback function should be one of the CK_BEHAVIOR_RETURN values. * ******************************************************************* */ CKERROR CISIteratorCB(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior *beh = behcontext.Behavior; CKContext* ctx = beh->GetCKContext(); CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); /************************************************************************/ /* process virtools callbacks : */ /* */ switch(behcontext.CallbackMessage) { case CKM_BEHAVIORRESET: { CKDataArray *array = NULL; beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&array); break; } case CKM_BEHAVIOREDITED: case CKM_BEHAVIORSETTINGSEDITED : { assert(beh && ctx); BOOL getFromDB = false; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_DB_MODE,&getFromDB); if( getFromDB && ( beh->GetInputParameterCount() == BEH_IN_INDEX_MIN_COUNT ) ) { beh->CreateInputParameter("CIS ID", CKPGUID_INT); } ////////////////////////////////////////////////////////////////////////// //remove all pIns : int p_count = beh->GetInputParameterCount(); while( (getFromDB ? BEH_IN_INDEX_MAX_COUNT : BEH_IN_INDEX_MIN_COUNT ) < p_count ) { CKDestroyObject( beh->RemoveInputParameter( --p_count) ); } break; } } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLPFGetActivePlayer::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behaviour=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError returnValue; behaviour->ActivateInput(EGBLGetActivePlayerBehInputs::In, false); //initialise data array CKDataArray *PlayerList; PlayerList = (CKDataArray *) behaviour->GetInputParameterObject(EGBLGetActivePlayerParamInputs::GetPLayerList); CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(GBLProfileManagerGUID); returnValue = pm->GetActivePlayers(PlayerList); if ((int)returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { behaviour->ActivateOutput(EGBLGetActivePlayerBehOutputs::Success, true); } else { CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLGetActivePlayerParamOutputs::ErrorCode); CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK ; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } const char*errorString = returnValue; TGBLError::SetTGBLError(pOut, tType,returnValue, (CKSTRING)errorString); behaviour->ActivateOutput(EGBLGetActivePlayerBehOutputs::Error, true); } return CKBR_OK; }
/* ******************************************************************* * Function: CGBLCOError RemoveUser(const CKBehaviorContext& behaviorContext) * * Description : Removes user(s) from the LAE session, this prevents them from joining the LAE session (if they havent joined already). * * Parameters : const CKBehaviorContext& behaviorContext * * * Returns : returns the error code * ******************************************************************* */ CGBLCOError CGBLLAERemoveUser::RemoveUser(const CKBehaviorContext& behaviorContext) { CKBehavior *behavior=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError errorReturn(CGBLCOError::EGBLCOErrorType::GBLCO_OK); CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)context->GetManagerByGuid(GBLSMStorageManagerGUID); if(storageManager) { IGBLSMLAEAccess* smLAEAccess=storageManager->GetLAEInterface(); if(smLAEAccess) { int nLAEID; CGBLLAEID laeID; behavior->GetInputParameter(EGBLRemoveUserParamInputs::SetLAEID)->GetValue(&nLAEID); laeID = nLAEID; CKDataArray *userIDs = (CKDataArray *)behavior->GetInputParameterObject(EGBLRemoveUserParamInputs::SetLAEUserIDList); for(int i=0; i< userIDs->GetRowCount() ;++i) { //CGBLUserID userID; int userID; userIDs->GetElementValue(i,0,&userID); CGBLCOError error = smLAEAccess->RemoveUser(laeID,userID); if(CGBLCOError::GBLCO_OK != error) { errorReturn = error; break; } } } else { errorReturn.SetCode ( GBLLAE_ERROR_REMOVEUSER ); errorReturn.SetDescription ( GBLLAE_ERROR_REMOVEUSER_DESC ); errorReturn.SetType ( CGBLCOError::GBLCO_LOCAL ); } } else { errorReturn.SetCode ( GBLLAE_ERROR_REMOVEUSER ); errorReturn.SetDescription ( GBLLAE_ERROR_REMOVEUSER_DESC ); errorReturn.SetType ( CGBLCOError::GBLCO_LOCAL ); } return errorReturn; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLPFRemovePlayer::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behaviour=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError returnValue; behaviour->ActivateInput(EGBLRemovePlayerBehInputs::RemovePlayer, false); CGBLTeamID TeamId; behaviour->GetInputParameterValue(EGBLRemovePlayerParamInputs::TeamId, &TeamId); CGBLUserID PlayerId; behaviour->GetInputParameterValue(EGBLRemovePlayerParamInputs::PlayerId, &PlayerId); CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(GBLProfileManagerGUID); returnValue = pm->RemoveTeamPlayer(TeamId, PlayerId); if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { behaviour->ActivateOutput(EGBLRemovePlayerBehOutputs::Success, true); } else { CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLRemovePlayerParamOutputs::ErrorCode); CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK ; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } const char*errorString = returnValue; TGBLError::SetTGBLError(pOut, tType,returnValue, (CKSTRING)errorString); behaviour->ActivateOutput(EGBLRemovePlayerBehOutputs::Error, true); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAEGetLA::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; IGBLSMProfileAccess* pin = NULL; CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID); IGBLSMLAAccess *laInterface = storageManager->GetLAInterface(); char *arrayName = "laList"; CKDataArray* array; array = (CKDataArray *)ctx->GetObjectByNameAndClass(arrayName,CKCID_DATAARRAY,NULL); if ( !array ) { array = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,arrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( array ); array->InsertColumn( -1, CKARRAYTYPE_INT, "LAID" ); } else { array->Clear(); } CGBLCOError res = laInterface->RetrieveLAList(array); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { beh->ActivateInput(0, FALSE); beh->SetOutputParameterObject(0, array); beh->ActivateOutput(0); } else { beh->ActivateInput(0, FALSE); CKParameterOut *parameterOutError = beh->GetOutputParameter(1); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_GETLISTOFLAIDS,GBLLAE_ERROR_GETLISTOFLAIDS_DESC); beh->ActivateOutput(1); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAETriggerSaving::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; CGBLLAEManager *laeManager = (CGBLLAEManager *)ctx->GetManagerByGuid(GBLLAEManagerGUID); if (laeManager) { if ( beh->IsInputActive(0) ) { laeManager->HandleSave ( ctx, beh->GetID() ); beh->ActivateInput(0, FALSE); return CKBR_ACTIVATENEXTFRAME; } } return CKBR_BEHAVIORERROR; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAESetLAEData::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; IGBLSMProfileAccess* pin = NULL; CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID); IGBLSMLAEAccess *laeInterface = storageManager->GetLAEInterface(); int cisid; CGBLLAID laid; XString xlaid; XString laeName; int laeState = 0; CKDataArray *userIDList = NULL; CGBLLAEID laeid = 0; int dlaeid; beh->GetInputParameterValue(1, &dlaeid); laeid = dlaeid; GBLLAEDataType::GetGBLLAEData(beh->GetInputParameter(0)->GetRealSource(), cisid, laeName, laeState, xlaid, &userIDList ); laid.FromString(xlaid); CGBLCOError res = laeInterface->StoreLAE (laeState, cisid, laid, laeName, &laeid); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { beh->ActivateInput(0, FALSE); beh->ActivateOutput(0); } else { CKParameterOut *parameterOutError = beh->GetOutputParameter(0); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_STORELAE,GBLLAE_ERROR_STORELAE_DESC); beh->ActivateOutput(1); } return CKBR_OK; }
/* ******************************************************************* * Function: int GetCIValue( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GetCIValue(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); BOOL getByName,getAsString,outputAttriubtes,outputOnChange = false; beh->GetLocalParameterValue(BEH_SETTINGS_GET_BY_NAME,&getByName); beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString); beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes); beh->GetLocalParameterValue(BEH_SETTINGS_OUTPUT_ON_CHANGE,&outputOnChange); // Beh Input 1 activated : switch of on event mode ///////////////////////////////////////////////// if( outputOnChange && beh->IsInputActive(1) ) { beh->ActivateInput(1,FALSE); return CKBR_OK; } using namespace GBLCommon::BehaviorTools; using namespace Customisation::typedefs; Customisation::typedefs::CIS* currentCIS = cman->GetCIS(); if( !currentCIS) { return CKBR_PARAMETERERROR; } CGBLCI *currentCI = NULL; //get by uniquie name mode ? if( getByName ) { CISIterator it = currentCIS->Find( new CGBLCIID (GetInputParameterValue<CKSTRING>(beh,0) , 0 ) ); if (it == currentCIS->End() ) { return CKBR_PARAMETERERROR; }else { currentCI = *it; } //////// then get the custom parameter : }else { CKParameter *ciPar = beh->GetInputParameter(0)->GetRealSource(); currentCI = static_cast<CGBLCI *>(ciPar->GetAppData()); if (!currentCI) { return CKBR_PARAMETERERROR; } } ////////////////////////////////////////////////////////////////////////// // output values : CKParameterOut *pout = beh->GetOutputParameter(0); if(getAsString) { //output the value VxScratch sbuffer(currentCI->realValue->GetDataSize()); CKSTRING buffer = (CKSTRING)sbuffer.Mem(); currentCI->realValue->GetStringValue(buffer); pout->SetStringValue(buffer); }else { CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); if ( beh->GetOutputParameter(0)->GetType() == currentCI->realValue->GetType() ) { pout->CopyValue(currentCI->realValue); }else { pout->SetType(currentCI->realValue->GetType()); return CKBR_PARAMETERERROR; } } using namespace GBLCommon::ParameterTools; ////////////////////////////////////////////////////////////////////////// // output custom attributes : if(outputAttriubtes) { //output unique name : CKParameterOut *poutName = beh->GetOutputParameter(BEH_OUT_INDEX_UNAME); poutName->SetStringValue(currentCI->name.Str()); //output description : CKParameterOut *poutDescription = beh->GetOutputParameter(BEH_OUT_INDEX_DESCRIPTION); poutDescription->SetStringValue(currentCI->description.Str()); //output default value : CKParameterOut *poutDefaultValue = beh->GetOutputParameter(BEH_OUT_INDEX_DEFAULTVALUE); TypeCheckedParameterCopy(poutDefaultValue,currentCI->defaultValue); if(getAsString) { XString outDefValue = GBLCommon::ParameterTools::GetParameterAsString(currentCI->defaultValue); poutDefaultValue->SetStringValue( outDefValue.Str() ); }else{ poutDefaultValue->CopyValue(currentCI->defaultValue,TRUE); } //output flags : int flags = 0 ; beh->SetOutputParameterValue(BEH_OUT_INDEX_FLAGS,¤tCI->flags); //output type int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type); beh->SetOutputParameterValue(BEH_OUT_INDEX_TYPE,&type); } if (outputOnChange && (currentCI->ciState & CGBLCI::GBL_CI_STATE::GBL_CI_CHANGED) ) { //reset state : currentCI->ciState = 0L; beh->ActivateOutput(0); } if (!outputOnChange) { beh->ActivateOutput(0); } return outputOnChange ? CKBR_ACTIVATENEXTFRAME : CKBR_OK; }
/* ******************************************************************* * Function: int CISIteratorBB( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CISIteratorBB(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); /*get the last index */ int index = 0; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX, &index); BOOL getFromDB = false; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_DB_MODE,&getFromDB); using namespace GBLCommon::BehaviorTools; using namespace GBLCommon::ParameterTools; using namespace Customisation::typedefs; /************************************************************************/ /* behavior trigger event processing : */ /* */ /* */ /* Reset/On : sets the index to zero and save it */ if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); if (getFromDB) { CKDataArray * resultArray = NULL; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray); if (resultArray) { resultArray->Clear(); while ( resultArray->GetColumnCount() ) resultArray->RemoveColumn(0); } else { resultArray = static_cast<CKDataArray*>(ctx->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::CIS_IDLIST", CK_OBJECTCREATION_DYNAMIC )); } ctx->GetCurrentLevel()->AddObject( resultArray ); ////////////////////////////////////////////////////////////////////////// retrieve list of CI ID's : CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); int idCIS = GetInputParameterValue<int>(beh,BEH_IN_PAR_CIS_ID); smCIS->RetrieveCIList(resultArray,CGBLCISID(idCIS)); beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray,sizeof(CKDataArray*)); int cis_size = resultArray->GetRowCount(); beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIS_SIZE,&cis_size); }else { Customisation::typedefs::CIS* currentCIS = cman->GetCIS(); if(!currentCIS) Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"CISIterator : couldn't find CIS"); } //reset counter : index = 0 ; beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index); beh->ActivateInput(1,TRUE); } //get LA_ID : int cisSize; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIS_SIZE,&cisSize); /* bounding check for the index: if out of range, set to zero and save it.*/ if(index > cisSize -1 ) { index = 0; beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index); beh->ActivateOutput(0); return CKBR_OK; } /* Loop In : */ if( beh->IsInputActive(1) ) { beh->ActivateInput(1,FALSE); CGBLCI *currentCI = NULL; //ctx->OutputToConsole("asfasdf"); if (getFromDB) { CKDataArray * resultArray = NULL; beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray); if (resultArray) { CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); CGBLCIConfigurationController* cman=static_cast<CGBLCIConfigurationController*>(ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID)); IGBLCIAccessInterface * accessInterface = cman->GetCISAccessInterface(); currentCI = new CGBLCI("temp",CKPGUID_INT); int idCI; resultArray->GetElementValue(index,0,&idCI); accessInterface->GetCI(currentCI,idCI); beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_DB_INDEX,&idCI); }else { ctx->OutputToConsole("wrong array"); } }else { Customisation::typedefs::CISIterator it = cman->GetCIS()->GetIteratorByIndex(index); currentCI = (CGBLCI *)*it; } if (currentCI) { //output name : CKParameterOut *outName = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_UNAME); outName->SetStringValue(currentCI->name.Str()); //output description: CKParameterOut *outDescr = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_DESCRIPTION); outDescr->SetStringValue(currentCI->description.Str()); //output type int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type); beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_TYPE,&type); //output value: CKParameterOut *outStrValue = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_VALUE); outStrValue->SetStringValue(GetParameterAsString(currentCI->realValue)); //output default value: CKParameterOut *outDefaultStrValue = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_DEFAULTVALUE); outDefaultStrValue->SetStringValue(GetParameterAsString(currentCI->defaultValue)); //output flags : beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_FLAGS,¤tCI->flags); }else { Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"CISIterator : couldn't find CI Parameter"); } //increase counter : index++; beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index); beh->ActivateOutput(1); } return CKBR_OK; }
int GBLCOCreateError::BehaviourFunction( const CKBehaviorContext& behContext ) { CKBehavior *behaviour = behContext.Behavior; CKContext *context = behContext.Context; if ( behaviour == NULL || context == NULL ) return CKBR_GENERICERROR; behaviour->ActivateInput(ECGBLCOCreateErrorBehInputs::In, FALSE); CGBLCOErrorManager *errorManager = (CGBLCOErrorManager *)context->GetManagerByGuid(CGBLCOErrorManagerGUID); if ( errorManager == NULL ) return CKBR_GENERICERROR; // Get Parameters Inputs Source. CKParameterOut *poutError = behaviour->GetOutputParameter(ECGBLCOCreateErrorParamOutputs::GetError); if ( poutError == NULL ) return CKBR_GENERICERROR; CKParameterIn*pinCode = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorCode); CKParameterIn*pinDesc = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorDescription); CKParameterIn*pinType = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorType); if ( pinCode == NULL || pinDesc == NULL || pinType == NULL ) return CKBR_GENERICERROR; CKParameter*paraCode = pinCode->GetRealSource(); CKParameter*paraDesc = pinDesc->GetRealSource(); CKParameter*paraType = pinType->GetRealSource(); if ( paraCode == NULL || paraDesc == NULL || paraType == NULL ) return CKBR_GENERICERROR; // Get Parameters Inputs Values (code,desc,type). int code = 0; paraCode->GetValue(&code); XString desc; int paramsize = paraDesc->GetStringValue(NULL); if (paramsize) { XAP<char> paramstring(new char[paramsize]); paraDesc->GetStringValue(paramstring,TRUE); desc << (char*)paramstring; } CGBLCOError::EGBLCOErrorType type; paraType->GetValue(&type); // Create the TGBLError parameter output. TGBLError::SetTGBLError(poutError,type,code,(CKSTRING)desc.CStr()); CK_CLASSID cid = poutError->GetClassID(); // if ( type != CGBLCOError::EGBLCOErrorType::GBLCO_FATAL ) { behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, FALSE); behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, TRUE); return CKBR_OK; } errorManager->NotifyError(type,code,(CKSTRING)desc.CStr()); behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, TRUE); behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, FALSE); return CKBR_OK; }
int CallPythonFunc2(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; XString File((CKSTRING) beh->GetInputParameterReadDataPtr(0)); XString Func((CKSTRING) beh->GetInputParameterReadDataPtr(1)); int reload=false; //= BehaviorTools::GetInputParameterValue<bool>(beh,2); beh->GetInputParameterValue(2,&reload); vt_python_man *pm = (vt_python_man*)ctx->GetManagerByGuid(INIT_MAN_GUID); CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager()); Python *py = pm->py; if (!pm->pLoaded) { pm->m_Context->OutputToConsoleEx("You must load Python before !"); beh->ActivateOutput(1,false); return CKBR_BEHAVIORERROR; } ////////////////////////////////////////////////////////////////////////// if( beh->IsInputActive(0) ) { try { PyObject *module = pm->InsertPModule(beh->GetID(),File,reload); PyObject* val = PyInt_FromLong(beh->GetID()); PyObject_SetAttrString( module , "bid", val); pm->CallPyModule(beh->GetID(),Func); } catch (Python_exception ex) { pm->m_Context->OutputToConsoleEx("PyErr : \t %s",(CKSTRING)ex.what()); std::cout << ex.what() << "pyexeption in beh : " << beh->GetName(); PyErr_Clear(); beh->ActivateOutput(1,false); } beh->ActivateInput(0,false); } ////////////////////////////////////////////////////////////////////////// else { for (int i = 1 ; i < beh->GetOutputCount() ; i++ ) { try { PyObject *module = pm->GetPModule(beh->GetID()); if(module) pm->CallPyModule(beh->GetID(),Func); } catch (Python_exception ex) { pm->m_Context->OutputToConsoleEx("PyErr : \t %s",(CKSTRING)ex.what()); std::cout << ex.what() << "pyexeption in beh : " << beh->GetName(); beh->ActivateOutput(1,TRUE); return CKBR_BEHAVIORERROR; } beh->ActivateInput(i,false); } } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLPFCreate::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behaviour=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError returnValue(CGBLCOError::EGBLCOErrorType::GBLCO_OK); CKBOOL newTeam = true; CKERROR check; behaviour->ActivateInput(EGBLCreateBehInputs::In, false); //newTeam = behaviour->IsInputParameterEnabled(EGBLCreateParamInputs::Teamname); CGBLUserID NewPlayerId; CGBLTeamID TeamId; CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(GBLProfileManagerGUID); int buf; check = behaviour->GetInputParameterValue(EGBLCreateParamInputs::LAEID, &buf); if(check != CK_OK|| buf==0) { newTeam = false; } CGBLLAEID LAEID(buf); XString TeamName((CKSTRING)behaviour->GetInputParameterReadDataPtr(EGBLCreateParamInputs::Teamname)); CGBLProfileManager::EGBLUserType userType; behaviour->GetInputParameterValue(EGBLCreateParamInputs::Type, &userType); XString UserName((CKSTRING) behaviour->GetInputParameterReadDataPtr(EGBLCreateParamInputs::Username)); if(newTeam) { returnValue = pm->CreateTeamProfile(&TeamId, LAEID, TeamName); } else { returnValue = pm->CreatePlayerProfile(&NewPlayerId, userType, UserName); } if ((int)returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { if (newTeam)//activate output with TeamId { behaviour->SetOutputParameterValue(EGBLCreateParamOutputs::ProfileId, &TeamId); } else //acitvate output with PlayerId { behaviour->SetOutputParameterValue(EGBLCreateParamOutputs::ProfileId, &NewPlayerId); } behaviour->ActivateOutput(EGBLCreateBehOutputs::Success, true); } else { CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLCreateParamOutputs::ErrorCode); CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK ; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } const char*errorString = returnValue; TGBLError::SetTGBLError(pOut, tType,returnValue, (CKSTRING)errorString); //behaviour->SetOutputParameterValue(EGBLCreateParamOutputs::ErrorCode, &returnValue); behaviour->ActivateOutput(EGBLCreateBehOutputs::Error, true); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLPFGetPlayers::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behaviour=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError returnValue; behaviour->ActivateInput(EGBLGetPlayersBehInputs::In, false); //initialise data array CKDataArray* FieldData = (CKDataArray*)context->CreateObject(CKCID_DATAARRAY, "FieldData", CK_OBJECTCREATION_DYNAMIC); CKDataArray *PlayerList; PlayerList = (CKDataArray*)behaviour->GetInputParameterObject(EGBLGetPlayersParamInputs::GetPlayerList); if(PlayerList == NULL) { behaviour->ActivateOutput(EGBLGetPlayersBehOutputs::Error, true); CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLGetPlayersParamOutputs::ErrorCode); CGBLCOError::EGBLCOErrorType tType; tType= CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; TGBLError::SetTGBLError(pOut, tType , 19021, "Missing or incorrect parameter provided"); } else { CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(GBLProfileManagerGUID); returnValue = pm->GetPlayers(PlayerList); if ((int)returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { behaviour->ActivateOutput(EGBLGetPlayersBehOutputs::Success, true); } else { CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLGetPlayersParamOutputs::ErrorCode); CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK ; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } const char*errorString = returnValue; TGBLError::SetTGBLError(pOut, tType,returnValue, (CKSTRING)errorString); behaviour->ActivateOutput(EGBLGetPlayersBehOutputs::Error, true); } } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int RetrieveCI(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); IGBLCIManageInterface *cisFac = cman->GetCISFactoryInterface(); IGBLCIAccessInterface * accessInterface = cman->GetCISAccessInterface(); BOOL getAsString,outputAttriubtes = false; beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString); beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes); using namespace GBLCommon::BehaviorTools; using namespace GBLCommon::ParameterTools; using namespace Customisation::typedefs; int idCI = GetInputParameterValue<int>(beh,BEH_PAR_INDEX_CI); CGBLCI *currentCI = NULL; CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); currentCI = new CGBLCI("temp",CKPGUID_INT); CGBLCOError returnValue = accessInterface->GetCI(currentCI,idCI); //get error parameter CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_PIN_OUT_INDEX_ERROR); // check results and output error if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { ////////////////////////////////////////////////////////////////////////// // output values : CKParameterOut *pout = beh->GetOutputParameter(1); if(getAsString) { //output the value VxScratch sbuffer(currentCI->realValue->GetDataSize()); CKSTRING buffer = (CKSTRING)sbuffer.Mem(); currentCI->realValue->GetStringValue(buffer); pout->SetStringValue(buffer); }else { CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); if ( beh->GetOutputParameter(0)->GetType() == currentCI->realValue->GetType() ) { pout->CopyValue(currentCI->realValue); }else { pout->SetType(currentCI->realValue->GetType()); return CKBR_PARAMETERERROR; } } ////////////////////////////////////////////////////////////////////////// // output custom attributes : if(outputAttriubtes) { //output unique name : CKParameterOut *poutName = beh->GetOutputParameter(BEH_OUT_INDEX_UNAME); poutName->SetStringValue(currentCI->name.Str()); //output description : CKParameterOut *poutDescription = beh->GetOutputParameter(BEH_OUT_INDEX_DESCRIPTION); poutDescription->SetStringValue(currentCI->description.Str()); //output default value : CKParameterOut *poutDefaultValue = beh->GetOutputParameter(BEH_OUT_INDEX_DEFAULTVALUE); TypeCheckedParameterCopy(poutDefaultValue,currentCI->defaultValue); if(getAsString) { XString outDefValue = GBLCommon::ParameterTools::GetParameterAsString(currentCI->defaultValue); poutDefaultValue->SetStringValue( outDefValue.Str() ); }else{ poutDefaultValue->CopyValue(currentCI->defaultValue,TRUE); } //output flags : int flags = 0 ; beh->SetOutputParameterValue(BEH_OUT_INDEX_FLAGS,¤tCI->flags); //output type int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type); beh->SetOutputParameterValue(BEH_OUT_INDEX_TYPE,&type); } TGBLError::SetTGBLError(parameterOutError,returnValue.GetType(),returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_SUCCESS, true); } else { CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } TGBLError::SetTGBLError(parameterOutError,tType,returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_ERROR, true); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAELoadControllers::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behavior=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; int returnValue = 0; if(behavior->IsInputActive(EGBLLoadControllersBehInputs::InLoad)) { CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLLoadControllersParamOutputs::GetError); CGBLChatManager *chatManager = (CGBLChatManager *)context->GetManagerByGuid(CGBLChatManagerGUID); if(!chatManager) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CHLOAD,GBLLAE_ERROR_CHLOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } CGBLCueManager *cueManager = (CGBLCueManager *)context->GetManagerByGuid(CGBLCueManagerGUID); if(!cueManager) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CULOAD,GBLLAE_ERROR_CULOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } CGBLLearningObjectiveManager *learningObjectiveManager = (CGBLLearningObjectiveManager *)context->GetManagerByGuid(CGBLLearningObjectiveManagerGUID); if(!learningObjectiveManager) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_LOLOAD,GBLLAE_ERROR_LOLOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } CGBLMeasuredObjectiveManager *measuredObjectiveManager = (CGBLMeasuredObjectiveManager *)context->GetManagerByGuid(CGBLMeasuredObjectiveManagerGUID); if(!measuredObjectiveManager) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_MOLOAD,GBLLAE_ERROR_MOLOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } CGBLConfigurationManager *configurationManager = (CGBLConfigurationManager *)context->GetManagerByGuid(CGBLConfigurationManagerGUID); if(!configurationManager) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CILOAD,GBLLAE_ERROR_CILOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } int nLAEID; CGBLLAEID laeID; behavior->GetInputParameter(EGBLLoadControllersParamInputs::SetLAEID)->GetValue(&nLAEID); laeID = nLAEID; CGBLCOError error; error = chatManager->Load(laeID); if(CGBLCOError::GBLCO_OK != error) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CHLOAD,GBLLAE_ERROR_CHLOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } error = cueManager->Load(laeID); if(CGBLCOError::GBLCO_OK != error) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CULOAD,GBLLAE_ERROR_CULOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } error = learningObjectiveManager->Load(laeID); if(CGBLCOError::GBLCO_OK != error) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_LOLOAD,GBLLAE_ERROR_LOLOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } error = measuredObjectiveManager->Load(laeID); if(CGBLCOError::GBLCO_OK != error) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_MOLOAD,GBLLAE_ERROR_MOLOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } error = configurationManager->Load(laeID); if(CGBLCOError::GBLCO_OK != error) { TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CILOAD,GBLLAE_ERROR_CILOAD_DESC); behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutError); return CKBR_GENERICERROR; } behavior->ActivateOutput(EGBLLoadControllersBehOutputs::OutLoaded); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLPFAddProfileField::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior *behaviour=behaviorContext.Behavior; CKContext *context = behaviorContext.Context; CGBLCOError returnValue; CKBOOL UseLOID=true; CKBOOL UseLAEID = true; behaviour->ActivateInput(EGBLAddProfileFieldBehInputs::In, false); XString FieldName ((CKSTRING) behaviour->GetInputParameterReadDataPtr(EGBLAddProfileFieldParamInputs::FieldName)); EGBLProfileFieldType type; EGBLProfileFieldType supportedType; behaviour->GetInputParameterValue(EGBLAddProfileFieldParamInputs::FieldType, &supportedType); switch(supportedType) { case TYPE_STRING: type = supportedType; break; case TYPE_INT: type = supportedType; break; case TYPE_FLOAT: type = supportedType; break; case TYPE_BOOL: type = supportedType; break; case TYPE_ANGLE: type = TYPE_OBJECT; break; case TYPE_PERCENTAGE: type = TYPE_BEOBJECT; break; case TYPE_VECTOR: type = TYPE_MATERIAL; break; case TYPE_VECTOR4: type = TYPE_TEXTURE; break; case TYPE_2DVECTOR: type = TYPE_SPRITE; break; case TYPE_QUATERNION: type = TYPE_3DENTITY; break; case TYPE_MATRIX: type = TYPE_SPRITE3D; break; case TYPE_COLOR: type = TYPE_OBJECT3D; break; default: type = TYPE_STRING; } CKERROR check; int bufLAEID=0; check = behaviour->GetInputParameterValue(EGBLAddProfileFieldParamInputs::LAEID, &bufLAEID); if(check !=CK_OK||bufLAEID==0) { UseLAEID= false; } int bufLOID=0; check = behaviour->GetInputParameterValue(EGBLAddProfileFieldParamInputs::LOID, &bufLOID); if(check !=CK_OK||bufLOID==0) { UseLOID= false; } CGBLLAEID LAEID = bufLAEID; CGBLLOID LOID = bufLOID; CGBLProfileID ProfileId; behaviour->GetInputParameterValue(EGBLAddProfileFieldParamInputs::ProfileID, &ProfileId); CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(GBLProfileManagerGUID); if (UseLOID && UseLAEID) { returnValue = pm->AddProfileField(ProfileId, LAEID, LOID, FieldName, type); } else if ( UseLAEID) { returnValue = pm->AddProfileField(ProfileId, LAEID, FieldName, type); } else { returnValue = pm->AddProfileField(ProfileId, FieldName, type); } if ((int)returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { behaviour->ActivateOutput(EGBLAddProfileFieldBehOutputs::Success, true); } else { CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLAddProfileFieldParamOutputs::ErrorCode); CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK ; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } const char*errorString = returnValue; TGBLError::SetTGBLError(pOut, tType,returnValue, (CKSTRING)errorString); behaviour->ActivateOutput(EGBLAddProfileFieldBehOutputs::Error, true); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Paramters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int CGBLLAEGetLAE::BehaviourFunction( const CKBehaviorContext& behaviorContext ) { CKBehavior* beh = behaviorContext.Behavior; CKContext* ctx = behaviorContext.Context; IGBLSMProfileAccess* pin = NULL; CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID); IGBLSMLAAccess *laInterface = storageManager->GetLAInterface(); IGBLSMLAEAccess *laeInterface = storageManager->GetLAEInterface(); char *laListArrayName = "laList"; CKDataArray* laListArray; laListArray = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,laListArrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( laListArray ); laListArray->InsertColumn( -1, CKARRAYTYPE_INT, "LAID" ); char *laeArrayName = "laeidList"; CKDataArray* laeArray; laeArray = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,laeArrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( laeArray ); laeArray->InsertColumn( -1, CKARRAYTYPE_INT, "LAEID" ); char *laelaArrayName = "laelaIDList"; CKDataArray* laelaArray; laelaArray = (CKDataArray *)ctx->GetObjectByNameAndClass(laelaArrayName,CKCID_DATAARRAY,NULL); if ( !laelaArray ) { laelaArray = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,laelaArrayName, CK_OBJECTCREATION_DYNAMIC); behaviorContext.CurrentLevel->AddObject( laelaArray ); laelaArray->InsertColumn( -1, CKARRAYTYPE_INT, "LAEID" ); laelaArray->InsertColumn( -1, CKARRAYTYPE_STRING, "LAID" ); } else { laelaArray->Clear(); } CGBLCOError res = laInterface->RetrieveLAList(laListArray); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { int count = laListArray->GetRowCount(); for (int i=0; i < count; i++) { //get list of laes for given la and add it to results list XString xLAID; CKSTRING valueField = NULL; int labelLength = laListArray->GetElementStringValue(i, 0, NULL); valueField = new CKCHAR[labelLength]; labelLength = laListArray->GetElementStringValue(i, 0, valueField); xLAID = valueField; delete valueField; CGBLLAID laid; laid.FromString(xLAID); CGBLCOError res = laeInterface->RetrieveLAEList(laeArray,laid); if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { int count = laeArray->GetRowCount(); for (int j=0; j < count; j++) { CKSTRING valueField = NULL; int labelLength = laeArray->GetElementStringValue(j, 0, NULL); valueField = new CKCHAR[labelLength]; labelLength = laeArray->GetElementStringValue(j, 0, valueField); laelaArray->AddRow(); laelaArray->SetElementStringValue(laelaArray->GetRowCount()-1, 0, valueField); laelaArray->SetElementStringValue(laelaArray->GetRowCount()-1, 1, xLAID.Str()); delete valueField; } } } beh->ActivateInput(0, FALSE); beh->SetOutputParameterObject(0, laelaArray); beh->ActivateOutput(0); } else { beh->ActivateInput(0, FALSE); CKParameterOut *parameterOutError = beh->GetOutputParameter(1); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_GETLISTOFLAIDS,GBLLAE_ERROR_GETLISTOFLAIDS_DESC); beh->ActivateOutput(1); } behaviorContext.CurrentLevel->RemoveObject(laListArray); ctx->DestroyObject(laListArray); behaviorContext.CurrentLevel->RemoveObject(laeArray); ctx->DestroyObject(laeArray); return CKBR_OK; }
/* ******************************************************************* * Function: int PacketIterator( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int PacketIterator(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); CGBLCONetwork *networkInterface = cman->GetNetworkInterface(); ////////////////////////////////////////////////////////////////////////// /* check network -interace : */ if(!networkInterface->IsValid()) { //try to init the network interface : if ( networkInterface->Init() != CGBLCOError::GBLCO_OK ) { return CKBR_PARAMETERERROR; } } ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //output packet info, this infos /*get the last index */ int index = 0; beh->GetLocalParameterValue(0, &index); /* bounding check for the index: if out of range, set to zero and save it.*/ if(index >= networkInterface->GetOutgoingPackets()->Size() ) { index = 0; beh->SetLocalParameterValue(0,&index); beh->ActivateOutput(0); return CKBR_OK; } /*************************************/ /* behavior trigger event processing : */ /* */ /* */ /* Reset/On : sets the index to zero and save it */ if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); index = 0 ; beh->SetLocalParameterValue(0,&index); beh->ActivateInput(1,TRUE); } /* Loop In : */ if( beh->IsInputActive(1) ) { beh->ActivateInput(1,FALSE); if(networkInterface->GetOutgoingPackets()->Size() && index < networkInterface->GetOutgoingPackets()->Size() ) { //the following call is virtual. Both versions of ForwardPacketToScript are passing parameters to this building block. cman->GetNetworkInterface()->ForwardPacketToScript(beh,index); index++; beh->SetLocalParameterValue(0,&index); return CKBR_OK; } } return CKBR_OK; }
int SetCIConnectionDetails(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; MeasuredObjectiveControllerMgr* mman=(MeasuredObjectiveControllerMgr*)ctx->GetManagerByGuid(MeasuredObjectiveControllerMgrGUID); CGBLSyncInterface * syninterface = CGBLLOArrayHandler::Instance()->GetSynInterface(); /************************************************************************/ /* check interface : */ /* */ if (!syninterface->isValidInterface()) { Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"interface wrong"); //try to init the network interface : if (!syninterface->Init(ctx)) { Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"not loaded"); return CKBR_BEHAVIORERROR; } } /************************************************************************/ /* process building block events : */ /* */ if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); XString message((CKSTRING) beh->GetInputParameterReadDataPtr(0)); int connectionID = -1; beh->GetInputParameterValue(1,&syninterface->connectionID); CKAttributeManager *aMan = static_cast<CKAttributeManager*>(ctx->GetAttributeManager()); ////////////////////////////////////////////////////////////////////////// //store connection details in the scipt dummies attribute : CKAttributeType gblNetworkAtt = aMan->GetAttributeTypeByName( GBL_API_ENTRY("NetworkDetails")); if (!syninterface->messageDummy->HasAttribute(gblNetworkAtt) ) { syninterface->messageDummy->SetAttribute(gblNetworkAtt); } GBLCommon::ParameterTools::SetParameterStructureValue<int>(syninterface->messageDummy->GetAttributeParameter(gblNetworkAtt),0,syninterface->connectionID); GBLCommon::ParameterTools::SetParameterStructureValue<CKSTRING>(syninterface->messageDummy->GetAttributeParameter(gblNetworkAtt),1,syninterface->messageName.Str()); ////////////////////////////////////////////////////////////////////////// //activate and execute the script : behcontext.CurrentScene->Activate(syninterface->synchronizeScript,true); behcontext.CurrentScene->Activate(syninterface->messageDummy,FALSE); syninterface->synchronizeScript->Execute(1); beh->ActivateOutput(0); } return CKBR_OK; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int GBLCIGetCIS_IDList(const CKBehaviorContext& behcontext) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // Retrieving min data : CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; beh->ActivateInput(0,false); // required managers CGBLCIConfigurationController* cman=static_cast<CGBLCIConfigurationController*>(ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID)); IGBLCIManageInterface *cisFac = cman->GetCISFactoryInterface(); CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); //get LAID from bb : CKParameter *parameterINGetLAID = beh->GetInputParameter(BEH_IN_INDEX_LAID)->GetRealSource(); using namespace GBLCommon::ParameterTools; //contruct c rep of the LAID : CGBLLAID laID( GetValueFromParameterStruct<int>(parameterINGetLAID,0,false), GetValueFromParameterStruct<int>(parameterINGetLAID,1,false) ); // get inout array : CKDataArray * resultArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(BEH_IN_INDEX_TARGETARRAY)); if(resultArray == NULL) { beh->ActivateOutput(1, true); CKParameterOut *pOut = beh->GetOutputParameter(0); CGBLCOError::EGBLCOErrorType tType; tType= CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; TGBLError::SetTGBLError(pOut, tType , 19021, "Missing or incorrect parameter provided"); return CKBR_OK; } //get error parameter CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_OUT_INDEX_ERROR); // get cis list CGBLCOError returnValue = smCIS->RetrieveCISIDList(laID,resultArray); // check results and output error if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { TGBLError::SetTGBLError(parameterOutError,returnValue.GetType(),returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_SUCCESS, true); } else { CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } TGBLError::SetTGBLError(parameterOutError,tType,returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_ERROR, true); } return CKBR_OK; }