14. Post-Process Highlight
And alot more...
This commit is contained in:
		
							
								
								
									
										30
									
								
								Project/Source/Gasa/Actors/CameraMount.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Project/Source/Gasa/Actors/CameraMount.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| #include "CameraMount.h" | ||||
|  | ||||
| #include "Camera/CameraComponent.h" | ||||
| #include "GameFramework/SpringArmComponent.h" | ||||
|  | ||||
|  | ||||
| ACameraMount::ACameraMount() | ||||
| { | ||||
| 	PrimaryActorTick.bCanEverTick = true; | ||||
|  | ||||
| 	RootComponent = CreateDefaultSubobject<USceneComponent>("Root"); | ||||
| 	 | ||||
| 	CamSpringArm = CreateDefaultSubobject<USpringArmComponent>("Camera Spring Arm"); | ||||
| 	CamSpringArm->SetupAttachment(RootComponent); | ||||
| 	CamSpringArm->SetRelativeRotation( FQuat::MakeFromEuler(FVector(0.0, -35.0, 0.0))); | ||||
| 	CamSpringArm->TargetArmLength  = 400.0f; | ||||
| 	CamSpringArm->bDoCollisionTest = true; | ||||
|  | ||||
| 	CamSpringArm->bInheritPitch = false; | ||||
| 	CamSpringArm->bInheritYaw   = false; | ||||
| 	CamSpringArm->bInheritRoll  = false; | ||||
| 	 | ||||
| 	Camera = CreateDefaultSubobject<UCameraComponent>("Camera"); | ||||
| 	Camera->SetupAttachment(CamSpringArm); | ||||
| } | ||||
|  | ||||
| void ACameraMount::PostInitializeComponents() | ||||
| { | ||||
| 	Super::PostInitializeComponents(); | ||||
| } | ||||
							
								
								
									
										25
									
								
								Project/Source/Gasa/Actors/CameraMount.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Project/Source/Gasa/Actors/CameraMount.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "GasaCommon.h" | ||||
| #include "CameraMount.generated.h" | ||||
|  | ||||
| UCLASS(Blueprintable) | ||||
| class GASA_API ACameraMount : public AActor | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| #pragma region Camera | ||||
| 	UPROPERTY(EditAnywhere, Category="Camera") | ||||
| 	TObjectPtr<UCameraComponent> Camera; | ||||
| 	 | ||||
| 	UPROPERTY(EditAnywhere, Category="Camera") | ||||
| 	TObjectPtr<USpringArmComponent> CamSpringArm; | ||||
| #pragma endregion Camera | ||||
|  | ||||
| 	ACameraMount(); | ||||
|  | ||||
| #pragma region Actor | ||||
| 	void PostInitializeComponents() override; | ||||
| #pragma endregion Actor | ||||
| }; | ||||
|  | ||||
| @@ -1,5 +1,6 @@ | ||||
| #include "GasaCharacter.h" | ||||
| 
 | ||||
| #include "GasaLevelScriptActor.h" | ||||
| #include "Camera/CameraComponent.h" | ||||
| #include "Components/CapsuleComponent.h" | ||||
| #include "GameFramework/CharacterMovementComponent.h" | ||||
| @@ -31,18 +32,6 @@ AGasaCharacter::AGasaCharacter() | ||||
| 	USceneComponent*        root_component = GetRootComponent(); | ||||
| 	USkeletalMeshComponent* mesh           = GetMesh(); | ||||
| 
 | ||||
| 	CamSpringArm = CreateDefaultSubobject<USpringArmComponent>("Camera Spring Arm"); | ||||
| 	CamSpringArm->SetupAttachment(root_component); | ||||
| 	CamSpringArm->SetRelativeRotation( FQuat::MakeFromEuler(FVector(0.0, -35.0, 0.0))); | ||||
| 	CamSpringArm->TargetArmLength = 400.0f; | ||||
| 
 | ||||
| 	CamSpringArm->bInheritPitch = false; | ||||
| 	CamSpringArm->bInheritYaw   = false; | ||||
| 	CamSpringArm->bInheritRoll  = false; | ||||
| 	 | ||||
| 	Camera = CreateDefaultSubobject<UCameraComponent>("Camera"); | ||||
| 	Camera->SetupAttachment(CamSpringArm); | ||||
| 
 | ||||
| 	Weapon = CreateDefaultSubobject<USkeletalMeshComponent>("Weapon"); | ||||
| 	Weapon->SetupAttachment(mesh, FName("WeaponAttach")); | ||||
| 	Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision); | ||||
| @@ -56,24 +45,42 @@ void AGasaCharacter::BeginPlay() | ||||
| void AGasaCharacter::Tick(float DeltaSeconds) | ||||
| { | ||||
| 	Super::Tick(DeltaSeconds); | ||||
| 
 | ||||
| 	 | ||||
| 	USkeletalMeshComponent* mesh = GetMesh(); | ||||
| 	switch (HighlightState) | ||||
| 	{ | ||||
| 		case EHighlight::Disabled: | ||||
| 		{ | ||||
| 			mesh->SetRenderCustomDepth(false); | ||||
| 			mesh->SetCustomDepthStencilValue(0.f); | ||||
| 			Weapon->SetRenderCustomDepth(false); | ||||
| 			Weapon->SetCustomDepthStencilValue(0.f); | ||||
| 		}	 | ||||
| 		break; | ||||
| 		case EHighlight::Enabled: | ||||
| 		{ | ||||
| 			mesh->SetRenderCustomDepth(true); | ||||
| 			mesh->SetCustomDepthStencilValue(HighlightStencilDepth); | ||||
| 			Weapon->SetRenderCustomDepth(true); | ||||
| 			Weapon->SetCustomDepthStencilValue(HighlightStencilDepth); | ||||
| 
 | ||||
| 			APostProcessVolume* PPV     = Gasa::GetLevelActor(this)->GlobalPPV; | ||||
| 			TObjectPtr<UObject> Blendable = PPV->Settings.WeightedBlendables.Array[0].Object; | ||||
| 			UMaterialInstanceDynamic* | ||||
| 			MID = Cast<UMaterialInstanceDynamic>(Blendable); | ||||
| 			MID->SetVectorParameterValue("Depth Highlight Color", HighlightColor); | ||||
| #if 0 | ||||
| 			UCapsuleComponent* Capsule = GetCapsuleComponent(); | ||||
| 				 | ||||
| 			UKismetSystemLibrary::DrawDebugCapsule(this | ||||
| 				, Capsule->GetComponentLocation() | ||||
| 				, Capsule->GetScaledCapsuleHalfHeight() | ||||
| 				, Capsule->GetScaledCapsuleHalfHeight()^ | ||||
| 				, Capsule->GetScaledCapsuleRadius() | ||||
| 				, Capsule->GetComponentRotation() | ||||
| 				, HighlightColor | ||||
| 				, 0.f | ||||
| 				, 1.f | ||||
| 			); | ||||
| #endif | ||||
| 		} | ||||
| 		break; | ||||
| 	} | ||||
| @@ -17,23 +17,14 @@ class GASA_API AGasaCharacter : public ACharacter | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| 	// TODO(Ed): Either make a toggle ore move to player controller if it gets expensive
 | ||||
| 	// There is no need to have this lodged int PlayerCharacter anyway. It can attach to pawn on posses.
 | ||||
| #pragma region Camera | ||||
| 	UPROPERTY(EditAnywhere, Category="Camera") | ||||
| 	UCameraComponent* Camera; | ||||
| 	 | ||||
| 	UPROPERTY(EditAnywhere, Category="Camera") | ||||
| 	USpringArmComponent* CamSpringArm; | ||||
| #pragma endregion Camera | ||||
| 	 | ||||
| #pragma region Combat | ||||
| 	UPROPERTY(EditAnywhere, Category="Combat") | ||||
| 	TObjectPtr<USkeletalMeshComponent> Weapon; | ||||
| #pragma endregion Combat | ||||
| 
 | ||||
| 	// This will be implemented in the base until it needs to be lifted into an abstraction.
 | ||||
| #pragma region Highlighting | ||||
| 	static constexpr float HighlightStencilDepth = 256.0; | ||||
| 	 | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Highlighting") | ||||
| 	EHighlight HighlightState; | ||||
| 	 | ||||
| @@ -49,7 +40,7 @@ public: | ||||
| 	UFUNCTION(BlueprintCallable, Category="Highlighting") | ||||
| 	FORCEINLINE void Dehighlight() { SetHighlight(EHighlight::Disabled); }; | ||||
| #pragma endregion Highlighting | ||||
| 	 | ||||
| 
 | ||||
| 	AGasaCharacter(); | ||||
| 	 | ||||
| #pragma region Actor | ||||
| @@ -23,6 +23,7 @@ public class Gasa : ModuleRules | ||||
|              | ||||
|             "AIModule", | ||||
|             "CoreUObject",  | ||||
|             "DeveloperSettings", | ||||
|             "Engine",  | ||||
|             "EnhancedInput", | ||||
|             "GameplayAbilities", | ||||
|   | ||||
| @@ -1,22 +1,32 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include "CoreMinimal.h" | ||||
| // #define private protected | ||||
|  | ||||
| #include "CogCommon.h" | ||||
| #define global         | ||||
| #define internal      static | ||||
| #define local_persist static | ||||
|  | ||||
| #pragma region Engine Forwards | ||||
| class  UCameraComponent; | ||||
| class  UInputAction; | ||||
| struct FInputActionValue; | ||||
| class  UInputMappingContext; | ||||
| class  USpringArmComponent; | ||||
|  | ||||
| class UCameraComponent; | ||||
| class UInputAction; | ||||
| class UInputMappingContext; | ||||
| class USpringArmComponent; | ||||
| #pragma endregion Engine Forwards | ||||
|  | ||||
| #pragma region Engine Plugin Forwards | ||||
| class UCogWindowManager; | ||||
| #pragma endregion Engine Plugin Forwards | ||||
|  | ||||
| #pragma region Gasa Forwards | ||||
| class AGasaCharacter; | ||||
| #pragma endregion Gasa Forwards | ||||
| // Gasa | ||||
|  | ||||
| #pragma region Forwards | ||||
| class ACameraMount; | ||||
| class AGasaCharacter; | ||||
| class AGasaLevelScriptActor; | ||||
|  | ||||
| class UGasaDevOptions; | ||||
| #pragma endregion Forwards | ||||
|   | ||||
							
								
								
									
										18
									
								
								Project/Source/Gasa/GasaDevOptions.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Project/Source/Gasa/GasaDevOptions.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| #include "GasaDevOptions.h" | ||||
|  | ||||
| #include "GasaDevOptionsCache.h" | ||||
|  | ||||
| namespace Gasa | ||||
| { | ||||
| 	global FName Tag_GlobalPPV; | ||||
| } | ||||
|  | ||||
| void FGasaDevOptionsCache::CachedDevOptions() | ||||
| { | ||||
| 	using namespace Gasa; | ||||
|  | ||||
| 	UGasaDevOptions const* DevOs = GetDevOptions(); | ||||
| 	Tag_GlobalPPV = DevOs->Tag_GlobalPPV; | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										29
									
								
								Project/Source/Gasa/GasaDevOptions.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Project/Source/Gasa/GasaDevOptions.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "Engine/DeveloperSettings.h" | ||||
|  | ||||
| #include "GasaDevOptions.generated.h" | ||||
|  | ||||
| UCLASS(Config=Game, DefaultConfig, meta=(DisplayName="Gasa")) | ||||
| class GASA_API UGasaDevOptions : public UDeveloperSettings | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| 	UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="Tags") | ||||
| 	FName Tag_GlobalPPV; | ||||
| }; | ||||
|  | ||||
| namespace Gasa | ||||
| { | ||||
| 	extern FName Tag_GlobalPPV; | ||||
|  | ||||
| 	FORCEINLINE | ||||
| 	UGasaDevOptions const* GetDevOptions() { | ||||
| 		return GetDefault<UGasaDevOptions>();	 | ||||
| 	} | ||||
|  | ||||
| 	FORCEINLINE | ||||
| 	UGasaDevOptions* GetMutDevOptions() { | ||||
| 		return GetMutableDefault<UGasaDevOptions>();	 | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										13
									
								
								Project/Source/Gasa/GasaDevOptionsCache.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Project/Source/Gasa/GasaDevOptionsCache.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "GasaCommon.h" | ||||
|  | ||||
| #include "GasaDevOptionsCache.generated.h" | ||||
|  | ||||
| USTRUCT() | ||||
| struct GASA_API FGasaDevOptionsCache | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| 	 | ||||
| 	void CachedDevOptions(); | ||||
| }; | ||||
							
								
								
									
										8
									
								
								Project/Source/Gasa/GasaGameInstance.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Project/Source/Gasa/GasaGameInstance.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| #include "GasaGameInstance.h" | ||||
|  | ||||
| void UGasaGameInstance::Init() | ||||
| { | ||||
| 	Super::Init(); | ||||
|  | ||||
| 	DevOptionsCache.CachedDevOptions(); | ||||
| } | ||||
							
								
								
									
										29
									
								
								Project/Source/Gasa/GasaGameInstance.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Project/Source/Gasa/GasaGameInstance.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "GasaCommon.h" | ||||
| #include "GasaDevOptionsCache.h" | ||||
|  | ||||
| #include "GasaGameInstance.generated.h" | ||||
|  | ||||
| UCLASS(Blueprintable) | ||||
| class GASA_API UGasaGameInstance : public UGameInstance | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
|  | ||||
| 	UPROPERTY(VisibleAnywhere, Category="Dev Cache") | ||||
| 	FGasaDevOptionsCache DevOptionsCache; | ||||
|  | ||||
| #pragma region GameInstance | ||||
| 	void Init() override; | ||||
| #pragma endregion GameInstance | ||||
| }; | ||||
|  | ||||
| namespace Gasa | ||||
| { | ||||
| 	FORCEINLINE | ||||
| 	UGasaGameInstance* GetGameInstance(UObject* Context) { | ||||
| 		// TODO(Ed): Do this with proper checks | ||||
| 		return Context->GetWorld()->GetGameInstance<UGasaGameInstance>(); | ||||
| 	} | ||||
| } | ||||
| @@ -9,3 +9,11 @@ class GASA_API AGasaGameMode : public AGameMode | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| }; | ||||
|  | ||||
| namespace Gasa | ||||
| { | ||||
| 	FORCEINLINE | ||||
| 	AGasaGameMode* GetGameMode(UObject* Context) { | ||||
| 		return Context->GetWorld()->GetAuthGameMode<AGasaGameMode>(); | ||||
| 	} | ||||
| } | ||||
| @@ -27,4 +27,12 @@ public: | ||||
|  | ||||
| 	void Tick(float DeltaSeconds) override; | ||||
| #pragma endregion GameState	 | ||||
| }; | ||||
| }; | ||||
|  | ||||
| namespace Gasa | ||||
| { | ||||
| 	FORCEINLINE | ||||
| 	AGasaGameState* GetGameState(UObject* Context) { | ||||
| 		return Context->GetWorld()->GetGameState<AGasaGameState>(); | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								Project/Source/Gasa/GasaGameplayTags.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Project/Source/Gasa/GasaGameplayTags.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| #include "GasaGameplayTags.h" | ||||
|  | ||||
							
								
								
									
										3
									
								
								Project/Source/Gasa/GasaGameplayTags.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Project/Source/Gasa/GasaGameplayTags.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "NativeGameplayTags.h" | ||||
							
								
								
									
										25
									
								
								Project/Source/Gasa/GasaLevelScriptActor.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Project/Source/Gasa/GasaLevelScriptActor.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #include "GasaLevelScriptActor.h" | ||||
|  | ||||
| #include "GasaDevOptions.h" | ||||
| #include "GasaGameplayTags.h" | ||||
| #include "Kismet/GameplayStatics.h" | ||||
|  | ||||
| #include "GasaLibrary.h" | ||||
|  | ||||
| void AGasaLevelScriptActor::BeginPlay() | ||||
| { | ||||
| 	Super::BeginPlay(); | ||||
|  | ||||
| 	TArray<AActor*> TaggedActors; | ||||
| 	UGameplayStatics::GetAllActorsWithTag(GetWorld(), Gasa::GetDevOptions()->Tag_GlobalPPV,TaggedActors); | ||||
| 	for (AActor* Actor : TaggedActors) | ||||
| 	{ | ||||
| 		GlobalPPV = Cast<APostProcessVolume>(Actor); | ||||
|  | ||||
| 		APostProcessVolume* PPV     = Gasa::GetLevelActor(this)->GlobalPPV; | ||||
| 		UMaterialInstance*  Blendable = Cast<UMaterialInstance>(PPV->Settings.WeightedBlendables.Array[0].Object); | ||||
| 		UMaterialInstanceDynamic* MID = UMaterialInstanceDynamic::Create(Blendable, this); | ||||
| 		PPV->Settings.WeightedBlendables.Array[0].Object = MID; | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										27
									
								
								Project/Source/Gasa/GasaLevelScriptActor.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Project/Source/Gasa/GasaLevelScriptActor.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "Engine/LevelScriptActor.h" | ||||
|  | ||||
| #include "GasaLevelScriptActor.generated.h" | ||||
|  | ||||
| UCLASS(Blueprintable) | ||||
| class GASA_API AGasaLevelScriptActor : public ALevelScriptActor | ||||
| { | ||||
|     GENERATED_BODY() | ||||
| public: | ||||
|     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Post Process") | ||||
|     TObjectPtr<APostProcessVolume> GlobalPPV; | ||||
|  | ||||
| #pragma region Actor | ||||
|     void BeginPlay() override; | ||||
| #pragma region endActor | ||||
| }; | ||||
|  | ||||
| namespace Gasa | ||||
| { | ||||
| 	inline | ||||
|     AGasaLevelScriptActor* GetLevelActor(UObject* Context, ULevel* OwnerLevel = nullptr) { | ||||
| 	    UWorld* World = GEngine->GetWorldFromContextObjectChecked(Context); | ||||
| 		return Cast<AGasaLevelScriptActor>(World->GetLevelScriptActor(OwnerLevel)); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										9
									
								
								Project/Source/Gasa/GasaLibrary.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Project/Source/Gasa/GasaLibrary.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #include "GasaLibrary.h" | ||||
|  | ||||
| #include "GasaDevOptions.h" | ||||
| #include "GasaLevelScriptActor.h" | ||||
| #include "Engine/LevelScriptActor.h" | ||||
|  | ||||
| UGasaDevOptions* UGasaLib::GetDevOptions(UObject* Context) { | ||||
| 	return Gasa::GetMutDevOptions(); | ||||
| } | ||||
							
								
								
									
										23
									
								
								Project/Source/Gasa/GasaLibrary.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Project/Source/Gasa/GasaLibrary.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "GasaCommon.h" | ||||
|  | ||||
| #include "GasaLibrary.Generated.h" | ||||
|  | ||||
|  | ||||
| // UINTERFACE() | ||||
| // class  | ||||
|  | ||||
| UCLASS(BlueprintType) | ||||
| class GASA_API UGasaLib : public UBlueprintFunctionLibrary | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
|  | ||||
| #pragma region Game | ||||
| 	 | ||||
| 	UFUNCTION(BlueprintCallable, Category="Gasa|Game", BlueprintPure, meta=(WorldContext="Context")) | ||||
| 	static UGasaDevOptions* GetDevOptions(UObject* Context); | ||||
| #pragma endregion Game | ||||
| }; | ||||
|  | ||||
| @@ -3,10 +3,19 @@ | ||||
| #include "Engine/LocalPlayer.h" | ||||
| #include "EnhancedInputComponent.h" | ||||
| #include "EnhancedInputSubsystems.h" | ||||
| #include "Character/GasaCharacter.h" | ||||
| #include "Actors/CameraMount.h" | ||||
| #include "Camera/CameraComponent.h" | ||||
| #include "Characters/GasaCharacter.h" | ||||
| #include "Components/CapsuleComponent.h" | ||||
| #include "GameFramework/SpringArmComponent.h" | ||||
| #include "Kismet/KismetSystemLibrary.h" | ||||
|  | ||||
| AGasaPlayerController::AGasaPlayerController() | ||||
| { | ||||
| 	PrimaryActorTick.bCanEverTick = true; | ||||
| 	bAutoManageActiveCameraTarget = false; | ||||
|  | ||||
| 	// Replication | ||||
| 	bReplicates = true; | ||||
| } | ||||
|  | ||||
| @@ -53,6 +62,18 @@ void AGasaPlayerController::Move(FInputActionValue const& ActionValue) | ||||
| #endif | ||||
| } | ||||
|  | ||||
| void AGasaPlayerController::OnPossess(APawn* InPawn) | ||||
| { | ||||
| 	Super::OnPossess(InPawn); | ||||
|  | ||||
| 	Cam->AttachToActor(InPawn, FAttachmentTransformRules::KeepRelativeTransform); | ||||
| } | ||||
|  | ||||
| void AGasaPlayerController::OnUnPossess() | ||||
| { | ||||
| 	Super::OnUnPossess(); | ||||
| } | ||||
|  | ||||
| #pragma region PlayerController | ||||
| void AGasaPlayerController::PlayerTick(float DeltaTime) | ||||
| { | ||||
| @@ -110,6 +131,7 @@ void AGasaPlayerController::BeginPlay() | ||||
| 	Super::BeginPlay(); | ||||
|  | ||||
| 	check(IMC); | ||||
| 	 | ||||
| 	UEnhancedInputLocalPlayerSubsystem* | ||||
| 	EILP_Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer()); | ||||
| 	check(EILP_Subsystem); | ||||
| @@ -123,4 +145,40 @@ void AGasaPlayerController::BeginPlay() | ||||
| 		SetInputMode(MouseMode); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void AGasaPlayerController::PostInitializeComponents() | ||||
| { | ||||
| 	Super::PostInitializeComponents(); | ||||
|  | ||||
| 	Cam = GetWorld()->SpawnActor<ACameraMount>(CamClass, FActorSpawnParameters() ); | ||||
| 	SetViewTarget(Cam); | ||||
| } | ||||
|  | ||||
| void AGasaPlayerController::Tick(float DeltaSeconds) | ||||
| { | ||||
| 	Super::Tick(DeltaSeconds); | ||||
|  | ||||
| #if 0 | ||||
| 	switch (HighlightState) | ||||
| 	{ | ||||
| 		case EHighlight::Disabled: | ||||
| 		break; | ||||
| 		case EHighlight::Enabled: | ||||
| 		{ | ||||
| 			UCapsuleComponent* Capsule = GetCapsuleComponent(); | ||||
| 				 | ||||
| 			UKismetSystemLibrary::DrawDebugCapsule(this | ||||
| 				, Capsule->GetComponentLocation() | ||||
| 				, Capsule->GetScaledCapsuleHalfHeight() | ||||
| 				, Capsule->GetScaledCapsuleRadius() | ||||
| 				, Capsule->GetComponentRotation() | ||||
| 				, HighlightColor | ||||
| 				, 0.f | ||||
| 				, 1.f | ||||
| 			); | ||||
| 		} | ||||
| 		break; | ||||
| 	} | ||||
| #endif | ||||
| } | ||||
| #pragma endregion Actor | ||||
|   | ||||
| @@ -11,13 +11,37 @@ class GASA_API AGasaPlayerController : public APlayerController | ||||
| { | ||||
| 	GENERATED_BODY() | ||||
| public: | ||||
| #pragma region Camera | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite) | ||||
| 	TSubclassOf<ACameraMount> CamClass; | ||||
| 	 | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite) | ||||
| 	TObjectPtr<ACameraMount> Cam; | ||||
| #pragma endregion Camera | ||||
|  | ||||
| 		// This will be implemented in the base until it needs to be lifted into an abstraction. | ||||
| #if 0 | ||||
| #pragma region Highlighting | ||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Highlighting") | ||||
| 	EHighlight HighlightState; | ||||
| 	 | ||||
| 	UFUNCTION(BlueprintCallable, Category="Highlighting") | ||||
| 	void SetHighlight( EHighlight Desired ); | ||||
|  | ||||
| 	UFUNCTION(BlueprintCallable, Category="Highlighting") | ||||
| 	FORCEINLINE void Highlight() { SetHighlight(EHighlight::Enabled); }; | ||||
| 	 | ||||
| 	UFUNCTION(BlueprintCallable, Category="Highlighting") | ||||
| 	FORCEINLINE void Dehighlight() { SetHighlight(EHighlight::Disabled); }; | ||||
| #pragma endregion Highlighting | ||||
| #endif | ||||
| 	 | ||||
| #pragma region Input | ||||
| 	UPROPERTY(VisibleAnywhere, BlueprintReadOnly) | ||||
| 	AGasaCharacter* HoverPrev; | ||||
| 	TObjectPtr<AGasaCharacter> HoverPrev; | ||||
| 	 | ||||
| 	UPROPERTY(VisibleAnywhere, BlueprintReadOnly) | ||||
| 	AGasaCharacter* HoverCurr; | ||||
| 	TObjectPtr<AGasaCharacter> HoverCurr; | ||||
| 	 | ||||
| 	UPROPERTY(EditAnywhere, Category="Input") | ||||
| 	TObjectPtr<UInputMappingContext> IMC; | ||||
| @@ -31,6 +55,10 @@ public: | ||||
| 	void Move(FInputActionValue const& ActionValue); | ||||
| 	 | ||||
| #pragma region PlayerController | ||||
| 	void OnPossess(APawn* InPawn) override; | ||||
|  | ||||
| 	void OnUnPossess() override; | ||||
| 	 | ||||
| 	void PlayerTick(float DeltaTime) override; | ||||
| 	 | ||||
| 	void SetupInputComponent() override; | ||||
| @@ -38,5 +66,9 @@ public: | ||||
|  | ||||
| #pragma region Actor | ||||
| 	void BeginPlay() override; | ||||
|  | ||||
| 	void PostInitializeComponents() override; | ||||
|  | ||||
| 	void Tick(float DeltaSeconds) override; | ||||
| #pragma endregion Actor | ||||
| }; | ||||
|   | ||||
| @@ -12,6 +12,7 @@ public class GasaEditorTarget : TargetRules | ||||
|         DefaultBuildSettings = BuildSettingsVersion.Latest; | ||||
|          | ||||
|         bUseUnityBuild = false; | ||||
|         bUseXGEController = false; | ||||
|          | ||||
| 		ExtraModuleNames.Add("Gasa"); | ||||
| 		ExtraModuleNames.Add("GasaEditor"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user