本文整理汇总了C++中CKBehavior::Activate方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::Activate方法的具体用法?C++ CKBehavior::Activate怎么用?C++ CKBehavior::Activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::Activate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BehaviourFunction
int GBLCOBGWrapper::BehaviourFunction( const CKBehaviorContext& behContext )
{
CKBehavior *behaviour = behContext.Behavior;
CKContext *context = behContext.Context;
int iPin, nbPin;
CKBehavior* script = (CKBehavior*)behaviour->GetLocalParameterObject(EGBLCOBGWRAPPERPARAM_PARAMETER_SCRIPT);
if (script == NULL)
return CKBR_GENERICERROR;
// Activate the right inputs
nbPin = behaviour->GetInputCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
if (behaviour->IsInputActive(iPin))
{
script->ActivateInput(iPin, TRUE);
behaviour->ActivateInput(iPin, FALSE);
}
}
// Deactivate all the outputs
nbPin = script->GetOutputCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
behaviour->ActivateOutput(iPin, FALSE);
}
// Parameter In: Set Source
int nbPinBB = behaviour->GetInputParameterCount();
int nbPinBG = script->GetInputParameterCount();
if (nbPinBB != nbPinBG)
return CKBR_GENERICERROR;
for (iPin = 0; iPin < nbPinBB; iPin++)
{
CKParameterIn *pBin = behaviour->GetInputParameter(iPin);
CKParameter* pSource = pBin->GetDirectSource();
CKParameterIn *pSin = script->GetInputParameter(iPin);
pSin->SetDirectSource(pSource);
}
// Execute the contained script
CKERROR result = script->Execute(behContext.DeltaTime);
// The script loop on itself too much times
if (result == CKBR_INFINITELOOP)
{
context->OutputToConsoleExBeep("Execute Script : Script %s Executed too much times",script->GetName());
script->Activate(FALSE,FALSE);
return CKBR_OK;
}
// Activate the right outputs
nbPin = script->GetOutputCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
if (script->IsOutputActive(iPin))
{
behaviour->ActivateOutput(iPin);
script->ActivateOutput(iPin, FALSE);
}
}
// Update Parameters Out
nbPin = behaviour->GetOutputParameterCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
CKParameterOut *pBout = behaviour->GetOutputParameter(iPin);
CKParameterOut *pSout = script->GetOutputParameter(iPin);
pBout->CopyValue(pSout, TRUE);
}
// Test if there are any active sub-behaviors, restart the next frame if any
BOOL bActivateNextFrame = FALSE;
ActivateNextFrameSubBB(script,bActivateNextFrame);
if (bActivateNextFrame)
return CKBR_ACTIVATENEXTFRAME;
// return the execute value
return result;
}