本文整理汇总了C++中CKBehavior::GetLocalParameterValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::GetLocalParameterValue方法的具体用法?C++ CKBehavior::GetLocalParameterValue怎么用?C++ CKBehavior::GetLocalParameterValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::GetLocalParameterValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PWOverlapSphereCB
//************************************
// Method: PWOverlapSphereCB
// FullName: PWOverlapSphereCB
// Access: public
// Returns: CKERROR
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
CKERROR PWOverlapSphereCB(const CKBehaviorContext& behcontext)
{
CKBehavior *beh = behcontext.Behavior;
switch(behcontext.CallbackMessage) {
case CKM_BEHAVIORATTACH:
case CKM_BEHAVIORLOAD:
case CKM_BEHAVIORSETTINGSEDITED:
{
DWORD groups;
beh->GetLocalParameterValue(bbS_Groups,&groups);
beh->EnableInputParameter(bbI_Groups,groups);
DWORD mask;
beh->GetLocalParameterValue(bbS_Mask,&mask);
beh->EnableInputParameter(bbI_Mask,mask);
}
break;
}
return CKBR_OK;
}
示例2: PBPhysicalizeCB
//************************************
// Method: PBPhysicalizeCB
// FullName: PBPhysicalizeCB
// Access: public
// Returns: CKERROR
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
CKERROR PBPhysicalizeCB(const CKBehaviorContext& behcontext)
{
CKBehavior *beh = behcontext.Behavior;
switch(behcontext.CallbackMessage) {
case CKM_BEHAVIORATTACH:
case CKM_BEHAVIORLOAD:
case CKM_BEHAVIORSETTINGSEDITED:
{
DWORD useDWorld;
beh->GetLocalParameterValue(bbS_USE_DEFAULT_WORLD,&useDWorld);
beh->EnableInputParameter(bbI_TargetWorld,!useDWorld);
/*
DWORD useDWorldSS;
beh->GetLocalParameterValue(bbS_USE_WORLD_SLEEP_SETTINGS,&useDWorldSS);
beh->EnableInputParameter(bbI_SleepSettings,!useDWorldSS);
DWORD useDWorldDS;
beh->GetLocalParameterValue(bbS_USE_WORLD_DAMPING_SETTINGS,&useDWorldDS);
beh->EnableInputParameter(bbI_DampingSettings,!useDWorldDS);
*/
DWORD useDWorldM;
beh->GetLocalParameterValue(bbS_USE_WORLD_MATERIAL,&useDWorldM);
beh->EnableInputParameter(bbI_Material,!useDWorldM);
}
break;
}
return CKBR_OK;
}
示例3: PJRevoluteCB
//************************************
// Method: PJRevoluteCB
// FullName: PJRevoluteCB
// Access: public
// Returns: CKERROR
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
CKERROR PJRevoluteCB(const CKBehaviorContext& behcontext)
{
CKBehavior *beh = behcontext.Behavior;
switch(behcontext.CallbackMessage) {
case CKM_BEHAVIORATTACH:
case CKM_BEHAVIORLOAD:
case CKM_BEHAVIORSETTINGSEDITED:
{
DWORD twistLimit;
beh->GetLocalParameterValue(1,&twistLimit);
beh->EnableInputParameter(bbI_HighLimit,twistLimit);
beh->EnableInputParameter(bbI_LowLimit,twistLimit);
DWORD springSwing;
beh->GetLocalParameterValue(0,&springSwing);
beh->EnableInputParameter(bbI_Spring,springSwing);
DWORD motor;
beh->GetLocalParameterValue(2,&motor);
beh->EnableInputParameter(bbI_Motor,motor);
break;
}
}
return CKBR_OK;
}
示例4: 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;
}
示例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.
*
* 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 CGBLBuildCommand::BehaviourFunction(const CKBehaviorContext& behaviorContext)
{
CKBehavior* behavior = behaviorContext.Behavior;
CKContext* context = behaviorContext.Context;
if( behavior->IsInputActive(EGBLBuildCommandBehInputs::BuildCommand) )
{
DeactivateInputs(behaviorContext);
DeactivateOutputs(behaviorContext);
return DoBuildCommand (behaviorContext);
}
if( behavior->IsInputActive(EGBLBuildCommandBehInputs::CancelOperation))
{
DeactivateInputs(behaviorContext);
DeactivateOutputs(behaviorContext);
ClearParameterOutputs (behaviorContext);
int stateValue = EGBLBuildCommandState::Initial;
behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);
int initialParameterPosition = 0;
behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &initialParameterPosition);
char *emptyString = "";
behavior->SetLocalParameterValue(commandStringLocalPos, emptyString, strlen(emptyString)+1);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Cancelled);
}
if( behavior->IsInputActive(EGBLBuildCommandBehInputs::ReadNextParameterValue))
{
DeactivateInputs(behaviorContext);
DeactivateOutputs(behaviorContext);
int stateValue = 0;
behavior->GetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);
if (! ( (stateValue == EGBLBuildCommandState::AwaitingParametersForUntargeted) || (stateValue == EGBLBuildCommandState::AwaitingParametersForNetwork) || (stateValue == EGBLBuildCommandState::GetTargets) ) )
{
int stateValue = EGBLBuildCommandState::Initial;
behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);
int initialParameterPosition = 0;
behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &initialParameterPosition);
char *emptyString = "";
behavior->SetLocalParameterValue(commandStringLocalPos, emptyString, strlen(emptyString)+1);
CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE_DESC);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
}
return DoReadNextParameterValue (behaviorContext);
}
return CKBR_OK;
}
示例6: TextureSinus
int TextureSinus(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
// we get the amount value
float xamp=0.1f;
beh->GetInputParameterValue(0, &xamp);
// we get the amount value
float yamp=0.1f;
beh->GetInputParameterValue(1, &yamp);
float l= 1.0f;
beh->GetInputParameterValue(2, &l);
// we get the saved uv's
VxUV* savedUV = (VxUV*) beh->GetLocalParameterReadDataPtr(0);
// we get the interpolated mesh
CKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);
int channel = -1;
beh->GetInputParameterValue(3, &channel);
int channelcount = mesh->GetChannelCount();
if (channel < -1 || channel >= channelcount) {
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
CKDWORD Stride;
VxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride,channel);
int pointsNumber = mesh->GetModifierUVCount(channel);
float time;
beh->GetLocalParameterValue(1, &time);
float t;
for( int i=0 ; i<pointsNumber ; i++, uvarray =(VxUV *)((BYTE *)uvarray + Stride)) {
t = ((float)i/pointsNumber-0.5f)*4.0f+time*l;
uvarray->u = savedUV[i].u + ( 0.5f - savedUV[i].u ) * xamp * cosf(t);
uvarray->v = savedUV[i].v + ( 0.5f - savedUV[i].v ) * yamp * sinf(t);
}
mesh->ModifierUVMove(channel);
float pi = 3.1415926535f;
time += behcontext.DeltaTime * 0.001f;
if(l*time > 2*pi)
time -= (2*pi / l);
beh->SetLocalParameterValue(1, &time);
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
return CKBR_OK;
}
示例7: GeneralCameraOrbitCallback
CKERROR GeneralCameraOrbitCallback(const CKBehaviorContext& context)
{
CKBehavior* beh = context.Behavior;
switch(context.CallbackMessage)
{
case CKM_BEHAVIORCREATE:
case CKM_BEHAVIORLOAD:
{
VxVector InitialAngles(INF,INF,INF);
beh->SetLocalParameterValue(LOCAL_INIT,&InitialAngles);
VxVector RotationAngles(0,0,0);
beh->SetLocalParameterValue(LOCAL_ROT,&RotationAngles);
}
break;
case CKM_BEHAVIORSETTINGSEDITED:
{
// Update the needed input for "returns"
CKBOOL Returns = TRUE;
beh->GetLocalParameterValue(LOCAL_RETURN,&Returns);
beh->EnableInputParameter(IN_SPEED_RETURN, Returns);
// Updates the needed inputs for limiting the move
CKBOOL Limited = TRUE;
beh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);
beh->EnableInputParameter(IN_MIN_H,Limited);
beh->EnableInputParameter(IN_MAX_H,Limited);
beh->EnableInputParameter(IN_MIN_V,Limited);
beh->EnableInputParameter(IN_MAX_V,Limited);
beh->EnableInputParameter(IN_MIN_ZOOM,Limited);
beh->EnableInputParameter(IN_MAX_ZOOM,Limited);
}
break;
default:
break;
}
return CKBR_OK;
}
示例8: MidiEvent
int MidiEvent(const CKBehaviorContext& behcontext)
{
CKBehavior *beh = behcontext.Behavior;
if( beh->IsInputActive(1) ){ // OFF
beh->ActivateInput(1, FALSE);
return CKBR_OK;
}
CKBOOL combiWasOK = FALSE;
if( beh->IsInputActive(0) ){ // ON
beh->ActivateInput(0, FALSE);
beh->SetLocalParameterValue(0, &combiWasOK);
} else {
beh->GetLocalParameterValue(0, &combiWasOK);
}
MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );
// Channel
int channel=0;
beh->GetInputParameterValue(0, &channel);
int note, count = beh->GetInputParameterCount();
//--- test if all input notes are activated or not
for( int a=1 ; a<count ; a++ ){
beh->GetInputParameterValue(a, ¬e);
if( !mm->IsNoteActive(note, channel) ) break;
}
if( a==count ){ // All notes are pressed
if( !combiWasOK ){
beh->ActivateOutput(0);
combiWasOK = TRUE;
beh->SetLocalParameterValue(0, &combiWasOK);
return CKBR_ACTIVATENEXTFRAME;
}
} else { // Not all notes are pressed
if( combiWasOK ){
beh->ActivateOutput(1);
combiWasOK = FALSE;
beh->SetLocalParameterValue(0, &combiWasOK);
return CKBR_ACTIVATENEXTFRAME;
}
}
return CKBR_ACTIVATENEXTFRAME;
}
示例9: 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;
}
示例10: onHit
bool pRayCastReport::onHit(const NxRaycastHit& hit)
{
CKBehavior *beh =(CKBehavior*)GetPMan()->m_Context->GetObject(mCurrentBehavior);
if ( beh )
{
pRayCastHits *carray = NULL;
beh->GetLocalParameterValue(0,&carray);
if (carray)
{
//carray->clear();
}else
{
carray = new pRayCastHits();
}
//carray->push_back(const_cast<NxRaycastHit&>(&hit));
NxRaycastHit *_hit = new NxRaycastHit();
_hit->distance = hit.distance;
_hit->faceID = hit.faceID;
_hit->flags = hit.flags;
_hit->internalFaceID = hit.internalFaceID;
_hit->materialIndex = hit.materialIndex;
_hit->shape = hit.shape;
_hit->u = hit.u;
_hit->v = hit.v;
_hit->worldImpact = hit.worldImpact;
_hit->worldNormal = hit.worldNormal;
const char *name = hit.shape->getName();
carray->push_back(_hit);
beh->SetLocalParameterValue(0,&carray);
}
return true;
}
示例11: PBGet2CB
//************************************
// Method: PBGet2CB
// FullName: PBGet2CB
// Access: public
// Returns: CKERROR
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
CKERROR PBGet2CB(const CKBehaviorContext& behcontext)
{
CKBehavior *beh = behcontext.Behavior;
switch(behcontext.CallbackMessage) {
case CKM_BEHAVIORATTACH:
case CKM_BEHAVIORLOAD:
case CKM_BEHAVIORSETTINGSEDITED:
{
DWORD collGroup;
beh->GetLocalParameterValue(bbI_CollisionGroup,&collGroup);
beh->EnableOutputParameter(bbI_CollisionGroup,collGroup);
DWORD kinematic;
beh->GetLocalParameterValue(bbI_Kinematic,&kinematic);
beh->EnableOutputParameter(bbI_Kinematic,kinematic);
DWORD grav;
beh->GetLocalParameterValue(bbI_Gravity,&grav);
beh->EnableOutputParameter(bbI_Gravity,grav);
DWORD coll;
beh->GetLocalParameterValue(bbI_Collision,&coll);
beh->EnableOutputParameter(bbI_Collision,coll);
DWORD mOff;
beh->GetLocalParameterValue(bbI_MassOffset,&mOff);
beh->EnableOutputParameter(bbI_MassOffset,mOff);
DWORD pOff;
beh->GetLocalParameterValue(bbI_ShapeOffset,&pOff);
beh->EnableOutputParameter(bbI_ShapeOffset,pOff);
}
break;
}
return CKBR_OK;
}
示例12: GeneralCameraOrbit
int GeneralCameraOrbit(const CKBehaviorContext& behcontext,INPUTPROCESSFUNCTION InputFunction)
{
// Get the behavior
CKBehavior* beh = behcontext.Behavior;
float delta = behcontext.DeltaTime;
// Current state of the behavior
CKBOOL stopping;
// Indicates the behavior we are stopping if returns, stop otherwise
CKBOOL Returns = TRUE;
beh->GetLocalParameterValue(LOCAL_RETURN,&Returns);
// Stop Entrance, we stop
if (beh->IsInputActive(1))
{
// Set IO State
beh->ActivateInput(1,FALSE);
// A protection in case we stop the behavior before having started it
VxVector InitialAngles;
beh->GetLocalParameterValue(LOCAL_INIT,&InitialAngles);
// Get current position
VxVector RotationAngles;
beh->GetLocalParameterValue(LOCAL_ROT,&RotationAngles);
// Stopping Now
stopping = TRUE;
beh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);
if ( !Returns || ((RotationAngles.x == 0) && (RotationAngles.y == 0)) ) {
beh->ActivateOutput(1,TRUE);
return CKBR_OK;
}
}
// Gets the current camera
CKCamera *Camera = (CKCamera *) beh->GetTarget();
if( !Camera ) return CKBR_OWNERERROR;
// Gets the target informations
VxVector TargetPosition;
beh->GetInputParameterValue(IN_TARGET_POS,&TargetPosition);
CK3dEntity* TargetRef = (CK3dEntity*)beh->GetInputParameterObject(IN_TARGET_REF);
//////////////////////////////////////////////
// Gets the input parameters of the behavior
//////////////////////////////////////////////
VxVector InitialAngles(0,0,0), RotationAngles(0,0,0);
// First entrance, sets the initial values here only
if (beh->IsInputActive(0))
{
// Sets IO State
beh->ActivateInput(0,FALSE);
beh->ActivateOutput(0,TRUE);
// Not Stopping
stopping = FALSE;
beh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);
// Compute the Initial Angles, the radius
VxVector InitialPosition;
Camera->GetPosition(&InitialPosition, TargetRef);
InitialPosition -= TargetPosition;
InitialAngles.z = Magnitude(InitialPosition);
if ( InitialAngles.z == 0.0f ) {
InitialAngles.x = 0.0f;
InitialAngles.y = 0.0f;
}
else {
// Vertical Polar Angle
float d;
InitialPosition.Normalize();
d = DotProduct(InitialPosition,VxVector::axisY());
// bound the value of d to avoid errors due to precision.
if (d < -1)
d = -1;
else if (d > 1)
d = 1;
InitialAngles.y = acosf(d);
// Horizontal Polar Angle
InitialPosition.y = 0;
if ( (InitialPosition.x == 0.0f) && (InitialPosition.y == 0.0f) && (InitialPosition.z == 0.0f) )
InitialAngles.x = PI/2;
else {
InitialPosition.Normalize();
d = DotProduct(InitialPosition,VxVector::axisX());
// bound the value of d to avoid eroors due to precision.
if (d < -1)
d = -1;
else if (d > 1)
d = 1;
InitialAngles.x = acosf(d);
d = DotProduct(InitialPosition,VxVector::axisZ());
//.........这里部分代码省略.........
示例13: DoBuildCommand
/*
*******************************************************************
* Function: int CGBLBuildCommand::DoBuildCommand(const CKBehaviorContext& behaviorContext)
*
* Description : Starts building the command. Find required GBLWaitForCommand BB,
* determine its target (GBLTarget) and take corresponded actions.
*
* Parameters :
* behaviourContext r Behavior context reference, which gives
* access to frequently used global objects
* ( context, level, manager, etc... )
*
*******************************************************************
*/
int CGBLBuildCommand::DoBuildCommand(const CKBehaviorContext& behaviorContext)
{
CKBehavior* behavior = behaviorContext.Behavior;
CKContext* context = behaviorContext.Context;
//set to initial state
int stateValue = EGBLBuildCommandState::Initial;
behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);
int initialParameterPosition = 0;
behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &initialParameterPosition);
char *emptyString = "";
behavior->SetLocalParameterValue(commandStringLocalPos, emptyString, strlen(emptyString)+1);
ClearParameterOutputs(behaviorContext);
int targetID = 0;
behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetCommandID, &targetID);
CKBehavior* targetBB = CGBLCommandUtil::GetTargetCommand (targetID, behaviorContext);
if (targetBB == NULL)
{
CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND_DESC);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
return CKBR_OK;
}
CK_ID targetBBID = targetBB->GetID();
behavior->SetLocalParameterValue (targetBBLocalPos, &targetBBID);
int gblTatgetType = -1;
targetBB->GetLocalParameterValue (CGBLWaitForCommand::EGBLWaitForCommandLocalVariables::EGBLFCTarget, &gblTatgetType);
switch (gblTatgetType)
{
case CGBLWaitForCommand::EGBLFCTarget::Untargeted:
{
XString commandString;
commandString << targetID << CGBLCommandUtil::commandSeparator;
behavior->SetLocalParameterValue(commandStringLocalPos, commandString.Str(), strlen(commandString.Str()) + 1 );
return DoHandleNextLocalArgument (behaviorContext);
}
break;
case CGBLWaitForCommand::EGBLFCTarget::Player:
case CGBLWaitForCommand::EGBLFCTarget::Team:
{
//set state to GetTargets
int stateValue = EGBLBuildCommandState::GetTargets;
behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos,&stateValue);
//get list of recipients
behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetTarget, &gblTatgetType);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::ListRecipients);
return CKBR_OK;
}
break;
default:
CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_UNSPECIFIED_RECIPIENT,GBLFC_ERROR_BUILDCOMMAND_UNSPECIFIED_RECIPIENT_DESC);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
break;
}
return CKBR_OK;
}
示例14: DoReadNextParameterValue
/*
*******************************************************************
* Function: int CGBLBuildCommand::DoReadNextParameterValue (const CKBehaviorContext& behaviorContext)
*
* Description : Read next provided argument from SetParameterString p-in and add it to command string
*
* Parameters :
* behaviourContext r Behavior context reference, which gives
* access to frequently used global objects
* ( context, level, manager, etc... )
*
*******************************************************************
*/
int CGBLBuildCommand::DoReadNextParameterValue (const CKBehaviorContext& behaviorContext)
{
CKBehavior* behavior = behaviorContext.Behavior;
CKContext* context = behaviorContext.Context;
int gblBuildCommandState;
behavior->GetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState);
switch (gblBuildCommandState)
{
case EGBLBuildCommandState::Initial:
{
CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE_DESC);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
return CKBR_OK;
}
break;
case EGBLBuildCommandState::GetTargets:
{
//check if the array of recipients is provided
void* recipients = NULL;
recipients = behavior->GetInputParameter (EGBLBuildCommandParamInputs::SetDests)->GetDirectSource()->GetValueObject();
if (recipients == NULL)
{
CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_NO_DESTS,GBLFC_ERROR_BUILDCOMMAND_NO_DESTS_DESC);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
return CKBR_OK;
}
int targetID = 0;
behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetCommandID, &targetID);
XString commandString;
commandString << targetID << CGBLCommandUtil::commandSeparator;
behavior->SetLocalParameterValue(commandStringLocalPos, commandString.Str(), strlen(commandString.Str()) + 1 );
//check if there are more arguments
return DoHandleNextNetworkArgument (behaviorContext);
}
break;
case EGBLBuildCommandState::AwaitingParametersForNetwork:
case EGBLBuildCommandState::AwaitingParametersForUntargeted:
{
CKSTRING commandString = (CKSTRING) behavior->GetLocalParameter(commandStringLocalPos)->GetReadDataPtr();
CKSTRING argumentString = (CKSTRING) behavior->GetInputParameter(EGBLBuildCommandParamInputs::SetParameterString)->GetReadDataPtr();
//char commandString[512];
//char argumentString[512];
//behavior->GetLocalParameterValue(commandStringLocalPos,&commandString);
//behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetParameterString, &argumentString);
if (strlen (argumentString) == 0)
{
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::InvalidValue);
return CKBR_OK;
}
CKSTRING argumentType = (CKSTRING) behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetArgumentType)->GetReadDataPtr();
if ( (strcmp (argumentType, "Integer") == 0) || (strcmp (argumentType, "Float") == 0))
{
bool isArgumentNumeric = CGBLCommandUtil::IsNumeric(argumentString);
if (!isArgumentNumeric)
{
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::InvalidValue);
return CKBR_OK;
}
}
XString updatedCommandString;
updatedCommandString << commandString << argumentString << CGBLCommandUtil::commandSeparator;
behavior->SetLocalParameterValue(commandStringLocalPos, updatedCommandString.Str(), strlen(updatedCommandString.Str()) + 1 );
if (gblBuildCommandState == EGBLBuildCommandState::AwaitingParametersForUntargeted)
{
return DoHandleNextLocalArgument (behaviorContext);
}
return DoHandleNextNetworkArgument (behaviorContext);
//.........这里部分代码省略.........
示例15: RetrieveCI
/*
*******************************************************************
* 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());
//.........这里部分代码省略.........