diff --git a/Content/Blueprints/Characters/BP_Player.uasset b/Content/Blueprints/Characters/BP_Player.uasset new file mode 100644 index 0000000..c2bc16c Binary files /dev/null and b/Content/Blueprints/Characters/BP_Player.uasset differ diff --git a/Content/Blueprints/GameModes/BP_MainGameMode.uasset b/Content/Blueprints/GameModes/BP_MainGameMode.uasset index 9a721f6..c1ba1d7 100644 Binary files a/Content/Blueprints/GameModes/BP_MainGameMode.uasset and b/Content/Blueprints/GameModes/BP_MainGameMode.uasset differ diff --git a/Content/Blueprints/Other/BP_CustomGameInstance.uasset b/Content/Blueprints/Other/BP_CustomGameInstance.uasset index c2fc893..3e91a9a 100644 Binary files a/Content/Blueprints/Other/BP_CustomGameInstance.uasset and b/Content/Blueprints/Other/BP_CustomGameInstance.uasset differ diff --git a/Content/Blueprints/Other/BP_MainWidgetManager.uasset b/Content/Blueprints/Other/BP_MainWidgetManager.uasset deleted file mode 100644 index cce8750..0000000 Binary files a/Content/Blueprints/Other/BP_MainWidgetManager.uasset and /dev/null differ diff --git a/Content/Levels/Test/L_Test.umap b/Content/Levels/Test/L_Test.umap index 74452a1..6cdd946 100644 Binary files a/Content/Levels/Test/L_Test.umap and b/Content/Levels/Test/L_Test.umap differ diff --git a/Content/Levels/Test/L_Test_BuiltData.uasset b/Content/Levels/Test/L_Test_BuiltData.uasset index f02e9d0..d2d569c 100644 Binary files a/Content/Levels/Test/L_Test_BuiltData.uasset and b/Content/Levels/Test/L_Test_BuiltData.uasset differ diff --git a/Content/Misc/Interactables/M_InteractableScreencapturerPP.uasset b/Content/Misc/Interactables/M_InteractableScreencapturerPP.uasset new file mode 100644 index 0000000..8a552bb Binary files /dev/null and b/Content/Misc/Interactables/M_InteractableScreencapturerPP.uasset differ diff --git a/Content/Misc/Interactables/T_InteractableScreencapturerDebugInput.uasset b/Content/Misc/Interactables/T_InteractableScreencapturerDebugInput.uasset new file mode 100644 index 0000000..7c5c7bb Binary files /dev/null and b/Content/Misc/Interactables/T_InteractableScreencapturerDebugInput.uasset differ diff --git a/Content/Misc/Interactables/T_InteractableScreencapturerDebugOutput.uasset b/Content/Misc/Interactables/T_InteractableScreencapturerDebugOutput.uasset new file mode 100644 index 0000000..12a85ce Binary files /dev/null and b/Content/Misc/Interactables/T_InteractableScreencapturerDebugOutput.uasset differ diff --git a/Content/Misc/Materials/Colors/M_Color_Pink.uasset b/Content/Misc/Materials/Colors/M_Color_Pink.uasset new file mode 100644 index 0000000..35ef0b4 Binary files /dev/null and b/Content/Misc/Materials/Colors/M_Color_Pink.uasset differ diff --git a/Content/UI/BP_MainWidgetManager.uasset b/Content/UI/BP_MainWidgetManager.uasset new file mode 100644 index 0000000..06a5140 Binary files /dev/null and b/Content/UI/BP_MainWidgetManager.uasset differ diff --git a/Content/UI/Blueprints/Overlays/UI_Crosshair.uasset b/Content/UI/Blueprints/Overlays/UI_Crosshair.uasset new file mode 100644 index 0000000..914a7b6 Binary files /dev/null and b/Content/UI/Blueprints/Overlays/UI_Crosshair.uasset differ diff --git a/Content/UI/Blueprints/Overlays/UI_DevelopBuildWarning.uasset b/Content/UI/Blueprints/Overlays/UI_DevelopBuildWarning.uasset new file mode 100644 index 0000000..9bf233c Binary files /dev/null and b/Content/UI/Blueprints/Overlays/UI_DevelopBuildWarning.uasset differ diff --git a/Content/UI/Blueprints/UI_Crosshair.uasset b/Content/UI/Blueprints/UI_Crosshair.uasset deleted file mode 100644 index 6edc669..0000000 Binary files a/Content/UI/Blueprints/UI_Crosshair.uasset and /dev/null differ diff --git a/Content/UI/Blueprints/UI_DevelopBuildWarning.uasset b/Content/UI/Blueprints/UI_DevelopBuildWarning.uasset deleted file mode 100644 index 623edfb..0000000 Binary files a/Content/UI/Blueprints/UI_DevelopBuildWarning.uasset and /dev/null differ diff --git a/Content/UI/Interactables/BP_InteractableHintWidgetManager.uasset b/Content/UI/Interactables/BP_InteractableHintWidgetManager.uasset new file mode 100644 index 0000000..038d9b7 Binary files /dev/null and b/Content/UI/Interactables/BP_InteractableHintWidgetManager.uasset differ diff --git a/Content/tempStaff/Input.uasset b/Content/tempStaff/Input.uasset deleted file mode 100644 index 85e327b..0000000 Binary files a/Content/tempStaff/Input.uasset and /dev/null differ diff --git a/Lost_Edge.uproject b/Lost_Edge.uproject index 1c0f94b..4a34664 100644 --- a/Lost_Edge.uproject +++ b/Lost_Edge.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "{0DD41C75-443A-77B1-7C02-5F9B73D04B7B}", + "EngineAssociation": "5.4", "Category": "", "Description": "", "Modules": [ diff --git a/Shaders/Private/InteractableScreenCapturerBitMapCS.usf b/Shaders/Private/InteractableScreenCapturerBitMapCS.usf index 97059f8..53bae47 100644 --- a/Shaders/Private/InteractableScreenCapturerBitMapCS.usf +++ b/Shaders/Private/InteractableScreenCapturerBitMapCS.usf @@ -10,14 +10,14 @@ RWBuffer Output; void InteractableScreenCapturerBitMapCS( uint3 dti : SV_DispatchThreadID) { - switch (Input[dti.x]) - { - case 0xFF00FFFF: - //Output[dti.x / 4] = Output[dti.x / 4] | (0xFF << 8 * (3 - (dti.x % 4))); // sets n-th byte to 0xFF - break; - default: - //Output[dti.x / 4] = Output[dti.x / 4] & ~(0xFF << 8 * (3 - (dti.x % 4))); // sets n-th byte to 0x00 - break; - } - //Output[0] = 1; + Output[dti.x] = Input[dti.x]; + //switch (Input[dti.x]) + //{ + // case 0xFF00FFFF: + // Output[dti.x / 4] = Output[dti.x / 4] | (0xFF << 8 * (3 - (dti.x % 4))); // sets n-th byte to 0xFF + // break; + // default: + // Output[dti.x / 4] = Output[dti.x / 4] & ~(0xFF << 8 * (3 - (dti.x % 4))); // sets n-th byte to 0x00 + // break; + //} } \ No newline at end of file diff --git a/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp b/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp index 791bf1d..64048f6 100644 --- a/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp +++ b/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp @@ -7,13 +7,14 @@ #include "InputMappingContext.h" #include "CustomGameUserSettings.h" -#include "Interactable/SawInteractable.h" -#include "Interactable/UsableInteractable.h" +#include "Interactable/Activators/InCameraInteractableActivator.h" +#include "Interactable/Activators/RaycastInteractableActivator.h" void UCustomGameInstanceBase::Init() { // IN FUTURE ASSIGN FROM CONTENT LOADER MEMBER - interactionsActivators = { {UUsableInteractable::StaticClass()}, {USawInteractable::StaticClass()} }; + interactionsActivators.Add(URaycastInteractableActivator::StaticClass()); + interactionsActivators.Add(UInCameraInteractableActivator::StaticClass()); UGameInstance::Init(); diff --git a/Source/Lost_Edge/Private/CustomGameInstanceBase.h b/Source/Lost_Edge/Private/CustomGameInstanceBase.h index 7b78065..77d9803 100644 --- a/Source/Lost_Edge/Private/CustomGameInstanceBase.h +++ b/Source/Lost_Edge/Private/CustomGameInstanceBase.h @@ -19,7 +19,7 @@ public: void ApplyMouseSettings(); UPROPERTY(EditDefaultsOnly) - TArray> interactionsActivators; + TArray> interactionsActivators; protected: UPROPERTY(EditDefaultsOnly) diff --git a/Source/Lost_Edge/Private/Interactable/InCameraInteractableActivator.cpp b/Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.cpp similarity index 85% rename from Source/Lost_Edge/Private/Interactable/InCameraInteractableActivator.cpp rename to Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.cpp index 21b1096..67ab07e 100644 --- a/Source/Lost_Edge/Private/Interactable/InCameraInteractableActivator.cpp +++ b/Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.cpp @@ -1,9 +1,8 @@ // Oleg Petruny proprietary. -#include "Interactable/InCameraInteractableActivator.h" +#include "InCameraInteractableActivator.h" -#include "Interactable.h" #include "InteractableScreenCapturer.h" UInCameraInteractableActivator::UInCameraInteractableActivator(const FObjectInitializer& ObjectInitializer) @@ -14,9 +13,13 @@ UInCameraInteractableActivator::UInCameraInteractableActivator(const FObjectInit return; } + activatorType = EActivatorType::Saw; + scanDistance = 7000; + _capturer = CreateDefaultSubobject(TEXT("UInCameraInteractableActivator_UInteractableScreenCapturer")); _capturer->interactableInScreenDelegate.BindUObject(this, &UInCameraInteractableActivator::NewSeenInteractable_Implementation); _capturer->SetupAttachment(this); + _capturer->scanDistance = scanDistance; PrimaryComponentTick.bCanEverTick = true; PrimaryComponentTick.bStartWithTickEnabled = false; @@ -44,7 +47,7 @@ void UInCameraInteractableActivator::Scan_Implementation() _interactablesToActivate.Dequeue(interactable); if(interactableActivatedDelegate.IsBound()) { - interactableActivatedDelegate.Execute(interactable); + interactableActivatedDelegate.Execute(interactable, activatorType); } } } \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/InCameraInteractableActivator.h b/Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.h similarity index 100% rename from Source/Lost_Edge/Private/Interactable/InCameraInteractableActivator.h rename to Source/Lost_Edge/Private/Interactable/Activators/InCameraInteractableActivator.h diff --git a/Source/Lost_Edge/Private/Interactable/InteractableActivator.cpp b/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.cpp similarity index 100% rename from Source/Lost_Edge/Private/Interactable/InteractableActivator.cpp rename to Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.cpp diff --git a/Source/Lost_Edge/Private/Interactable/InteractableActivator.h b/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.h similarity index 75% rename from Source/Lost_Edge/Private/Interactable/InteractableActivator.h rename to Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.h index 3b31f83..5d357f1 100644 --- a/Source/Lost_Edge/Private/Interactable/InteractableActivator.h +++ b/Source/Lost_Edge/Private/Interactable/Activators/InteractableActivator.h @@ -5,10 +5,12 @@ #include "Components/SceneComponent.h" #include "CoreMinimal.h" +#include "../Interactable.h" + #include "InteractableActivator.generated.h" -DECLARE_DELEGATE_OneParam(FInteractableActivated, class AInteractable*); -DECLARE_DELEGATE_OneParam(FInteractableDeactivated, class AInteractable*); +DECLARE_DELEGATE_TwoParams(FInteractableActivated, AInteractable*, EActivatorType); +DECLARE_DELEGATE_TwoParams(FInteractableDeactivated, AInteractable*, EActivatorType); UCLASS(Abstract, Blueprintable, BlueprintType) class UInteractableActivator : public USceneComponent @@ -27,10 +29,13 @@ protected: inline void Scan(); inline virtual void Scan_Implementation() PURE_VIRTUAL(UInteractableActivator::Scan_Implementation, ); + UPROPERTY(EditDefaultsOnly) + EActivatorType activatorType; + UPROPERTY(EditDefaultsOnly) float scanDistance = 200; class UWorld* world; class APlayerBase* player; - enum ECollisionChannel collisionChannel; + ECollisionChannel collisionChannel; }; diff --git a/Source/Lost_Edge/Private/Interactable/InteractableScreenCapturer.cpp b/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.cpp similarity index 64% rename from Source/Lost_Edge/Private/Interactable/InteractableScreenCapturer.cpp rename to Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.cpp index ccc3797..24f65aa 100644 --- a/Source/Lost_Edge/Private/Interactable/InteractableScreenCapturer.cpp +++ b/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.cpp @@ -7,16 +7,18 @@ #include "Engine/TextureRenderTarget2D.h" #include "Kismet/GameplayStatics.h" #include "opencv2/imgproc.hpp" +#include "RenderGraphUtils.h" +#include "RHIGPUReadback.h" #include "RHIResources.h" #include "SceneView.h" #include "TextureCompressorModule.h" -#include "Interactable.h" +#include "../Interactable.h" +#include "InteractableScreenCapturerBitMapCS.h" constexpr float tickInterval = 1.0f / 5; constexpr float textureWidth = 1280 / 2; constexpr float textureHeight = 720 / 2; -constexpr float rayDistance = 7000; UInteractableScreenCapturer::UInteractableScreenCapturer(const FObjectInitializer& ObjectInitializer) : USceneCaptureComponent2D(ObjectInitializer) @@ -24,7 +26,8 @@ UInteractableScreenCapturer::UInteractableScreenCapturer(const FObjectInitialize PrimaryComponentTick.bCanEverTick = false; PrimaryComponentTick.bStartWithTickEnabled = false; - TextureTarget = LoadObject(this, TEXT("/Game/tempStaff/Input")); + TextureTarget = LoadObject(this, TEXT("/Game/Misc/Interactables/T_InteractableScreencapturerDebugInput")); + //_output = LoadObject(this, TEXT("/Game/Misc/Interactables/T_InteractableScreencapturerDebugOutput")); //TextureTarget = ObjectInitializer.CreateDefaultSubobject(this, TEXT("UInteractableScreenCapturer_TextureRenderTarget")); //TextureTarget->RenderTargetFormat = ETextureRenderTargetFormat::RTF_RGBA8; //TextureTarget->ClearColor = FLinearColor::Black; @@ -36,12 +39,14 @@ UInteractableScreenCapturer::UInteractableScreenCapturer(const FObjectInitialize PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_LegacySceneCapture; bCaptureEveryFrame = 0; bCaptureOnMovement = 0; - LODDistanceFactor = 10000; + LODDistanceFactor = 1; bUseRayTracingIfEnabled = false; - CaptureSource = ESceneCaptureSource::SCS_BaseColor; + CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR; CompositeMode = ESceneCaptureCompositeMode::SCCM_Overwrite; - PostProcessBlendWeight = 0; + PostProcessBlendWeight = 1; + auto ppMaterial = LoadObject(this, TEXT("/Game/Misc/Interactables/M_InteractableScreencapturerPP")); + PostProcessSettings.AddBlendable(ppMaterial, 1.0f); bUseCustomProjectionMatrix = false; bAlwaysPersistRenderingState = true; @@ -57,6 +62,8 @@ UInteractableScreenCapturer::UInteractableScreenCapturer(const FObjectInitialize ShowFlags.SetGame(true); ShowFlags.SetMaterials(true); ShowFlags.SetRendering(true); + ShowFlags.SetPostProcessMaterial(true); + ShowFlags.SetPostProcessing(true); PrimaryComponentTick.TickInterval = tickInterval; PrimaryComponentTick.bCanEverTick = true; @@ -74,7 +81,7 @@ void UInteractableScreenCapturer::TickComponent(float DeltaTime, enum ELevelTick USceneCaptureComponent2D::TickComponent(DeltaTime, TickType, ThisTickFunction); CaptureScene(); GetCameraView(DeltaTime, _view); - Process(); + //Process(); } break; default: @@ -93,13 +100,71 @@ void UInteractableScreenCapturer::Process() capture = TextureTarget->GetResource()->TextureRHI, world = GetWorld(), view = _view, + //output = _output->GetResource()->TextureRHI, this ] (FRHICommandListImmediate& RHICmdList) { +#ifdef INTERACTABLE_ACTIVATOR_DEBUG double StartTime = FPlatformTime::Seconds(); +#endif // INTERACTABLE_ACTIVATOR_DEBUG static FIntPoint _extent = capture->GetDesc().Extent; - static uint32 _size = _extent.X * _extent.Y; + static int32 _size = _extent.X * _extent.Y; + + + //FRHIResourceCreateInfo outBufferCreateInfo(TEXT("InteractableScreenCapturerCSOutBuffer")); + //EBufferUsageFlags outBufferUsage = EBufferUsageFlags::UnorderedAccess | EBufferUsageFlags::SourceCopy; + //FBufferRHIRef outBuffer = RHICmdList.CreateBuffer(_size * sizeof(uint32), outBufferUsage, 0, ERHIAccess::UAVCompute, outBufferCreateInfo); + //auto outBufferUAVCreateDesc = FRHIViewDesc::CreateBufferUAV() + // .SetType(FRHIViewDesc::EBufferType::Typed) + // .SetFormat(PF_R32_UINT) + // .SetNumElements(_size); + //auto outBufferUAV = RHICmdList.CreateUnorderedAccessView(outBuffer, outBufferUAVCreateDesc); + // + //TShaderMapRef shader(GetGlobalShaderMap(GMaxRHIFeatureLevel)); + //const uint32 threadsNum = FMath::DivideAndRoundUp(_size, FInteractableScreenCapturerBitMapCS::shader_threads_per_group_count); + // + //FInteractableScreenCapturerBitMapCS::FParameters shaderParams; + //shaderParams.Input = RHICmdList.CreateShaderResourceView(capture, FRHIViewDesc::CreateTextureSRV() + // .SetDimensionFromTexture(capture) + // .SetMipRange(0, 1)); + //shaderParams.Output = outBufferUAV; + // + //FComputeShaderUtils::Dispatch(RHICmdList, shader, shaderParams, FIntVector(threadsNum, 1, 1)); + // + //RHICmdList.Transition({ FRHITransitionInfo(outBufferUAV, ERHIAccess::UAVCompute, ERHIAccess::CopySrc) }); + // + //// Kick off the readbacks. + //FRHIGPUBufferReadback outBufferReadback(TEXT("InteractableScreenCapturerCSOutBufferReadback")); + //outBufferReadback.EnqueueCopy(RHICmdList, outBuffer, _size * sizeof(uint32)); + // + //// Sync the GPU. Unfortunately we can't use the fences because not all RHIs implement them yet. + //RHICmdList.BlockUntilGPUIdle(); + //RHICmdList.FlushResources(); + // + //uint32* outBufferData = (uint32*)outBufferReadback.Lock(_size * sizeof(uint32)); + //uint32 sstride = 0; + //uint32* ddata = (uint32*)RHICmdList.LockTexture2D( + // output, + // 0, + // RLM_WriteOnly, + // sstride, + // false); + //for(int32 i = 0; i < _size; ++i) + //{ + // ddata[i] = outBufferData[i]; + // //switch(outBufferData[i]) + // //{ + // // case 0xFF: + // // ddata[i] = 0xFFFFFFFF; + // // default: + // // ddata[i] = 0x00000000; + // //} + //} + //RHICmdList.UnlockTexture2D(output, 0, false); + // + //outBufferReadback.Unlock(); + static uint8* _bitMap = new uint8[_size]; // cv::Mat allocation is weird sometimes... @@ -110,7 +175,7 @@ void UInteractableScreenCapturer::Process() RLM_ReadOnly, stride, false); - for(uint32 i = 0; i < _size; ++i) + for(int32 i = 0; i < _size; ++i) { switch(data[i].R) { @@ -167,17 +232,15 @@ void UInteractableScreenCapturer::Process() * (FInverseRotationMatrix(view.Rotation) * FMatrix(FPlane(0, 0, 1, 0), FPlane(1, 0, 0, 0), FPlane(0, 1, 0, 0), FPlane(0, 0, 0, 1))) * view.CalculateProjectionMatrix()) .InverseFast(); - GEngine->AddOnScreenDebugMessage(60, 0.5f, FColor::Yellow, FString::Printf(TEXT("x:%f, y:%f"), view.Rotation.Yaw, view.Rotation.Roll)); FVector worldLoc, worldDir; for(int i = 1; i < components; ++i) { FVector2D screenPos = { ((double*)componentsCentroids.data)[i * 2], ((double*)componentsCentroids.data)[i * 2 + 1] }; FSceneView::DeprojectScreenToWorld(screenPos, FIntRect{ {0, 0}, _extent }, _invProjection, worldLoc, worldDir); - //GEngine->AddOnScreenDebugMessage(66 + i, 0.5f, FColor::Yellow, FString::Printf(TEXT("x:%f, y:%f"), screenPos.X, screenPos.Y)); FHitResult result{}; FVector startLocation = view.Location; - FVector endLocation = worldLoc + worldDir * rayDistance; + FVector endLocation = worldLoc + worldDir * scanDistance; world->LineTraceSingleByChannel( result, startLocation, @@ -196,19 +259,23 @@ void UInteractableScreenCapturer::Process() interactableInScreenDelegate.Execute(interactable); }); } - //GEngine->AddOnScreenDebugMessage(10 + i, 0.5f, FColor::Yellow, interactable->GetName()); - GEngine->AddOnScreenDebugMessage(20 + i, 0.5f, FColor::Yellow, FString::Printf(TEXT("dist:%f"), (view.Location - interactable->GetActorLocation()).Length())); } - +#ifdef INTERACTABLE_ACTIVATOR_DEBUG DrawDebugLine(world, startLocation, endLocation, FColor::Green, false, tickInterval, 0, 0.5f); +#endif // INTERACTABLE_ACTIVATOR_DEBUG + } +#ifdef INTERACTABLE_ACTIVATOR_DEBUG else { DrawDebugLine(world, startLocation, endLocation, FColor::Red, false, tickInterval, 10, 0.5f); } - //DrawDebugLine(world, startLocation, endLocation, FColor::Red, false, tickInterval, 0, 0.5f); +#endif // INTERACTABLE_ACTIVATOR_DEBUG + } - GEngine->AddOnScreenDebugMessage(667, 0.5f, FColor::Yellow, FString::Printf(TEXT("time:%f"), FPlatformTime::Seconds() - StartTime)); +#ifdef INTERACTABLE_ACTIVATOR_DEBUG + GEngine->AddOnScreenDebugMessage(30 + (int)EActivatorType::Saw, 0.5f, FColor::Yellow, FString::Printf(TEXT("ScreenCapturer calltime: %f"), FPlatformTime::Seconds() - StartTime)); +#endif // INTERACTABLE_ACTIVATOR_DEBUG running = false; } ); diff --git a/Source/Lost_Edge/Private/Interactable/InteractableScreenCapturer.h b/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.h similarity index 89% rename from Source/Lost_Edge/Private/Interactable/InteractableScreenCapturer.h rename to Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.h index f273685..9bcd52a 100644 --- a/Source/Lost_Edge/Private/Interactable/InteractableScreenCapturer.h +++ b/Source/Lost_Edge/Private/Interactable/Activators/InteractableScreenCapturer.h @@ -20,10 +20,14 @@ public: FInteractableInScreen interactableInScreenDelegate; + UPROPERTY(EditAnywhere) + float scanDistance = 7000; + protected: void Process(); private: FMinimalViewInfo _view; TSet _sawInteractables; + //class UTextureRenderTarget2D* _output; }; diff --git a/Source/Lost_Edge/Private/Interactable/RaycastInteractableActivator.cpp b/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.cpp similarity index 58% rename from Source/Lost_Edge/Private/Interactable/RaycastInteractableActivator.cpp rename to Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.cpp index 59516e0..d202226 100644 --- a/Source/Lost_Edge/Private/Interactable/RaycastInteractableActivator.cpp +++ b/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.cpp @@ -6,7 +6,11 @@ #include "DrawDebugHelpers.h" #include "Engine/World.h" -#include "Interactable.h" +URaycastInteractableActivator::URaycastInteractableActivator(const FObjectInitializer& ObjectInitializer) + : UInteractableActivator(ObjectInitializer) +{ + activatorType = EActivatorType::Use; +} void URaycastInteractableActivator::Scan_Implementation() { @@ -27,31 +31,40 @@ void URaycastInteractableActivator::Scan_Implementation() { if(_last != result.GetActor()) { + if(_last) + { + interactableDeactivatedDelegate.Execute(_last, activatorType); + _last = nullptr; + } _activated = true; if(auto interactable = Cast(result.GetActor())) { _last = interactable; if(interactableActivatedDelegate.IsBound()) { - interactableActivatedDelegate.Execute(interactable); + interactableActivatedDelegate.Execute(interactable, activatorType); + } } } - } - //DrawDebugLine(GetWorld(), startLocation, endLocation, FColor::Green, false, 0.5f, 0, 1.0f); - } +#ifdef INTERACTABLE_ACTIVATOR_DEBUG + DrawDebugLine(GetWorld(), startLocation, endLocation, FColor::Green, false, 0.5f, 0, 0.5f); +#endif // INTERACTABLE_ACTIVATOR_DEBUG + } else { if(_activated) { if(interactableDeactivatedDelegate.IsBound()) { - interactableDeactivatedDelegate.Execute(_last); + interactableDeactivatedDelegate.Execute(_last, activatorType); } _activated = false; _last = nullptr; - } + } - //DrawDebugLine(GetWorld(), startLocation, endLocation, FColor::Red, false, 0.5f, 10, 1.0f); - } -} \ No newline at end of file +#ifdef INTERACTABLE_ACTIVATOR_DEBUG + DrawDebugLine(GetWorld(), startLocation, endLocation, FColor::Red, false, 0.5f, 10, 0.5f); +#endif // INTERACTABLE_ACTIVATOR_DEBUG + } + } \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/RaycastInteractableActivator.h b/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.h similarity index 80% rename from Source/Lost_Edge/Private/Interactable/RaycastInteractableActivator.h rename to Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.h index 2519571..6be85dc 100644 --- a/Source/Lost_Edge/Private/Interactable/RaycastInteractableActivator.h +++ b/Source/Lost_Edge/Private/Interactable/Activators/RaycastInteractableActivator.h @@ -12,6 +12,9 @@ class URaycastInteractableActivator : public UInteractableActivator { GENERATED_BODY() +public: + URaycastInteractableActivator(const FObjectInitializer& ObjectInitializer); + protected: void Scan(); virtual void Scan_Implementation() override; diff --git a/Source/Lost_Edge/Private/Interactable/Interactable.cpp b/Source/Lost_Edge/Private/Interactable/Interactable.cpp index 7ff6710..14adcf9 100644 --- a/Source/Lost_Edge/Private/Interactable/Interactable.cpp +++ b/Source/Lost_Edge/Private/Interactable/Interactable.cpp @@ -3,4 +3,59 @@ #include "Interactable.h" +#include "Kismet/GameplayStatics.h" +#include "../MainGameModeBase.h" +#include "../Widgets/WidgetsManager.h" +#include "Modificators/InteractableModificator.h" + +void AInteractable::BeginPlay() +{ + // FOR ADRESS TO COLOR + //if(auto m = material.LoadSynchronous()) + //{ + // if(material->VectorParameterValues.Num() > 0) + // { + // GEngine->AddOnScreenDebugMessage(5, 5.0f, FColor::Emerald, material->VectorParameterValues[0].ParameterInfo.Name.ToString()); + // } + //} + + TArray meshes; + GetComponents(meshes); + for(auto mesh : meshes) + { + mesh->CustomDepthStencilValue = 0; + mesh->CustomDepthStencilWriteMask = ERendererStencilMask::ERSM_Default; + mesh->SetRenderCustomDepth(true); + } + + for(auto& modificatorClass : modificatorsClasses) + { + _modificators.Add(NewObject(this, modificatorClass)); + } +} + +void AInteractable::_Activate(EActivatorType type) +{ + activated |= static_cast(type); + if(auto WM = AMainGameModeBase::GetWidgetManager()) + { + for(const auto modificator : _modificators) + { + WM->ShowInteractionHints(modificator); + } + } + + Activate_Implementation(type); +} + +void AInteractable::_Deactivate(EActivatorType type) +{ + activated &= ~static_cast(type); + if(auto WM = AMainGameModeBase::GetWidgetManager()) + { + WM->HideInteractionHints(type); + } + + Deactivate_Implementation(type); +} diff --git a/Source/Lost_Edge/Private/Interactable/Interactable.h b/Source/Lost_Edge/Private/Interactable/Interactable.h index 4bbcc71..3163038 100644 --- a/Source/Lost_Edge/Private/Interactable/Interactable.h +++ b/Source/Lost_Edge/Private/Interactable/Interactable.h @@ -4,19 +4,55 @@ #include "CoreMinimal.h" #include "GameFramework/Actor.h" -#include "UObject/ScriptInterface.h" #include "Interactable.generated.h" +#define INTERACTABLE_DEBUG +//#define INTERACTABLE_ACTIVATOR_DEBUG + +UENUM(BlueprintType, meta = (Bitflags)) +enum class EActivatorType : uint8 +{ + None = 0, + Use = 1 << 0, + Saw = 1 << 1, + Custom1 = 1 << 2 UMETA(DisplayName = "Custom 1"), + Custom2 = 1 << 3 UMETA(DisplayName = "Custom 2"), + Custom3 = 1 << 4 UMETA(DisplayName = "Custom 3"), + Custom4 = 1 << 5 UMETA(DisplayName = "Custom 4"), + Custom5 = 1 << 6 UMETA(DisplayName = "Custom 5"), + Custom6 = 1 << 7 UMETA(DisplayName = "Custom 6") +}; +ENUM_CLASS_FLAGS(EActivatorType) + UCLASS(Abstract, MinimalAPI, Blueprintable, BlueprintType) class AInteractable : public AActor { GENERATED_BODY() public: + void _Activate(EActivatorType type); UFUNCTION(BlueprintNativeEvent, BlueprintCallable) - TArray> GetInteractableComponents(); - virtual TArray> GetInteractableComponents_Implementation() - PURE_VIRTUAL(AInteractable::GetInteractableComponents_Implementation, return {};); + void Activate(EActivatorType type); + virtual void Activate_Implementation(EActivatorType type) {} + + void _Deactivate(EActivatorType type); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable) + void Deactivate(EActivatorType type); + virtual void Deactivate_Implementation(EActivatorType type) {} + +protected: + virtual void BeginPlay() override; + + UPROPERTY(BlueprintReadWrite, meta = (Bitmask, BitmaskEnum = "EActivatorType")) + uint8 activated = 0; + + UPROPERTY(EditDefaultsOnly) + TArray> modificatorsClasses; + +private: + //UPROPERTY(EditDefaultsOnly) + //TSoftObjectPtr material; + TArray _modificators; }; diff --git a/Source/Lost_Edge/Private/Interactable/InteractableCaller.cpp b/Source/Lost_Edge/Private/Interactable/InteractableCaller.cpp deleted file mode 100644 index 2c2a03f..0000000 --- a/Source/Lost_Edge/Private/Interactable/InteractableCaller.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Oleg Petruny proprietary. - - -#include "InteractableCaller.h" - -UInteractableCaller::UInteractableCaller(const FObjectInitializer& ObjectInitializer) - : UActorComponent(ObjectInitializer) -{ - if(HasAnyFlags(RF_ClassDefaultObject | RF_ArchetypeObject)) - { - return; - } - - RegisterComponent(); -} - -void UInteractableCaller::Init() -{ - //GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, GetOwner()->GetName()); -} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/InteractableCaller.h b/Source/Lost_Edge/Private/Interactable/InteractableCaller.h deleted file mode 100644 index a3f8018..0000000 --- a/Source/Lost_Edge/Private/Interactable/InteractableCaller.h +++ /dev/null @@ -1,19 +0,0 @@ -// Oleg Petruny proprietary. - -#pragma once - -#include "Components/ActorComponent.h" -#include "CoreMinimal.h" - -#include "InteractableCaller.generated.h" - -UCLASS(Abstract, Blueprintable, BlueprintType) -class UInteractableCaller : public UActorComponent -{ - GENERATED_BODY() - -public: - UInteractableCaller(const FObjectInitializer& ObjectInitializer); - - void Init(); -}; \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/InteractableComponent.cpp b/Source/Lost_Edge/Private/Interactable/InteractableComponent.cpp deleted file mode 100644 index 5a6caa3..0000000 --- a/Source/Lost_Edge/Private/Interactable/InteractableComponent.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Oleg Petruny proprietary. - - -#include "InteractableComponent.h" - diff --git a/Source/Lost_Edge/Private/Interactable/InteractableComponent.h b/Source/Lost_Edge/Private/Interactable/InteractableComponent.h deleted file mode 100644 index 1514f7d..0000000 --- a/Source/Lost_Edge/Private/Interactable/InteractableComponent.h +++ /dev/null @@ -1,29 +0,0 @@ -// Oleg Petruny proprietary. - -#pragma once - -#include "CoreMinimal.h" -#include "InputMappingContext.h" -#include "UObject/Interface.h" - -#include "InteractableActivator.h" - -#include "InteractableComponent.generated.h" - -UCLASS(Abstract, Blueprintable, BlueprintType) -class UInteractableComponent : public UActorComponent -{ - GENERATED_BODY() - -public: - UFUNCTION(BlueprintNativeEvent, BlueprintCallable) - const FString GetName(); - virtual const FString GetName_Implementation() - PURE_VIRTUAL(UInteractableComponent::GetInteractionName_Implementation, return "NONE";); - - UFUNCTION(BlueprintNativeEvent, BlueprintCallable) - const TArray> GetActivators(); - virtual const TArray> GetActivators_Implementation() - PURE_VIRTUAL(UInteractableComponent::GetActivatorsZ_Implementation, - TArray> _activators{}; return _activators;); -}; diff --git a/Source/Lost_Edge/Private/Interactable/Modificators/InteractableModificator.cpp b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableModificator.cpp new file mode 100644 index 0000000..aeb0054 --- /dev/null +++ b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableModificator.cpp @@ -0,0 +1,16 @@ +// Oleg Petruny proprietary. + + +#include "InteractableModificator.h" + +#include "InputMappingContext.h" + +const UInputMappingContext* UInteractableModificator::GetMappingContext() const +{ + return inputMapping.LoadSynchronous(); +} + +EActivatorType UInteractableModificator::GetActivatorTypes() const +{ + return static_cast(activatorTypes); +} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/Modificators/InteractableModificator.h b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableModificator.h new file mode 100644 index 0000000..43408b6 --- /dev/null +++ b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableModificator.h @@ -0,0 +1,27 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "Components/ActorComponent.h" +#include "CoreMinimal.h" + +#include "InteractableModificator.generated.h" + +enum class EActivatorType : uint8; + +UCLASS(Abstract, Blueprintable, BlueprintType) +class UInteractableModificator : public UActorComponent +{ + GENERATED_BODY() + +public: + const class UInputMappingContext* GetMappingContext() const; + EActivatorType GetActivatorTypes() const; + +protected: + UPROPERTY(EditDefaultsOnly) + TSoftObjectPtr inputMapping; + + UPROPERTY(EditAnywhere, meta = (Bitmask, BitmaskEnum = "EActivatorType")) + uint8 activatorTypes = 0; +}; diff --git a/Source/Lost_Edge/Private/Interactable/Modificators/InteractableUsableModificator.cpp b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableUsableModificator.cpp new file mode 100644 index 0000000..40048d3 --- /dev/null +++ b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableUsableModificator.cpp @@ -0,0 +1,5 @@ +// Oleg Petruny proprietary. + + +#include "InteractableUsableModificator.h" + diff --git a/Source/Lost_Edge/Private/Interactable/Modificators/InteractableUsableModificator.h b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableUsableModificator.h new file mode 100644 index 0000000..f78fa39 --- /dev/null +++ b/Source/Lost_Edge/Private/Interactable/Modificators/InteractableUsableModificator.h @@ -0,0 +1,18 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "InteractableModificator.h" + +#include "InteractableUsableModificator.generated.h" + + +UCLASS(Blueprintable, BlueprintType) +class UInteractableUsableModificator : public UInteractableModificator +{ + GENERATED_BODY() + +public: + +protected: +}; diff --git a/Source/Lost_Edge/Private/Interactable/SawInteractable.cpp b/Source/Lost_Edge/Private/Interactable/SawInteractable.cpp deleted file mode 100644 index f699ea6..0000000 --- a/Source/Lost_Edge/Private/Interactable/SawInteractable.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Oleg Petruny proprietary. - - -#include "SawInteractable.h" - -#include "InCameraInteractableActivator.h" -#include "InteractableCaller.h" - -const FString USawInteractable::GetName_Implementation() -{ - static auto _name = TEXT("Saw"); - return _name; -} - -const TArray> USawInteractable::GetActivators_Implementation() -{ - static TArray> _array = { - {UInCameraInteractableActivator::StaticClass()} - }; - return _array; -} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/SawInteractable.h b/Source/Lost_Edge/Private/Interactable/SawInteractable.h deleted file mode 100644 index 81cc5d3..0000000 --- a/Source/Lost_Edge/Private/Interactable/SawInteractable.h +++ /dev/null @@ -1,23 +0,0 @@ -// Oleg Petruny proprietary. - -#pragma once - -#include "CoreMinimal.h" - -#include "InteractableComponent.h" - -#include "SawInteractable.generated.h" - - -UCLASS(Blueprintable, BlueprintType) -class USawInteractable : public UInteractableComponent -{ - GENERATED_BODY() - -public: - const FString GetName(); - virtual const FString GetName_Implementation() override; - - const TArray> GetActivators(); - virtual const TArray> GetActivators_Implementation() override; -}; \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/UsableInteractable.cpp b/Source/Lost_Edge/Private/Interactable/UsableInteractable.cpp deleted file mode 100644 index 6e5d64a..0000000 --- a/Source/Lost_Edge/Private/Interactable/UsableInteractable.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Oleg Petruny proprietary. - - -#include "UsableInteractable.h" - -#include "RaycastInteractableActivator.h" - -const FString UUsableInteractable::GetName_Implementation() -{ - static auto _name = TEXT("Use"); - return _name; -} - -const TArray> UUsableInteractable::GetActivators_Implementation() -{ - static TArray> _array = { - {URaycastInteractableActivator::StaticClass()} - }; - return _array; -} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/Interactable/UsableInteractable.h b/Source/Lost_Edge/Private/Interactable/UsableInteractable.h deleted file mode 100644 index cf51761..0000000 --- a/Source/Lost_Edge/Private/Interactable/UsableInteractable.h +++ /dev/null @@ -1,23 +0,0 @@ -// Oleg Petruny proprietary. - -#pragma once - -#include "CoreMinimal.h" - -#include "InteractableComponent.h" - -#include "UsableInteractable.generated.h" - - -UCLASS(Blueprintable, BlueprintType) -class UUsableInteractable : public UInteractableComponent -{ - GENERATED_BODY() - -public: - const FString GetName(); - virtual const FString GetName_Implementation() override; - - const TArray> GetActivators(); - virtual const TArray> GetActivators_Implementation() override; -}; \ No newline at end of file diff --git a/Source/Lost_Edge/Private/MainGameModeBase.cpp b/Source/Lost_Edge/Private/MainGameModeBase.cpp index 4a6439f..521ca9e 100644 --- a/Source/Lost_Edge/Private/MainGameModeBase.cpp +++ b/Source/Lost_Edge/Private/MainGameModeBase.cpp @@ -9,8 +9,9 @@ #include "UObject/ScriptInterface.h" #include "CustomGameInstanceBase.h" -#include "Interactable/InteractableComponent.h" -#include "WidgetsManager.h" +#include "Widgets/WidgetsManager.h" + +UWidgetsManager* AMainGameModeBase::_widgetsManager = nullptr; void AMainGameModeBase::StartPlay() { @@ -37,6 +38,11 @@ bool AMainGameModeBase::SetPause(APlayerController* PC, FCanUnpause CanUnpauseDe return AGameModeBase::SetPause(PC, CanUnpauseDelegate); } +UWidgetsManager* AMainGameModeBase::GetWidgetManager() +{ + return _widgetsManager; +} + void AMainGameModeBase::SwitchCameraMode() { static TWeakObjectPtr _playerPawn = nullptr; diff --git a/Source/Lost_Edge/Private/MainGameModeBase.h b/Source/Lost_Edge/Private/MainGameModeBase.h index d9a9563..0d91121 100644 --- a/Source/Lost_Edge/Private/MainGameModeBase.h +++ b/Source/Lost_Edge/Private/MainGameModeBase.h @@ -18,10 +18,12 @@ public: void SwitchCameraMode(); + static class UWidgetsManager* GetWidgetManager(); + protected: UPROPERTY(EditDefaultsOnly) TSubclassOf widgetManagerClass; private: - class UWidgetsManager* _widgetsManager; + static class UWidgetsManager* _widgetsManager; }; diff --git a/Source/Lost_Edge/Private/PlayerBase.cpp b/Source/Lost_Edge/Private/PlayerBase.cpp index 39d864b..5f715b1 100644 --- a/Source/Lost_Edge/Private/PlayerBase.cpp +++ b/Source/Lost_Edge/Private/PlayerBase.cpp @@ -11,11 +11,7 @@ #include "Kismet/KismetMathLibrary.h" #include "CustomGameInstanceBase.h" -#include "Interactable/Interactable.h" -#include "Interactable/InteractableActivator.h" -#include "Interactable/InteractableCaller.h" -#include "Interactable/InteractableComponent.h" -#include "Interactable/UsableInteractable.h" +#include "Interactable/Activators/InteractableActivator.h" #include "CustomGameUserSettings.h" #include "MainGameModeBase.h" @@ -73,7 +69,7 @@ void APlayerBase::BeginPlay() } } - LoadInteractable(); + LoadInteractablesActivators(); } void APlayerBase::SwitchToCameraPawn() @@ -136,33 +132,46 @@ void APlayerBase::UpdatePitch(float min, float max) } } -void APlayerBase::LoadInteractable() +void APlayerBase::LoadInteractablesActivators() { - auto GI = Cast(GetWorld()->GetGameInstance()); - if(!GI) + if(auto GI = Cast(GetWorld()->GetGameInstance())) { - return; - } - - TSet> activators; - for(auto& interaction : GI->interactionsActivators) - { - auto actArray = interaction->GetDefaultObject()->GetActivators_Implementation(); - for(auto& act : actArray) + TSet instancedActivators; + for(auto& act : GI->interactionsActivators) { - if(!activators.Contains(act)) - { - activators.Add(act); - auto component = NewObject(this, act); - component->interactableActivatedDelegate.BindUObject(this, &APlayerBase::InteractableActivated); - component->SetupAttachment(camera); - component->RegisterComponent(); - } + if(instancedActivators.Contains(act)) + continue; + instancedActivators.Add(act); + + auto component = NewObject(this, act); + component->interactableActivatedDelegate.BindUObject(this, &APlayerBase::InteractableActivated); + component->interactableDeactivatedDelegate.BindUObject(this, &APlayerBase::InteractableDeactivated); + component->SetupAttachment(camera); + component->RegisterComponent(); } } } -void APlayerBase::InteractableActivated(AInteractable* interactable) +void APlayerBase::InteractableActivated(AInteractable* interactable, EActivatorType type) { - GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Cyan, TEXT("Player activate: ") + interactable->GetName()); + if(interactionLocked) + return; + + interactable->Activate(type); +#ifdef INTERACTABLE_DEBUG + GEngine->AddOnScreenDebugMessage(30 + (int)type, 5.0f, FColor::Cyan, TEXT("Player activate: ") + interactable->GetName() + + TEXT(" by: ") + StaticEnum()->GetNameByValue(static_cast(type)).ToString()); +#endif // INTERACTABLE_DEBUG +} + +void APlayerBase::InteractableDeactivated(AInteractable* interactable, EActivatorType type) +{ + if(interactionLocked) + return; + + interactable->Deactivate(type); +#ifdef INTERACTABLE_DEBUG + GEngine->AddOnScreenDebugMessage(30 + (int)type, 5.0f, FColor::Magenta, TEXT("Player deactivate: ") + interactable->GetName() + + TEXT(" by: ") + StaticEnum()->GetNameByValue(static_cast(type)).ToString()); +#endif // INTERACTABLE_DEBUG } \ No newline at end of file diff --git a/Source/Lost_Edge/Private/PlayerBase.h b/Source/Lost_Edge/Private/PlayerBase.h index ff5438a..6a30d28 100644 --- a/Source/Lost_Edge/Private/PlayerBase.h +++ b/Source/Lost_Edge/Private/PlayerBase.h @@ -5,6 +5,8 @@ #include "CoreMinimal.h" #include "GameFramework/Character.h" +#include "Interactable/Interactable.h" + #include "PlayerBase.generated.h" UCLASS() @@ -49,6 +51,8 @@ protected: bool jumpLocked = false; UPROPERTY(EditAnywhere) bool runLocked = false; + UPROPERTY(EditAnywhere) + bool interactionLocked = false; APlayerCameraManager* cameraManager; class UCameraComponent* camera; @@ -60,6 +64,7 @@ protected: float maxPitch = 65; private: - void LoadInteractable(); - void InteractableActivated(class AInteractable* interactable); + void LoadInteractablesActivators(); + void InteractableActivated(AInteractable* interactable, EActivatorType type); + void InteractableDeactivated(AInteractable* interactable, EActivatorType type); }; diff --git a/Source/Lost_Edge/Private/Widgets/InteractableHintWidget.cpp b/Source/Lost_Edge/Private/Widgets/InteractableHintWidget.cpp new file mode 100644 index 0000000..d4f5e3e --- /dev/null +++ b/Source/Lost_Edge/Private/Widgets/InteractableHintWidget.cpp @@ -0,0 +1,5 @@ +// Oleg Petruny proprietary. + + +#include "InteractableHintWidget.h" + diff --git a/Source/Lost_Edge/Private/Widgets/InteractableHintWidget.h b/Source/Lost_Edge/Private/Widgets/InteractableHintWidget.h new file mode 100644 index 0000000..f2fdc2c --- /dev/null +++ b/Source/Lost_Edge/Private/Widgets/InteractableHintWidget.h @@ -0,0 +1,23 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "Blueprint/UserWidget.h" +#include "CoreMinimal.h" + +#include "InteractableHintWidget.generated.h" + +UCLASS(Blueprintable) +class UInteractableHintWidget : public UUserWidget +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintNativeEvent, BlueprintCallable) + void Show(); + virtual void Show_Implementation() {} + + UFUNCTION(BlueprintNativeEvent, BlueprintCallable) + void Proceed(); + virtual void Proceed_Implementation() {} +}; diff --git a/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.cpp b/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.cpp new file mode 100644 index 0000000..800d26f --- /dev/null +++ b/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.cpp @@ -0,0 +1,4 @@ +// Oleg Petruny proprietary. + + +#include "InteractableHintWidgetManager.h" diff --git a/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.h b/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.h new file mode 100644 index 0000000..021add0 --- /dev/null +++ b/Source/Lost_Edge/Private/Widgets/InteractableHintWidgetManager.h @@ -0,0 +1,35 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "Blueprint/UserWidget.h" +#include "CoreMinimal.h" + +#include "InteractableHintWidgetManager.generated.h" + +enum class EActivatorType : uint8; + +UCLASS(Blueprintable) +class UInteractableHintWidgetManager : public UUserWidget +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintNativeEvent, BlueprintCallable) + void Append(const class UInteractableModificator* modificator); + virtual void Append_Implementation(const class UInteractableModificator* modificator) {} + + UFUNCTION(BlueprintNativeEvent, BlueprintCallable) + void Remove(EActivatorType type); + virtual void Remove_Implementation(EActivatorType type) {} + +protected: + UPROPERTY(EditDefaultsOnly) + TSubclassOf interactableHintPressWidgetClass; + class UInteractableHintWidget* interactableHintPressWidget; + + UPROPERTY(EditDefaultsOnly) + TSubclassOf interactableHintHoldWidgetClass; + class UInteractableHintWidget* interactableHintHoldWidget; + +}; diff --git a/Source/Lost_Edge/Private/WidgetsManager.cpp b/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp similarity index 77% rename from Source/Lost_Edge/Private/WidgetsManager.cpp rename to Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp index 6ee7e38..3fe1502 100644 --- a/Source/Lost_Edge/Private/WidgetsManager.cpp +++ b/Source/Lost_Edge/Private/Widgets/WidgetsManager.cpp @@ -5,12 +5,14 @@ #include "Blueprint/UserWidget.h" #include "Engine/World.h" +#include "InputMappingContext.h" #include "Kismet/GameplayStatics.h" #include "UObject/ScriptInterface.h" #include "CustomGameInstanceBase.h" #include "Interactable/Interactable.h" -#include "Interactable/InteractableComponent.h" +#include "Interactable/Modificators/InteractableModificator.h" +#include "InteractableHintWidgetManager.h" void UWidgetsManager::Init() { @@ -33,6 +35,8 @@ void UWidgetsManager::Init() } } } + + interactableHintWidgetManager = NewObject(this, interactableHintWidgetManagerClass); } void UWidgetsManager::HideOverlayWidgets() @@ -78,8 +82,11 @@ void UWidgetsManager::UpdateOverlayWidgetsOwner() } } -void UWidgetsManager::ShowInteractionHints(AInteractable* interactable) +void UWidgetsManager::ShowInteractionHints(const UInteractableModificator* modificator) { - GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("Interaction Hint")); - //interactable->GetInterfa + interactableHintWidgetManager->Append(modificator); +} +void UWidgetsManager::HideInteractionHints(const EActivatorType type) +{ + interactableHintWidgetManager->Remove(type); } \ No newline at end of file diff --git a/Source/Lost_Edge/Private/WidgetsManager.h b/Source/Lost_Edge/Private/Widgets/WidgetsManager.h similarity index 66% rename from Source/Lost_Edge/Private/WidgetsManager.h rename to Source/Lost_Edge/Private/Widgets/WidgetsManager.h index f521bf1..48bb35c 100644 --- a/Source/Lost_Edge/Private/WidgetsManager.h +++ b/Source/Lost_Edge/Private/Widgets/WidgetsManager.h @@ -1,5 +1,3 @@ -#pragma once - // Oleg Petruny proprietary. #pragma once @@ -9,6 +7,8 @@ #include "WidgetsManager.generated.h" +enum class EActivatorType : uint8; + UCLASS(Blueprintable) class UWidgetsManager : public UObject { @@ -21,7 +21,8 @@ public: void ShowOverlayWidgets(); void UpdateOverlayWidgetsOwner(); - void ShowInteractionHints(class AInteractable* interactable); + void ShowInteractionHints(const class UInteractableModificator* modificator); + void HideInteractionHints(const EActivatorType type); protected: UPROPERTY(EditDefaultsOnly) @@ -31,4 +32,8 @@ protected: UPROPERTY(EditDefaultsOnly) TArray> overlayWidgets; // hidden in pause TArray> overlayWidgetsInstances; + + UPROPERTY(EditDefaultsOnly) + TSubclassOf interactableHintWidgetManagerClass; + class UInteractableHintWidgetManager* interactableHintWidgetManager; }; diff --git a/Source/Lost_EdgeShaders/Public/InteractableScreenCapturerBitMapCS.h b/Source/Lost_EdgeShaders/Public/InteractableScreenCapturerBitMapCS.h index fc976c8..d7bca86 100644 --- a/Source/Lost_EdgeShaders/Public/InteractableScreenCapturerBitMapCS.h +++ b/Source/Lost_EdgeShaders/Public/InteractableScreenCapturerBitMapCS.h @@ -16,8 +16,8 @@ public: BEGIN_SHADER_PARAMETER_STRUCT(FParameters, ) - SHADER_PARAMETER_SRV(Buffer, Input) - SHADER_PARAMETER_UAV(RWBuffer, Output) + SHADER_PARAMETER_SRV(Buffer, Input) + SHADER_PARAMETER_UAV(RWBuffer, Output) END_SHADER_PARAMETER_STRUCT()