bool UPawnActionsComponent::OnEvent(UPawnAction& Action, EPawnActionEventType::Type Event) { bool bResult = false; const FPawnActionEvent ActionEvent(Action, Event, ActionEventIndex++); if (Event != EPawnActionEventType::Invalid && ActionEvents.Find(ActionEvent) == INDEX_NONE) { ActionEvents.Add(ActionEvent); // if it's a first even enable tick if (ActionEvents.Num() == 1) { SetComponentTickEnabled(true); } bResult = true; } else if (Event == EPawnActionEventType::Invalid) { // ignore UE_VLOG(ControlledPawn, LogPawnAction, Warning, TEXT("Ignoring Action Event: Action %s Event %s") , *Action.GetName(), *GetEventName(Event)); } else { UE_VLOG(ControlledPawn, LogPawnAction, Warning, TEXT("Ignoring duplicate Action Event: Action %s Event %s") , *Action.GetName(), *GetEventName(Event)); } return bResult; }
void UPawnAction::OnChildFinished(UPawnAction& Action, EPawnActionResult::Type WithResult) { UE_VLOG(GetPawn(), LogPawnAction, Log, TEXT("%s> Child \'%s\' finished with result %s") , *GetName(), *Action.GetName(), *GetActionResultName(WithResult)); ensure(Action.ParentAction == this); ensure(ChildAction == &Action); Action.ParentAction = NULL; ChildAction = NULL; }
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; }