From ad1a274996f10894da9bd1c52ece36254f64a66f Mon Sep 17 00:00:00 2001 From: BenPyton Date: Sun, 7 Apr 2024 21:58:54 +0200 Subject: [PATCH] Added plugin settings to customize the door debug arrow --- .../Private/ProceduralDungeonSettings.cpp | 3 +++ .../Private/ProceduralDungeonTypes.cpp | 3 ++- .../Private/ProceduralDungeonUtils.cpp | 18 ++++++++++++++++++ .../Public/ProceduralDungeonSettings.h | 14 ++++++++++++++ .../Public/ProceduralDungeonUtils.h | 3 +++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Source/ProceduralDungeon/Private/ProceduralDungeonSettings.cpp b/Source/ProceduralDungeon/Private/ProceduralDungeonSettings.cpp index 129da21..dbd610b 100644 --- a/Source/ProceduralDungeon/Private/ProceduralDungeonSettings.cpp +++ b/Source/ProceduralDungeon/Private/ProceduralDungeonSettings.cpp @@ -43,6 +43,9 @@ UProceduralDungeonSettings::UProceduralDungeonSettings(const FObjectInitializer& // Debug settings DrawDebug = true; ShowRoomOrigin = false; + bFlipDoorArrowSide = false; + DoorArrowLength = 300.0f; + DoorArrowHeadSize = 300.0f; OnScreenPrintDebug = false; PrintDebugDuration = 60.0f; diff --git a/Source/ProceduralDungeon/Private/ProceduralDungeonTypes.cpp b/Source/ProceduralDungeon/Private/ProceduralDungeonTypes.cpp index e511ad2..9ebc507 100644 --- a/Source/ProceduralDungeon/Private/ProceduralDungeonTypes.cpp +++ b/Source/ProceduralDungeon/Private/ProceduralDungeonTypes.cpp @@ -225,7 +225,8 @@ void FDoorDef::DrawDebug(const UWorld* World, const FColor& Color, const FVector if (isConnected) { // Arrow (there is a room on the other side OR in the editor preview) - DrawDebugDirectionalArrow(World, DoorPosition, DoorPosition + DoorRotation * FVector(300, 0, 0), 300, Color); + FVector ArrowVector = (Dungeon::FlipDoorArrow() ? -1.0f : 1.0f) * FVector(Dungeon::DoorArrowLength(), 0.0f, 0.0f); + DrawDebugDirectionalArrow(World, DoorPosition, DoorPosition + DoorRotation * ArrowVector, Dungeon::DoorArrowHeadSize(), Color); } else { diff --git a/Source/ProceduralDungeon/Private/ProceduralDungeonUtils.cpp b/Source/ProceduralDungeon/Private/ProceduralDungeonUtils.cpp index a68aac0..207b752 100644 --- a/Source/ProceduralDungeon/Private/ProceduralDungeonUtils.cpp +++ b/Source/ProceduralDungeon/Private/ProceduralDungeonUtils.cpp @@ -127,6 +127,24 @@ bool Dungeon::ShowRoomOrigin() return Settings->ShowRoomOrigin; } +bool Dungeon::FlipDoorArrow() +{ + const UProceduralDungeonSettings* Settings = GetDefault(); + return Settings->bFlipDoorArrowSide; +} + +float Dungeon::DoorArrowLength() +{ + const UProceduralDungeonSettings* Settings = GetDefault(); + return Settings->DoorArrowLength; +} + +float Dungeon::DoorArrowHeadSize() +{ + const UProceduralDungeonSettings* Settings = GetDefault(); + return Settings->DoorArrowHeadSize; +} + bool Dungeon::CanLoop() { const UProceduralDungeonSettings* Settings = GetDefault(); diff --git a/Source/ProceduralDungeon/Public/ProceduralDungeonSettings.h b/Source/ProceduralDungeon/Public/ProceduralDungeonSettings.h index d0341e2..d9b40d3 100644 --- a/Source/ProceduralDungeon/Public/ProceduralDungeonSettings.h +++ b/Source/ProceduralDungeon/Public/ProceduralDungeonSettings.h @@ -90,6 +90,20 @@ class PROCEDURALDUNGEON_API UProceduralDungeonSettings : public UObject UPROPERTY(EditAnywhere, config, Category = "Debug", meta = (EditCondition = "DrawDebug")) bool ShowRoomOrigin; + // Flip side the arrow that shows door facing direction. + // True means that the arrow gets inside the room (opposite of door actor's forward). + // False means that the arrow goes outside the room (same as door actor's forward). + UPROPERTY(EditAnywhere, config, Category = "Debug", meta = (EditCondition = "DrawDebug")) + bool bFlipDoorArrowSide; + + // Length of the door's debug arrow. + UPROPERTY(EditAnywhere, config, Category = "Debug", meta = (EditCondition = "DrawDebug")) + float DoorArrowLength; + + // Size of the door's debug arrow head. + UPROPERTY(EditAnywhere, config, Category = "Debug", meta = (EditCondition = "DrawDebug")) + float DoorArrowHeadSize; + // Show some logs on the screen UPROPERTY(EditAnywhere, config, Category = "Debug") bool OnScreenPrintDebug; diff --git a/Source/ProceduralDungeon/Public/ProceduralDungeonUtils.h b/Source/ProceduralDungeon/Public/ProceduralDungeonUtils.h index cfd81d2..5d73f6c 100644 --- a/Source/ProceduralDungeon/Public/ProceduralDungeonUtils.h +++ b/Source/ProceduralDungeon/Public/ProceduralDungeonUtils.h @@ -69,6 +69,9 @@ namespace Dungeon bool PROCEDURALDUNGEON_API OccludeDynamicActors(); bool PROCEDURALDUNGEON_API DrawDebug(); bool PROCEDURALDUNGEON_API ShowRoomOrigin(); + bool PROCEDURALDUNGEON_API FlipDoorArrow(); + float PROCEDURALDUNGEON_API DoorArrowLength(); + float PROCEDURALDUNGEON_API DoorArrowHeadSize(); bool PROCEDURALDUNGEON_API CanLoop(); ECollisionChannel PROCEDURALDUNGEON_API RoomObjectType();