style: apply clang format
This commit is contained in:
		| @@ -16,15 +16,15 @@ DEFINE_LOG_CATEGORY(LogTemplateCharacter); | ||||
|  | ||||
| AUTAD_UIPlayerController::AUTAD_UIPlayerController() | ||||
| { | ||||
| 	bShowMouseCursor = true; | ||||
| 	bShowMouseCursor   = true; | ||||
| 	DefaultMouseCursor = EMouseCursor::Default; | ||||
| 	CachedDestination = FVector::ZeroVector; | ||||
| 	FollowTime = 0.f; | ||||
| 	CachedDestination  = FVector::ZeroVector; | ||||
| 	FollowTime		   = 0.f; | ||||
| } | ||||
|  | ||||
| void AUTAD_UIPlayerController::BeginPlay() | ||||
| { | ||||
| 	// Call the base class   | ||||
| 	// Call the base class | ||||
| 	Super::BeginPlay(); | ||||
| } | ||||
|  | ||||
| @@ -34,29 +34,52 @@ void AUTAD_UIPlayerController::SetupInputComponent() | ||||
| 	Super::SetupInputComponent(); | ||||
|  | ||||
| 	// Add Input Mapping Context | ||||
| 	if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer())) | ||||
| 	if (UEnhancedInputLocalPlayerSubsystem* Subsystem = | ||||
| 			ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>( | ||||
| 				GetLocalPlayer())) | ||||
| 	{ | ||||
| 		Subsystem->AddMappingContext(DefaultMappingContext, 0); | ||||
| 	} | ||||
|  | ||||
| 	// Set up action bindings | ||||
| 	if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(InputComponent)) | ||||
| 	if (UEnhancedInputComponent* EnhancedInputComponent = | ||||
| 			Cast<UEnhancedInputComponent>(InputComponent)) | ||||
| 	{ | ||||
| 		// Setup mouse input events | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Started, this, &AUTAD_UIPlayerController::OnInputStarted); | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Triggered, this, &AUTAD_UIPlayerController::OnSetDestinationTriggered); | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Completed, this, &AUTAD_UIPlayerController::OnSetDestinationReleased); | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Canceled, this, &AUTAD_UIPlayerController::OnSetDestinationReleased); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationClickAction, ETriggerEvent::Started, this, | ||||
| 			&AUTAD_UIPlayerController::OnInputStarted); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationClickAction, ETriggerEvent::Triggered, this, | ||||
| 			&AUTAD_UIPlayerController::OnSetDestinationTriggered); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationClickAction, ETriggerEvent::Completed, this, | ||||
| 			&AUTAD_UIPlayerController::OnSetDestinationReleased); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationClickAction, ETriggerEvent::Canceled, this, | ||||
| 			&AUTAD_UIPlayerController::OnSetDestinationReleased); | ||||
|  | ||||
| 		// Setup touch input events | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Started, this, &AUTAD_UIPlayerController::OnInputStarted); | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Triggered, this, &AUTAD_UIPlayerController::OnTouchTriggered); | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Completed, this, &AUTAD_UIPlayerController::OnTouchReleased); | ||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Canceled, this, &AUTAD_UIPlayerController::OnTouchReleased); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationTouchAction, ETriggerEvent::Started, this, | ||||
| 			&AUTAD_UIPlayerController::OnInputStarted); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationTouchAction, ETriggerEvent::Triggered, this, | ||||
| 			&AUTAD_UIPlayerController::OnTouchTriggered); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationTouchAction, ETriggerEvent::Completed, this, | ||||
| 			&AUTAD_UIPlayerController::OnTouchReleased); | ||||
| 		EnhancedInputComponent->BindAction( | ||||
| 			SetDestinationTouchAction, ETriggerEvent::Canceled, this, | ||||
| 			&AUTAD_UIPlayerController::OnTouchReleased); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input Component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this)); | ||||
| 		UE_LOG( | ||||
| 			LogTemplateCharacter, Error, | ||||
| 			TEXT( | ||||
| 				"'%s' Failed to find an Enhanced Input Component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), | ||||
| 			*GetNameSafe(this)); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -70,17 +93,20 @@ void AUTAD_UIPlayerController::OnSetDestinationTriggered() | ||||
| { | ||||
| 	// We flag that the input is being pressed | ||||
| 	FollowTime += GetWorld()->GetDeltaSeconds(); | ||||
| 	 | ||||
| 	// We look for the location in the world where the player has pressed the input | ||||
|  | ||||
| 	// We look for the location in the world where the player has pressed the | ||||
| 	// input | ||||
| 	FHitResult Hit; | ||||
| 	bool bHitSuccessful = false; | ||||
| 	bool	   bHitSuccessful = false; | ||||
| 	if (bIsTouch) | ||||
| 	{ | ||||
| 		bHitSuccessful = GetHitResultUnderFinger(ETouchIndex::Touch1, ECollisionChannel::ECC_Visibility, true, Hit); | ||||
| 		bHitSuccessful = GetHitResultUnderFinger( | ||||
| 			ETouchIndex::Touch1, ECollisionChannel::ECC_Visibility, true, Hit); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		bHitSuccessful = GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, true, Hit); | ||||
| 		bHitSuccessful = GetHitResultUnderCursor( | ||||
| 			ECollisionChannel::ECC_Visibility, true, Hit); | ||||
| 	} | ||||
|  | ||||
| 	// If we hit a surface, cache the location | ||||
| @@ -88,12 +114,14 @@ void AUTAD_UIPlayerController::OnSetDestinationTriggered() | ||||
| 	{ | ||||
| 		CachedDestination = Hit.Location; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	// Move towards mouse pointer or touch | ||||
| 	APawn* ControlledPawn = GetPawn(); | ||||
| 	if (ControlledPawn != nullptr) | ||||
| 	{ | ||||
| 		FVector WorldDirection = (CachedDestination - ControlledPawn->GetActorLocation()).GetSafeNormal(); | ||||
| 		FVector WorldDirection = | ||||
| 			(CachedDestination - ControlledPawn->GetActorLocation()) | ||||
| 				.GetSafeNormal(); | ||||
| 		ControlledPawn->AddMovementInput(WorldDirection, 1.0, false); | ||||
| 	} | ||||
| } | ||||
| @@ -104,8 +132,11 @@ void AUTAD_UIPlayerController::OnSetDestinationReleased() | ||||
| 	if (FollowTime <= ShortPressThreshold) | ||||
| 	{ | ||||
| 		// We move there and spawn some particles | ||||
| 		UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, CachedDestination); | ||||
| 		UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, FXCursor, CachedDestination, FRotator::ZeroRotator, FVector(1.f, 1.f, 1.f), true, true, ENCPoolMethod::None, true); | ||||
| 		UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, | ||||
| 														CachedDestination); | ||||
| 		UNiagaraFunctionLibrary::SpawnSystemAtLocation( | ||||
| 			this, FXCursor, CachedDestination, FRotator::ZeroRotator, | ||||
| 			FVector(1.f, 1.f, 1.f), true, true, ENCPoolMethod::None, true); | ||||
| 	} | ||||
|  | ||||
| 	FollowTime = 0.f; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user