diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 7fa02d2..177e028 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -46,6 +46,7 @@ r.DynamicGlobalIlluminationMethod=1 r.ReflectionMethod=1 r.Shadow.Virtual.Enable=1 r.DefaultFeature.AutoExposure.ExtendDefaultLuminanceRange=True +r.CustomDepth=3 [/Script/WorldPartitionEditor.WorldPartitionEditorSettings] CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet' diff --git a/Content/Blueprints/Character/ABP_Enemy.uasset b/Content/Blueprints/Character/ABP_Enemy.uasset index 8833b8a..512d920 100644 --- a/Content/Blueprints/Character/ABP_Enemy.uasset +++ b/Content/Blueprints/Character/ABP_Enemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43d98314673c991ee851d595aa019bd88e54f553e59184102318fdad2db29c83 -size 93962 +oid sha256:a720393e3280a478556e8b5c501af71857593c5d0d0aab050eb830acbb298038 +size 2423 diff --git a/Content/Blueprints/Character/Enemy/Animation/ABP_Enemy.uasset b/Content/Blueprints/Character/Enemy/Animation/ABP_Enemy.uasset new file mode 100644 index 0000000..62aab37 --- /dev/null +++ b/Content/Blueprints/Character/Enemy/Animation/ABP_Enemy.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1d4eddbf4b2b9f0a0ce58a93bedcfde788f46abd5247b7cb2b96c928560518c +size 93913 diff --git a/Content/Blueprints/Character/Enemy/BP_EnemyBase.uasset b/Content/Blueprints/Character/Enemy/BP_EnemyBase.uasset new file mode 100644 index 0000000..519e9b3 --- /dev/null +++ b/Content/Blueprints/Character/Enemy/BP_EnemyBase.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:434e893d7bd7cf8c9f669f4bf78ce6f6a563223af5f6160209016b47d634aa44 +size 22835 diff --git a/Content/Blueprints/Character/Enemy/GoblinSlingshot/Animation/ABP_GoblinSlingshot.uasset b/Content/Blueprints/Character/Enemy/GoblinSlingshot/Animation/ABP_GoblinSlingshot.uasset index faf538d..961dde3 100644 --- a/Content/Blueprints/Character/Enemy/GoblinSlingshot/Animation/ABP_GoblinSlingshot.uasset +++ b/Content/Blueprints/Character/Enemy/GoblinSlingshot/Animation/ABP_GoblinSlingshot.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bffce3c326f1db87a91509d21bd710205d2ec01b2f939b5c580b86e2e5678e66 -size 28917 +oid sha256:c7b6c577541cf371d8c5f398926a78894bd86d5a1bb4b9c2a2f49e1bdeb0d2e9 +size 28988 diff --git a/Content/Blueprints/Character/Enemy/GoblinSlingshot/BP_GoblinSlingshot.uasset b/Content/Blueprints/Character/Enemy/GoblinSlingshot/BP_GoblinSlingshot.uasset index e90ec5f..8099a48 100644 --- a/Content/Blueprints/Character/Enemy/GoblinSlingshot/BP_GoblinSlingshot.uasset +++ b/Content/Blueprints/Character/Enemy/GoblinSlingshot/BP_GoblinSlingshot.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8b284e7a2a493d88cd954552a46f4c7d42e8de05b3fbf5852251c87ddb08c54 -size 32816 +oid sha256:5bba27ed30eb7a86d4cb564315ef44fb00d2fb845438288582f5627e7fabeeb3 +size 32813 diff --git a/Content/Blueprints/Character/Enemy/GoblinSpear/Animation/ABP_GoblinSpear.uasset b/Content/Blueprints/Character/Enemy/GoblinSpear/Animation/ABP_GoblinSpear.uasset index c8ff596..d892061 100644 --- a/Content/Blueprints/Character/Enemy/GoblinSpear/Animation/ABP_GoblinSpear.uasset +++ b/Content/Blueprints/Character/Enemy/GoblinSpear/Animation/ABP_GoblinSpear.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a90217957b684bb76dd3c55c5d4e535c04fa9beeae47828739a11913ae12eee0 -size 28591 +oid sha256:d23b980cb26aff098508e70fe1fb2a5f58a27c1ea6a0daaf9bce13e390af4168 +size 28583 diff --git a/Content/Blueprints/Character/Enemy/GoblinSpear/BP_GoblinSpear.uasset b/Content/Blueprints/Character/Enemy/GoblinSpear/BP_GoblinSpear.uasset index 6229e41..830162f 100644 --- a/Content/Blueprints/Character/Enemy/GoblinSpear/BP_GoblinSpear.uasset +++ b/Content/Blueprints/Character/Enemy/GoblinSpear/BP_GoblinSpear.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cec6f8708605906a58314432f463c4c0bc1a780ccbafb84206c0c4cd8898e39a -size 32665 +oid sha256:c32e425c3e1d77f3c3ac6ed5fe72db5e7ddbdfef2f78c1c24b7aaee60596e76c +size 32538 diff --git a/Content/Maps/StartupMap.umap b/Content/Maps/StartupMap.umap index 3cc8a24..7258a21 100644 --- a/Content/Maps/StartupMap.umap +++ b/Content/Maps/StartupMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0b4fb17f96d0c003497199638e06a220712e7811c472ff83b0d0a601543c8ad -size 38534 +oid sha256:5c425e1027540bd9081efc0140a25d1867796d1e391a4ccf498d1c29be7d0269 +size 51546 diff --git a/Source/Aura/Aura.h b/Source/Aura/Aura.h index 636b14a..fa5e9ea 100644 --- a/Source/Aura/Aura.h +++ b/Source/Aura/Aura.h @@ -4,3 +4,4 @@ #include "CoreMinimal.h" +#define CUSTOM_DEPTH_RED 250 diff --git a/Source/Aura/Private/Character/AuraEnemy.cpp b/Source/Aura/Private/Character/AuraEnemy.cpp index d2cda85..6dafc78 100644 --- a/Source/Aura/Private/Character/AuraEnemy.cpp +++ b/Source/Aura/Private/Character/AuraEnemy.cpp @@ -2,4 +2,27 @@ #include "Character/AuraEnemy.h" +#include "Aura/Aura.h" +AAuraEnemy::AAuraEnemy() +{ + GetMesh()->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block); + + GetMesh()->SetRenderCustomDepth(false); + GetMesh()->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED); + + Weapon->SetRenderCustomDepth(false); + Weapon->SetCustomDepthStencilValue(CUSTOM_DEPTH_RED); +} + +void AAuraEnemy::HighlightActor() +{ + GetMesh()->SetRenderCustomDepth(true); + Weapon->SetRenderCustomDepth(true); +} + +void AAuraEnemy::UnHighlightActor() +{ + GetMesh()->SetRenderCustomDepth(false); + Weapon->SetRenderCustomDepth(false); +} diff --git a/Source/Aura/Private/Interaction/EnemyInterface.cpp b/Source/Aura/Private/Interaction/EnemyInterface.cpp new file mode 100644 index 0000000..8ebdb84 --- /dev/null +++ b/Source/Aura/Private/Interaction/EnemyInterface.cpp @@ -0,0 +1,7 @@ +// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024 + + +#include "Interaction/EnemyInterface.h" + + +// Add default functionality here for any IMyClass functions that are not pure virtual. diff --git a/Source/Aura/Private/Player/AuraPlayerController.cpp b/Source/Aura/Private/Player/AuraPlayerController.cpp index f2c14e0..aca1817 100644 --- a/Source/Aura/Private/Player/AuraPlayerController.cpp +++ b/Source/Aura/Private/Player/AuraPlayerController.cpp @@ -4,12 +4,20 @@ #include "Player/AuraPlayerController.h" #include "EnhancedInputSubsystems.h" #include "EnhancedInputComponent.h" +#include "Interaction/EnemyInterface.h" AAuraPlayerController::AAuraPlayerController() { bReplicates = true; } +void AAuraPlayerController::PlayerTick(float DeltaTime) +{ + Super::PlayerTick(DeltaTime); + + CursorTrace(); +} + void AAuraPlayerController::BeginPlay() { Super::BeginPlay(); @@ -52,3 +60,60 @@ void AAuraPlayerController::Move(const FInputActionValue& InputActionValue) } } +void AAuraPlayerController::CursorTrace() +{ + FHitResult CursorHit; + GetHitResultUnderCursor(ECC_Visibility, false, CursorHit); + if (!CursorHit.bBlockingHit) return; + + LastActor = ThisActor; + ThisActor = CursorHit.GetActor(); + + /** + * Line trace from cursor. There are several scenarios: + * A. LastActor is null && ThisActor is null + * - Do nothing + * B. LastActor is null && ThisActor is valid + * - Highlight ThisActor + * C. LastActor is valid && ThisActor is null + * - UnHighlight LastActor + * D. Both actors are valid, but LastActor != ThisActor + * - UnHighlight LastActor, and Highlight ThisActor + * E. Both actors are valid, and are the same actor + * - Do nothing + */ + if (LastActor == nullptr) + { + if (ThisActor != nullptr) + { + // Case B + ThisActor->HighlightActor(); + } + else + { + // Case A - both are null, do nothing + } + } + else // LastActor is valid + { + if (ThisActor == nullptr) + { + // Case C + LastActor->UnHighlightActor(); + } + else // both actors are valid + { + if (LastActor != ThisActor) + { + // Case D + LastActor->UnHighlightActor(); + ThisActor->HighlightActor(); + } + else + { + // Case E - do nothing + } + } + } +} + diff --git a/Source/Aura/Public/Character/AuraEnemy.h b/Source/Aura/Public/Character/AuraEnemy.h index 5dacaa9..15a987b 100644 --- a/Source/Aura/Public/Character/AuraEnemy.h +++ b/Source/Aura/Public/Character/AuraEnemy.h @@ -4,14 +4,19 @@ #include "CoreMinimal.h" #include "AuraCharacterBase.h" +#include "Interaction/EnemyInterface.h" #include "AuraEnemy.generated.h" /** * */ UCLASS() -class AURA_API AAuraEnemy : public AAuraCharacterBase +class AURA_API AAuraEnemy : public AAuraCharacterBase, public IEnemyInterface { GENERATED_BODY() - + +public: + AAuraEnemy(); + virtual void HighlightActor() override; + virtual void UnHighlightActor() override; }; diff --git a/Source/Aura/Public/Interaction/EnemyInterface.h b/Source/Aura/Public/Interaction/EnemyInterface.h new file mode 100644 index 0000000..c86bf07 --- /dev/null +++ b/Source/Aura/Public/Interaction/EnemyInterface.h @@ -0,0 +1,27 @@ +// Assets provided by DruidMechanics. Copyright Jonathan Rampersad 2024 + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/Interface.h" +#include "EnemyInterface.generated.h" + +// This class does not need to be modified. +UINTERFACE() +class UEnemyInterface : public UInterface +{ + GENERATED_BODY() +}; + +/** + * + */ +class AURA_API IEnemyInterface +{ + GENERATED_BODY() + + // Add interface functions to this class. This is the class that will be inherited to implement this interface. +public: + virtual void HighlightActor() = 0; + virtual void UnHighlightActor() = 0; +}; diff --git a/Source/Aura/Public/Player/AuraPlayerController.h b/Source/Aura/Public/Player/AuraPlayerController.h index fc0f92d..0e972b7 100644 --- a/Source/Aura/Public/Player/AuraPlayerController.h +++ b/Source/Aura/Public/Player/AuraPlayerController.h @@ -9,6 +9,7 @@ struct FInputActionValue; class UInputAction; class UInputMappingContext; +class IEnemyInterface; /** * @@ -21,6 +22,8 @@ class AURA_API AAuraPlayerController : public APlayerController public: AAuraPlayerController(); + virtual void PlayerTick(float DeltaTime) override; + protected: virtual void BeginPlay() override; @@ -34,4 +37,8 @@ private: TObjectPtr MoveAction; void Move(const FInputActionValue& InputActionValue); + + void CursorTrace(); + TScriptInterface LastActor; + TScriptInterface ThisActor; };