uint32 UPawnActionsComponent::AbortActionsInstigatedBy(UObject* const Instigator, EAIRequestPriority::Type Priority)
{
    uint32 AbortedActionsCount = 0;

    if (Priority == EAIRequestPriority::MAX)
    {
        // call for every regular priority
        for (int32 PriorityIndex = 0; PriorityIndex < EAIRequestPriority::MAX; ++PriorityIndex)
        {
            AbortedActionsCount += AbortActionsInstigatedBy(Instigator, EAIRequestPriority::Type(PriorityIndex));
        }
    }
    else
    {
        UPawnAction* Action = ActionStacks[Priority].GetTop();
        while (Action)
        {
            if (Action->GetInstigator() == Instigator)
            {
                OnEvent(*Action, EPawnActionEventType::InstantAbort);
                ++AbortedActionsCount;
            }
            Action = Action->ParentAction;
        }
    }

    return AbortedActionsCount;
}
示例#2
0
bool UPawnAction::PushChildAction(UPawnAction& Action)
{
	bool bResult = false;
	
	if (OwnerComponent != NULL)
	{
		UE_CVLOG( ChildAction != NULL
			, GetPawn(), LogPawnAction, Log, TEXT("%s> Pushing child action %s while already having ChildAction set to %s")
			, *GetName(), *Action.GetName(), *ChildAction->GetName());
		
		// copy runtime data
		// note that priority and instigator will get assigned as part of PushAction.

		bResult = OwnerComponent->PushAction(Action, GetPriority(), Instigator);

		// adding a check to make sure important data has been set 
		ensure(Action.GetPriority() == GetPriority() && Action.GetInstigator() == GetInstigator());
	}

	return bResult;
}