style: apply clang format
This commit is contained in:
		| @@ -8,6 +8,16 @@ public class UTAD_UI : ModuleRules | |||||||
| 	{ | 	{ | ||||||
| 		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; | 		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; | ||||||
|  |  | ||||||
|         PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput" }); |         PublicDependencyModuleNames.AddRange(new string[] | ||||||
|  |         { | ||||||
|  | 	        "Core", | ||||||
|  | 	        "CoreUObject", | ||||||
|  | 	        "Engine", | ||||||
|  | 	        "InputCore", | ||||||
|  | 	        "NavigationSystem", | ||||||
|  | 	        "AIModule", | ||||||
|  | 	        "Niagara", | ||||||
|  | 	        "EnhancedInput" | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,7 +3,6 @@ | |||||||
| #include "UTAD_UI.h" | #include "UTAD_UI.h" | ||||||
| #include "Modules/ModuleManager.h" | #include "Modules/ModuleManager.h" | ||||||
|  |  | ||||||
| IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, UTAD_UI, "UTAD_UI" ); | IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, UTAD_UI, "UTAD_UI"); | ||||||
|  |  | ||||||
| DEFINE_LOG_CATEGORY(LogUTAD_UI) | DEFINE_LOG_CATEGORY(LogUTAD_UI) | ||||||
|   |  | ||||||
| @@ -22,23 +22,30 @@ AUTAD_UICharacter::AUTAD_UICharacter() | |||||||
| 	bUseControllerRotationRoll	= false; | 	bUseControllerRotationRoll	= false; | ||||||
|  |  | ||||||
| 	// Configure character movement | 	// Configure character movement | ||||||
| 	GetCharacterMovement()->bOrientRotationToMovement = true; // Rotate character to moving direction | 	GetCharacterMovement()->bOrientRotationToMovement = | ||||||
|  | 		true; // Rotate character to moving direction | ||||||
| 	GetCharacterMovement()->RotationRate		= FRotator(0.f, 640.f, 0.f); | 	GetCharacterMovement()->RotationRate		= FRotator(0.f, 640.f, 0.f); | ||||||
| 	GetCharacterMovement()->bConstrainToPlane	= true; | 	GetCharacterMovement()->bConstrainToPlane	= true; | ||||||
| 	GetCharacterMovement()->bSnapToPlaneAtStart = true; | 	GetCharacterMovement()->bSnapToPlaneAtStart = true; | ||||||
|  |  | ||||||
| 	// Create a camera boom... | 	// Create a camera boom... | ||||||
| 	CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom")); | 	CameraBoom = | ||||||
|  | 		CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom")); | ||||||
| 	CameraBoom->SetupAttachment(RootComponent); | 	CameraBoom->SetupAttachment(RootComponent); | ||||||
| 	CameraBoom->SetUsingAbsoluteRotation(true); // Don't want arm to rotate when character does | 	CameraBoom->SetUsingAbsoluteRotation( | ||||||
|  | 		true); // Don't want arm to rotate when character does | ||||||
| 	CameraBoom->TargetArmLength = 800.f; | 	CameraBoom->TargetArmLength = 800.f; | ||||||
| 	CameraBoom->SetRelativeRotation(FRotator(-60.f, 0.f, 0.f)); | 	CameraBoom->SetRelativeRotation(FRotator(-60.f, 0.f, 0.f)); | ||||||
| 	CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level | 	CameraBoom->bDoCollisionTest = | ||||||
|  | 		false; // Don't want to pull camera in when it collides with level | ||||||
|  |  | ||||||
| 	// Create a camera... | 	// Create a camera... | ||||||
| 	TopDownCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("TopDownCamera")); | 	TopDownCameraComponent = | ||||||
| 	TopDownCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); | 		CreateDefaultSubobject<UCameraComponent>(TEXT("TopDownCamera")); | ||||||
| 	TopDownCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm | 	TopDownCameraComponent->SetupAttachment(CameraBoom, | ||||||
|  | 											USpringArmComponent::SocketName); | ||||||
|  | 	TopDownCameraComponent->bUsePawnControlRotation = | ||||||
|  | 		false; // Camera does not rotate relative to arm | ||||||
|  |  | ||||||
| 	// Activate ticking in order to update the cursor every frame. | 	// Activate ticking in order to update the cursor every frame. | ||||||
| 	PrimaryActorTick.bCanEverTick		   = true; | 	PrimaryActorTick.bCanEverTick		   = true; | ||||||
|   | |||||||
| @@ -18,17 +18,24 @@ public: | |||||||
| 	virtual void Tick(float DeltaSeconds) override; | 	virtual void Tick(float DeltaSeconds) override; | ||||||
|  |  | ||||||
| 	/** Returns TopDownCameraComponent subobject **/ | 	/** Returns TopDownCameraComponent subobject **/ | ||||||
| 	FORCEINLINE class UCameraComponent* GetTopDownCameraComponent() const { return TopDownCameraComponent; } | 	FORCEINLINE class UCameraComponent* GetTopDownCameraComponent() const | ||||||
|  | 	{ | ||||||
|  | 		return TopDownCameraComponent; | ||||||
|  | 	} | ||||||
| 	/** Returns CameraBoom subobject **/ | 	/** Returns CameraBoom subobject **/ | ||||||
| 	FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } | 	FORCEINLINE class USpringArmComponent* GetCameraBoom() const | ||||||
|  | 	{ | ||||||
|  | 		return CameraBoom; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| private: | private: | ||||||
| 	/** Top down camera */ | 	/** Top down camera */ | ||||||
| 	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) | 	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, | ||||||
|  | 			  meta = (AllowPrivateAccess = "true")) | ||||||
| 	class UCameraComponent* TopDownCameraComponent; | 	class UCameraComponent* TopDownCameraComponent; | ||||||
|  |  | ||||||
| 	/** Camera boom positioning the camera above the character */ | 	/** Camera boom positioning the camera above the character */ | ||||||
| 	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) | 	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, | ||||||
|  | 			  meta = (AllowPrivateAccess = "true")) | ||||||
| 	class USpringArmComponent* CameraBoom; | 	class USpringArmComponent* CameraBoom; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,15 +11,18 @@ AUTAD_UIGameMode::AUTAD_UIGameMode() | |||||||
| 	PlayerControllerClass = AUTAD_UIPlayerController::StaticClass(); | 	PlayerControllerClass = AUTAD_UIPlayerController::StaticClass(); | ||||||
|  |  | ||||||
| 	// set default pawn class to our Blueprinted character | 	// set default pawn class to our Blueprinted character | ||||||
| 	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/TopDown/Blueprints/BP_TopDownCharacter")); | 	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass( | ||||||
|  | 		TEXT("/Game/TopDown/Blueprints/BP_TopDownCharacter")); | ||||||
| 	if (PlayerPawnBPClass.Class != nullptr) | 	if (PlayerPawnBPClass.Class != nullptr) | ||||||
| 	{ | 	{ | ||||||
| 		DefaultPawnClass = PlayerPawnBPClass.Class; | 		DefaultPawnClass = PlayerPawnBPClass.Class; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// set default controller to our Blueprinted controller | 	// set default controller to our Blueprinted controller | ||||||
| 	static ConstructorHelpers::FClassFinder<APlayerController> PlayerControllerBPClass(TEXT("/Game/TopDown/Blueprints/BP_TopDownPlayerController")); | 	static ConstructorHelpers::FClassFinder<APlayerController> | ||||||
| 	if(PlayerControllerBPClass.Class != NULL) | 		PlayerControllerBPClass( | ||||||
|  | 			TEXT("/Game/TopDown/Blueprints/BP_TopDownPlayerController")); | ||||||
|  | 	if (PlayerControllerBPClass.Class != NULL) | ||||||
| 	{ | 	{ | ||||||
| 		PlayerControllerClass = PlayerControllerBPClass.Class; | 		PlayerControllerClass = PlayerControllerBPClass.Class; | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -14,6 +14,3 @@ class AUTAD_UIGameMode : public AGameModeBase | |||||||
| public: | public: | ||||||
| 	AUTAD_UIGameMode(); | 	AUTAD_UIGameMode(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -34,29 +34,52 @@ void AUTAD_UIPlayerController::SetupInputComponent() | |||||||
| 	Super::SetupInputComponent(); | 	Super::SetupInputComponent(); | ||||||
|  |  | ||||||
| 	// Add Input Mapping Context | 	// Add Input Mapping Context | ||||||
| 	if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer())) | 	if (UEnhancedInputLocalPlayerSubsystem* Subsystem = | ||||||
|  | 			ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>( | ||||||
|  | 				GetLocalPlayer())) | ||||||
| 	{ | 	{ | ||||||
| 		Subsystem->AddMappingContext(DefaultMappingContext, 0); | 		Subsystem->AddMappingContext(DefaultMappingContext, 0); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Set up action bindings | 	// Set up action bindings | ||||||
| 	if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(InputComponent)) | 	if (UEnhancedInputComponent* EnhancedInputComponent = | ||||||
|  | 			Cast<UEnhancedInputComponent>(InputComponent)) | ||||||
| 	{ | 	{ | ||||||
| 		// Setup mouse input events | 		// Setup mouse input events | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Started, this, &AUTAD_UIPlayerController::OnInputStarted); | 		EnhancedInputComponent->BindAction( | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Triggered, this, &AUTAD_UIPlayerController::OnSetDestinationTriggered); | 			SetDestinationClickAction, ETriggerEvent::Started, this, | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Completed, this, &AUTAD_UIPlayerController::OnSetDestinationReleased); | 			&AUTAD_UIPlayerController::OnInputStarted); | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Canceled, this, &AUTAD_UIPlayerController::OnSetDestinationReleased); | 		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 | 		// Setup touch input events | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Started, this, &AUTAD_UIPlayerController::OnInputStarted); | 		EnhancedInputComponent->BindAction( | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Triggered, this, &AUTAD_UIPlayerController::OnTouchTriggered); | 			SetDestinationTouchAction, ETriggerEvent::Started, this, | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Completed, this, &AUTAD_UIPlayerController::OnTouchReleased); | 			&AUTAD_UIPlayerController::OnInputStarted); | ||||||
| 		EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Canceled, this, &AUTAD_UIPlayerController::OnTouchReleased); | 		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 | 	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)); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -71,16 +94,19 @@ void AUTAD_UIPlayerController::OnSetDestinationTriggered() | |||||||
| 	// We flag that the input is being pressed | 	// We flag that the input is being pressed | ||||||
| 	FollowTime += GetWorld()->GetDeltaSeconds(); | 	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; | 	FHitResult Hit; | ||||||
| 	bool	   bHitSuccessful = false; | 	bool	   bHitSuccessful = false; | ||||||
| 	if (bIsTouch) | 	if (bIsTouch) | ||||||
| 	{ | 	{ | ||||||
| 		bHitSuccessful = GetHitResultUnderFinger(ETouchIndex::Touch1, ECollisionChannel::ECC_Visibility, true, Hit); | 		bHitSuccessful = GetHitResultUnderFinger( | ||||||
|  | 			ETouchIndex::Touch1, ECollisionChannel::ECC_Visibility, true, Hit); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		bHitSuccessful = GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, true, Hit); | 		bHitSuccessful = GetHitResultUnderCursor( | ||||||
|  | 			ECollisionChannel::ECC_Visibility, true, Hit); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// If we hit a surface, cache the location | 	// If we hit a surface, cache the location | ||||||
| @@ -93,7 +119,9 @@ void AUTAD_UIPlayerController::OnSetDestinationTriggered() | |||||||
| 	APawn* ControlledPawn = GetPawn(); | 	APawn* ControlledPawn = GetPawn(); | ||||||
| 	if (ControlledPawn != nullptr) | 	if (ControlledPawn != nullptr) | ||||||
| 	{ | 	{ | ||||||
| 		FVector WorldDirection = (CachedDestination - ControlledPawn->GetActorLocation()).GetSafeNormal(); | 		FVector WorldDirection = | ||||||
|  | 			(CachedDestination - ControlledPawn->GetActorLocation()) | ||||||
|  | 				.GetSafeNormal(); | ||||||
| 		ControlledPawn->AddMovementInput(WorldDirection, 1.0, false); | 		ControlledPawn->AddMovementInput(WorldDirection, 1.0, false); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -104,8 +132,11 @@ void AUTAD_UIPlayerController::OnSetDestinationReleased() | |||||||
| 	if (FollowTime <= ShortPressThreshold) | 	if (FollowTime <= ShortPressThreshold) | ||||||
| 	{ | 	{ | ||||||
| 		// We move there and spawn some particles | 		// We move there and spawn some particles | ||||||
| 		UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, CachedDestination); | 		UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, | ||||||
| 		UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, FXCursor, CachedDestination, FRotator::ZeroRotator, FVector(1.f, 1.f, 1.f), true, true, ENCPoolMethod::None, true); | 														CachedDestination); | ||||||
|  | 		UNiagaraFunctionLibrary::SpawnSystemAtLocation( | ||||||
|  | 			this, FXCursor, CachedDestination, FRotator::ZeroRotator, | ||||||
|  | 			FVector(1.f, 1.f, 1.f), true, true, ENCPoolMethod::None, true); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	FollowTime = 0.f; | 	FollowTime = 0.f; | ||||||
|   | |||||||
| @@ -31,15 +31,18 @@ public: | |||||||
| 	UNiagaraSystem* FXCursor; | 	UNiagaraSystem* FXCursor; | ||||||
|  |  | ||||||
| 	/** MappingContext */ | 	/** MappingContext */ | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, | ||||||
|  | 			  meta = (AllowPrivateAccess = "true")) | ||||||
| 	UInputMappingContext* DefaultMappingContext; | 	UInputMappingContext* DefaultMappingContext; | ||||||
|  |  | ||||||
| 	/** Jump Input Action */ | 	/** Jump Input Action */ | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, | ||||||
|  | 			  meta = (AllowPrivateAccess = "true")) | ||||||
| 	UInputAction* SetDestinationClickAction; | 	UInputAction* SetDestinationClickAction; | ||||||
|  |  | ||||||
| 	/** Jump Input Action */ | 	/** Jump Input Action */ | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, | ||||||
|  | 			  meta = (AllowPrivateAccess = "true")) | ||||||
| 	UInputAction* SetDestinationTouchAction; | 	UInputAction* SetDestinationTouchAction; | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
| @@ -64,5 +67,3 @@ private: | |||||||
| 	bool  bIsTouch;	  // Is it a touch device | 	bool  bIsTouch;	  // Is it a touch device | ||||||
| 	float FollowTime; // For how long it has been pressed | 	float FollowTime; // For how long it has been pressed | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user