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; }
int GetNextBBId(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; beh->ActivateInput(0,FALSE); int count = beh->GetParent()->GetSubBehaviorLinkCount(); int result = -1; for (int i=0; i<count; i++) { CKBehaviorLink *link = beh->GetParent()->GetSubBehaviorLink(i); if (link->GetInBehaviorIO() == beh->GetOutput(0)) { result = link->GetOutBehaviorIO()->GetOwner()->GetID(); beh->SetOutputParameterValue(0,&result); break; } } CKBehavior *script = static_cast<CKBehavior*>(ctx->GetObject(result)); if (script) { int bc = script->GetOutputCount(); int bc2 = script->GetInputCount(); } beh->ActivateOutput(0); beh->SetOutputParameterValue(0,&result); return CKBR_OK; }
int AddNodalLink(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CKAttributeManager* attman = ctx->GetAttributeManager(); beh->ActivateInput(0,FALSE); beh->ActivateOutput(0); CKGroup* group = (CKGroup*)beh->GetInputParameterObject(0); CKParameterOut* param = group->GetAttributeParameter(attman->GetAttributeTypeByName(Network3dName)); if(!param) throw "Given Group isn't a Network"; N3DGraph* graph; param->GetValue(&graph); CK3dEntity* s = (CK3dEntity*)beh->GetInputParameterObject(1); CK3dEntity* e = (CK3dEntity*)beh->GetInputParameterObject(2); float b; beh->GetInputParameterValue(3,&b); graph->InsertEdge(s,e,b); 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. * * 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; }
void PluginCallback(PluginInfo::CALLBACK_REASON reason,PluginInterface* plugininterface) { s_Plugininterface = plugininterface; CKContext *ctx = s_Plugininterface->GetCKContext(); switch(reason) { case PluginInfo::CR_LOAD: { ////////////////////////////////////////////////////////////////////////// // // this attachs the custom dialog to the Configurable Information"(CGBLCI). CKParameterManager *pm = ctx->GetParameterManager(); CKParameterTypeDesc *param_desc = pm->GetParameterTypeDescription(CKGUID_CGBLM_PARAMETER); if ( pm && param_desc ) { param_desc->UICreatorFunction = ConfigurableInformationUIFunc; } /* // this attachs the gui dialog for CKPGUID_STRING to the GBLCO_FILE_TYPE. CKParameterTypeDesc *param_descFType = pm->GetParameterTypeDescription(GBLCO_FILE_TYPE); CKParameterTypeDesc *param_descString = pm->GetParameterTypeDescription(CKPGUID_STRING); if ( param_descFType ) { param_descFType->UICreatorFunction = param_descString->UICreatorFunction; } */ }break; } }
/* ******************************************************************* * 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: CKBehavior* GetTargetCommand(const int commandId, const CKBehaviorContext& behaviorContext) * * Description : Gets target behavior object given the command ID * * Paramters : * * commandId r command id of the target object to get * behaviorContext r context * * Returns : * pointer to the behavior object, NULL if no object found * ******************************************************************* */ CKBehavior* CGBLCommandController::GetTargetCommand(const int commandId, const CKBehaviorContext& behaviorContext) { CKBehavior* targetBehavior = NULL; CKContext* context = behaviorContext.Context; int behaviorCount = context->GetObjectsCountByClassID(CKCID_BEHAVIOR); CK_ID* behaviorIds = context->GetObjectsListByClassID(CKCID_BEHAVIOR); int currentID; for (int i = 0; i < behaviorCount; ++i) { CKBehavior* behavior = (CKBehavior*)context->GetObject(behaviorIds[i]); if (behavior->GetPrototypeGuid() == GUID_GBLWAITFORCOMMAND_PROTOTYPE) { CKParameterLocal *localParam = NULL; localParam = behavior->GetLocalParameter(2); //Get command ID if (localParam != NULL) { localParam->GetValue(¤tID); //Get command ID's value localParam = NULL; } else { break; } if (currentID == commandId) { targetBehavior = behavior; break; } } } return targetBehavior; }
/* ******************************************************************* * 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 GetLastFileName(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; XString Inpath (ctx->GetLastCmoLoaded()); CKParameterOut *pout = beh->GetOutputParameter(0); pout->SetStringValue(Inpath.Str()); PathRemoveFileSpec(Inpath.Str()); CKParameterOut *pout2 = beh->GetOutputParameter(1); pout2->SetStringValue(Inpath.Str()); beh->ActivateOutput(0); return 0; }
/* ******************************************************************* * 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; }
//************************************ // Method: RegisterAttributeType // FullName: RegisterAttributeType // Access: public // Returns: int // Qualifier: // Parameter: const CKBehaviorContext& behcontext //************************************ int RegisterAttributeType(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; PhysicManager *pm = GetPMan(); CKAttributeManager* attman = ctx->GetAttributeManager(); CKParameterManager *pMan = ctx->GetParameterManager(); using namespace vtTools::BehaviorTools; if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); CKSTRING name = GetInputParameterValue<CKSTRING>(beh,bbI_Name); CKSTRING category = GetInputParameterValue<CKSTRING>(beh,bbI_Category); CKSTRING defValue = GetInputParameterValue<CKSTRING>(beh,bbI_DefValue); int pType = GetInputParameterValue<int>(beh,bbI_PType); CK_CLASSID classId = GetInputParameterValue<CK_CLASSID>(beh,bbI_Class); int attFlags = 0 ; int user = GetInputParameterValue<int>(beh,bbI_User); int save = GetInputParameterValue<int>(beh,bbI_Save); if(user) attFlags|=CK_ATTRIBUT_USER; if(save) attFlags|=CK_ATTRIBUT_TOSAVE; attFlags|=CK_ATTRIBUT_CAN_DELETE; CKAttributeType aIType = attman->GetAttributeTypeByName(name); if (aIType!=-1) { beh->ActivateOutput(1); } int att = attman->RegisterNewAttributeType(name,pMan->ParameterTypeToGuid(pType),classId,(CK_ATTRIBUT_FLAGS)attFlags); if (strlen(category)) { attman->AddCategory(category); attman->SetAttributeCategory(att,category); } if (strlen(defValue)) { attman->SetAttributeDefaultValue(att,defValue); } } pm->populateAttributeFunctions(); pm->_RegisterAttributeCallbacks(); beh->ActivateOutput(0); return 0; }
CKERROR CallPythonFuncCB2(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior *beh = behcontext.Behavior; CKContext* ctx = beh->GetCKContext(); CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); /************************************************************************/ /* process virtools callbacks : */ /* */ switch(behcontext.CallbackMessage) { case CKM_BEHAVIOREDITED: case CKM_BEHAVIORSETTINGSEDITED: { assert(beh && ctx); int p_count = beh->GetOutputParameterCount(); /*while( (BEH_OUT_MIN_COUNT ) < p_count ) { CKDestroyObject( beh->RemoveOutputParameter( --p_count) ); }*/ XString name("PyFuncX: "); name << ((CKSTRING) beh->GetInputParameterReadDataPtr(1)); if ( strlen(((CKSTRING) beh->GetInputParameterReadDataPtr(1))) ==0) { XString name("PyFileX: "); name << ((CKSTRING) beh->GetInputParameterReadDataPtr(0)); beh->SetName(name.Str()); break; } beh->SetName(name.Str()); break; } case CKM_BEHAVIORATTACH: case CKM_BEHAVIORLOAD : { XString name("PyFuncX: "); name << ((CKSTRING) beh->GetInputParameterReadDataPtr(1)); beh->SetName(name.Str()); if ( strlen(((CKSTRING) beh->GetInputParameterReadDataPtr(1))) ==0) { XString name("PyFileX: "); name << ((CKSTRING) beh->GetInputParameterReadDataPtr(0)); beh->SetName(name.Str()); break; } } } return CKBR_OK; }
/* ******************************************************************* * Function: int RetrieveCICB( 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 RetrieveCICB(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior *beh = behcontext.Behavior; CKContext* ctx = beh->GetCKContext(); CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); /************************************************************************/ /* process virtools callbacks : */ /* */ switch(behcontext.CallbackMessage) { case CKM_BEHAVIOREDITED: case CKM_BEHAVIORSETTINGSEDITED: { assert(beh && ctx); BOOL getAsString,outputAttriubtes = false; beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString); beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes); ////////////////////////////////////////////////////////////////////////// // get ci by string if(getAsString) { CKParameterOut* ciValue = beh->GetOutputParameter(0); ciValue->SetType(pm->ParameterGuidToType(CKPGUID_STRING)); } if(outputAttriubtes) { beh->CreateOutputParameter("Default Value",CKPGUID_STRING); beh->CreateOutputParameter("Unique name",CKPGUID_STRING); beh->CreateOutputParameter("Description",CKPGUID_STRING); beh->CreateOutputParameter("Runtime flags",CIPRTFLAGSGUID); beh->CreateOutputParameter("Type",CKPGUID_PARAMETERTYPE); } int p_count = beh->GetOutputParameterCount(); while( (outputAttriubtes ? BEH_OUT_MAX_COUNT : BEH_OUT_MIN_COUNT ) < p_count ) { CKDestroyObject( beh->RemoveOutputParameter( --p_count) ); } } } 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 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 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; }
int FTPLogin(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; if( beh->IsInputActive(0)){ beh->ActivateInput(0,FALSE); HWND win = (HWND)ctx->GetMainWindow(); FtpInit(win); //HFILE hLogFile = _lcreat (LOG_FILE, 0); //FtpLogTo (hLogFile); FtpSetDefaultTimeOut (30); FtpSetPassiveMode(TRUE); FtpSetAsynchronousMode(); int Port; beh->GetInputParameterValue(3,&Port); XString Host((CKSTRING) beh->GetInputParameterReadDataPtr(0)); XString User((CKSTRING) beh->GetInputParameterReadDataPtr(1)); XString Pw((CKSTRING) beh->GetInputParameterReadDataPtr(2)); int Login = FtpLogin(Host.Str(),User.Str(),Pw.Str(),win,0); beh->SetOutputParameterValue(0,&Login); if (Login == 0)beh->ActivateOutput(0); else{ beh->ActivateOutput(2); return CKBR_OK; } return CKBR_ACTIVATENEXTFRAME; } if( beh->IsInputActive(1)){ beh->ActivateInput(1,FALSE); FtpCloseConnection(); FtpRelease (); beh->ActivateOutput(1); return CKBR_OK; } return CKBR_ACTIVATENEXTFRAME; }
void PluginCallback(PluginInfo::CALLBACK_REASON reason,PluginInterface* plugininterface) { s_Plugininterface = plugininterface; CKContext *ctx = s_Plugininterface->GetCKContext(); //Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"notif"); /* switch(plugininterface->GetLastNotification()->messageID) { // Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"notif"); //CUIK_NOTIFICATION_PRESEQUENCEDELETED } */ switch(reason) { case PluginInfo::CR_LOAD: { ////////////////////////////////////////////////////////////////////////// // // this attachs the custom dialog to the Configurable Information"(CGBLCI). CKParameterManager *pm = ctx->GetParameterManager(); CKParameterTypeDesc *param_desc = pm->GetParameterTypeDescription(CIPARAMETERGUID); if ( pm && param_desc ) { param_desc->UICreatorFunction = ConfigurableInformationUIFunc; } // this attachs the gui dialog for CKPGUID_STRING to the GBLCO_FILE_TYPE. CKParameterTypeDesc *param_descFType = pm->GetParameterTypeDescription(GBLCO_FILE_TYPE); CKParameterTypeDesc *param_descString = pm->GetParameterTypeDescription(CKPGUID_STRING); if ( param_descFType ) { param_descFType->UICreatorFunction = param_descString->UICreatorFunction; } }break; } }
/* ******************************************************************* * 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; }
int GBLCOSetID::BehaviourFunction( const CKBehaviorContext& behContext ) { CKBehavior *behaviour = behContext.Behavior; CKContext *context = behContext.Context; behaviour->ActivateInput(ECGBLCOSetLAIDBehInputs::InSetIdentity, FALSE); CKAttributeManager*attributeManager = context->GetAttributeManager(); if (attributeManager != NULL) { CKLevel *level = context->GetCurrentLevel(); if ( level != NULL ) { int attributeType = attributeManager->GetAttributeTypeByName("GBLCOLAID"); if (attributeType == -1) attributeType = attributeManager->RegisterNewAttributeType("GBLCOLAID", GUID_TGBLLAID, CKCID_BEOBJECT); else if ( level->HasAttribute(attributeType) ) level->RemoveAttribute(attributeType); attributeManager->SetAttributeCategory(attributeType,"GBL"); level->SetAttribute(attributeType); CKParameter*attribute = level->GetAttributeParameter(attributeType); if ( attribute != NULL ) { CKParameterIn*pin = behaviour->GetInputParameter(ECGBLCOSetLAIDBehInputs::InSetIdentity); CKParameter*laid = pin->GetDirectSource(); if ( laid != NULL ) { CKERROR err = attribute->CopyValue(laid); if ( err == CK_OK ) { behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, TRUE); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, FALSE); return CKBR_OK; } } } } } CKParameterOut *parameterOutError = behaviour->GetOutputParameter(ECGBLCOSetLAIDParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLCO_ERROR_SETID_ATTRIBUTE,GBLCO_ERROR_SETID_ATTRIBUTE_DESC); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, FALSE); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, TRUE); return CKBR_GENERICERROR; }
/* ******************************************************************* * 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; }
int HasFFEffects(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; HWND mWin = (HWND )ctx->GetMainWindow(); DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI2, NULL ) ; // Get the first enumerated force feedback device g_pDI2->EnumDevices( 0, EnumFFDevicesCallback0, 0, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK ); if( g_pFFDevice2 == NULL ) beh->ActivateOutput(1); else beh->ActivateOutput(0); FreeDirectInput0(); return CKBR_OK; }
void PhysicManager::_RegisterBodyParameterFunctions() { return; CKContext* ctx = GetContext(); CKParameterManager *pm = ctx->GetParameterManager(); CKParameterTypeDesc *param_desc = pm->GetParameterTypeDescription(VTF_PHYSIC_BODY_COMMON_SETTINGS); if( !param_desc ) return; if (param_desc->CreateDefaultFunction!=0) { xLogger::xLog(ELOGERROR,E_LI_AGEIA,"has function"); bodyCreateFuncOld = param_desc->CreateDefaultFunction; param_desc->CreateDefaultFunction = (CK_PARAMETERCREATEDEFAULTFUNCTION)bodyDefaultFunctionMerged; } //param_desc->UICreatorFunction = CKActorUIFunc; //param_desc->UICreatorFunction = CKDoubleUIFunc; }
/* ******************************************************************* * Function: int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) * * Description : This function sets corresponding outputs with requested argument's * name, type and if the type of arguments is TGBLFCStringFromList, it also * provides designer specified list array with GetDesignerSpecifiedList output. * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * * nextArgument r Required argument to have parameters provided by the command * * targetBB r Target GBLWaitForCommand building block * * Returns : int, The return value is 0 if no error occured or -1 on error * ******************************************************************* */ int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; XString typeName = context->GetParameterManager()->ParameterTypeToName(nextArgument->GetType()); XString argumentName = nextArgument->GetName(); if (typeName == "TGBLFCStringFromList") { int inputs = targetBB->GetInputParameterCount(); for (int i=0; i<inputs; i++) { CKParameterIn *parameterInput = targetBB->GetInputParameter(i); if ( argumentName == parameterInput->GetName() ) { CKParameterOut *parameterOutput = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetDesignerSpecifiedList); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterOutput->GetType()), FALSE); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterInput->GetType()), FALSE); parameterOutput->CopyValue (parameterInput->GetDirectSource()); break; } } } behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentType, typeName.Str(), strlen (typeName.Str()) + 1 ); behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentName, argumentName.Str(), strlen (argumentName.Str()) + 1 ); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::GetNextParameterValue); return 0; }
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 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; }