本文整理汇总了C++中CKContext类的典型用法代码示例。如果您正苦于以下问题:C++ CKContext类的具体用法?C++ CKContext怎么用?C++ CKContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CKContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadCIS
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;
}
示例2: GetNextBBId
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;
}
示例3: BehaviourFunction
/*
*******************************************************************
* 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;
}
示例4: PluginCallback
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;
}
}
示例5: BehaviourFunction
/*
*******************************************************************
* 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;
}
示例6: GetTargetCommand
/*
*******************************************************************
* 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;
}
示例7: BehaviourFunction
/*
*******************************************************************
* 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="Mona";
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;
}
示例8: BehaviourFunction
/*
*******************************************************************
* 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;
}
示例9: RegisterAttributeType
//************************************
// 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;
}
示例10: RetrieveCICB
/*
*******************************************************************
* 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;
}
示例11: SetCIConnectionDetails
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;
}
示例12: GetCIS
/*
*******************************************************************
* 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;
}
示例13: CISIteratorCB
/*
*******************************************************************
* 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;
}
示例14: PluginCallback
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;
}
}
示例15: BehaviourFunction
/*
*******************************************************************
* 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;
}