diff --git a/Content/BP_BugLocationActor.uasset b/Content/BP_BugLocationActor.uasset deleted file mode 100644 index c479cc9..0000000 Binary files a/Content/BP_BugLocationActor.uasset and /dev/null differ diff --git a/Content/BP_BugMarkerActor.uasset b/Content/BP_BugMarkerActor.uasset new file mode 100644 index 0000000..dc744e5 Binary files /dev/null and b/Content/BP_BugMarkerActor.uasset differ diff --git a/Content/BP_BugPlacerPawn.uasset b/Content/BP_BugPlacerPawn.uasset index 12c66fa..2018227 100644 Binary files a/Content/BP_BugPlacerPawn.uasset and b/Content/BP_BugPlacerPawn.uasset differ diff --git a/Content/IA_BugPlacerArbitraryPlacement.uasset b/Content/IA_BugPlacerArbitraryPlacement.uasset new file mode 100644 index 0000000..c55f2fd Binary files /dev/null and b/Content/IA_BugPlacerArbitraryPlacement.uasset differ diff --git a/Content/MC_BugPlacement.uasset b/Content/MC_BugPlacement.uasset index 49de20f..bba1fb4 100644 Binary files a/Content/MC_BugPlacement.uasset and b/Content/MC_BugPlacement.uasset differ diff --git a/Content/MPC_Laser.uasset b/Content/MPC_Laser.uasset new file mode 100644 index 0000000..9daceb0 Binary files /dev/null and b/Content/MPC_Laser.uasset differ diff --git a/Content/M_LaserGlow.uasset b/Content/M_LaserGlow.uasset new file mode 100644 index 0000000..94e3ec1 Binary files /dev/null and b/Content/M_LaserGlow.uasset differ diff --git a/Content/M_LaserShaft.uasset b/Content/M_LaserShaft.uasset new file mode 100644 index 0000000..fbf2e4d Binary files /dev/null and b/Content/M_LaserShaft.uasset differ diff --git a/Content/SM_LaserShaft.uasset b/Content/SM_LaserShaft.uasset new file mode 100644 index 0000000..bef6941 Binary files /dev/null and b/Content/SM_LaserShaft.uasset differ diff --git a/Content/T_LaserGlow.uasset b/Content/T_LaserGlow.uasset new file mode 100644 index 0000000..c339fae Binary files /dev/null and b/Content/T_LaserGlow.uasset differ diff --git a/Content/UI/CUI_BugCommentTextEntry.uasset b/Content/UI/CUI_BugCommentTextEntry.uasset new file mode 100644 index 0000000..b0ada76 Binary files /dev/null and b/Content/UI/CUI_BugCommentTextEntry.uasset differ diff --git a/Content/UI/CUI_BugFormButton.uasset b/Content/UI/CUI_BugFormButton.uasset new file mode 100644 index 0000000..f19bd3c Binary files /dev/null and b/Content/UI/CUI_BugFormButton.uasset differ diff --git a/Content/UI/CUI_BugFormOptionButton.uasset b/Content/UI/CUI_BugFormOptionButton.uasset new file mode 100644 index 0000000..4f2489b Binary files /dev/null and b/Content/UI/CUI_BugFormOptionButton.uasset differ diff --git a/Content/UI/CUI_BugFormTextEntryButton.uasset b/Content/UI/CUI_BugFormTextEntryButton.uasset new file mode 100644 index 0000000..09aab72 Binary files /dev/null and b/Content/UI/CUI_BugFormTextEntryButton.uasset differ diff --git a/Content/UI/CUI_BugSubmissionForm.uasset b/Content/UI/CUI_BugSubmissionForm.uasset new file mode 100644 index 0000000..72df207 Binary files /dev/null and b/Content/UI/CUI_BugSubmissionForm.uasset differ diff --git a/Content/UI/CUI_BugSummaryTextEntry.uasset b/Content/UI/CUI_BugSummaryTextEntry.uasset new file mode 100644 index 0000000..12c834f Binary files /dev/null and b/Content/UI/CUI_BugSummaryTextEntry.uasset differ diff --git a/Content/UI/CUI_Style_BugFormBorder.uasset b/Content/UI/CUI_Style_BugFormBorder.uasset new file mode 100644 index 0000000..db3e2b6 Binary files /dev/null and b/Content/UI/CUI_Style_BugFormBorder.uasset differ diff --git a/Content/UI/CUI_Style_BugFormButton.uasset b/Content/UI/CUI_Style_BugFormButton.uasset new file mode 100644 index 0000000..3104591 Binary files /dev/null and b/Content/UI/CUI_Style_BugFormButton.uasset differ diff --git a/Content/UI/CUI_Style_BugFormButtonText.uasset b/Content/UI/CUI_Style_BugFormButtonText.uasset new file mode 100644 index 0000000..f8688bf Binary files /dev/null and b/Content/UI/CUI_Style_BugFormButtonText.uasset differ diff --git a/Content/UI/CUI_Style_BugFormText.uasset b/Content/UI/CUI_Style_BugFormText.uasset new file mode 100644 index 0000000..d614a75 Binary files /dev/null and b/Content/UI/CUI_Style_BugFormText.uasset differ diff --git a/Source/Unrealzilla/Private/BugMarkerActor.cpp b/Source/Unrealzilla/Private/BugMarkerActor.cpp new file mode 100644 index 0000000..ce84ad2 --- /dev/null +++ b/Source/Unrealzilla/Private/BugMarkerActor.cpp @@ -0,0 +1,6 @@ +// ©2022 Batty Bovine Productions, LLC. All Rights Reserved. + +#include "BugMarkerActor.h" + + + diff --git a/Source/Unrealzilla/Private/BugPlacerPawn.cpp b/Source/Unrealzilla/Private/BugPlacerPawn.cpp index 4bf7038..f468ea3 100644 --- a/Source/Unrealzilla/Private/BugPlacerPawn.cpp +++ b/Source/Unrealzilla/Private/BugPlacerPawn.cpp @@ -2,6 +2,10 @@ #include "BugPlacerPawn.h" +#include "BugMarkerActor.h" +#include "UnrealzillaGlobalSettings.h" + +#include "Components/MaterialBillboardComponent.h" #include "Components/SphereComponent.h" #include "GameFramework/Character.h" #include "GameFramework/FloatingPawnMovement.h" @@ -12,14 +16,26 @@ ABugPlacerPawn::ABugPlacerPawn() { this->PrimaryActorTick.bCanEverTick = true; + this->bArbitraryPlacement = false; + this->bCurrentTraceHit = false; + this->SphereComponent = CreateDefaultSubobject("SphereCollision"); this->SphereComponent->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName); this->SphereComponent->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_No; this->SphereComponent->SetShouldUpdatePhysicsVolume(true); this->SphereComponent->SetCanEverAffectNavigation(false); - this->SphereComponent->bDynamicObstacle = true; + this->SphereComponent->bDynamicObstacle = false; this->RootComponent = this->SphereComponent; + this->PlacementMarkerRoot = CreateDefaultSubobject("PlacementMarkerRoot"); + this->PlacementMarkerRoot->AttachToComponent(this->RootComponent, FAttachmentTransformRules::KeepRelativeTransform); + + this->LaserGlow = CreateDefaultSubobject("LaserGlow"); + this->LaserGlow->AttachToComponent(this->PlacementMarkerRoot, FAttachmentTransformRules::KeepRelativeTransform); + + this->TraceOriginComponent = CreateDefaultSubobject("TraceOrigin"); + this->TraceOriginComponent->AttachToComponent(this->RootComponent, FAttachmentTransformRules::KeepRelativeTransform); + this->PawnMovement = CreateDefaultSubobject("MovementComponent"); if (this->PawnMovement) { @@ -34,6 +50,17 @@ void ABugPlacerPawn::BeginPlay() this->OriginalPlayer = UGameplayStatics::GetPlayerCharacter(this, 0); + // Create the bug marker we will be placing. + if (this->BugPlacerBlueprintClass.IsValid()) + { + FActorSpawnParameters SpawnParams; + SpawnParams.Name = TEXT("BugMarker"); + SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + SpawnParams.bHideFromSceneOutliner = true; + this->BugMarker = this->GetWorld()->SpawnActor(this->BugPlacerBlueprintClass.Get(), this->SphereComponent->GetComponentTransform(), SpawnParams); + this->BugMarker->AttachToComponent(this->PlacementMarkerRoot, FAttachmentTransformRules::SnapToTargetNotIncludingScale); + } + this->Activate(); Super::BeginPlay(); @@ -47,6 +74,90 @@ void ABugPlacerPawn::EndPlay(const EEndPlayReason::Type EndPlayReason) Super::EndPlay(EndPlayReason); } +void ABugPlacerPawn::Tick(float DeltaSeconds) +{ + const UWorld *World = this->GetWorld(); + + if (this->bArbitraryPlacement) + { + this->TraceOriginComponent->SetVisibility(false, true); + this->PlacementMarkerRoot->SetVisibility(true, true); + this->LaserGlow->SetVisibility(false, true); + + // If the debugger requests arbitrary placement, put the marker a set distance away from the camera. + this->PlacementMarkerRoot->SetRelativeLocationAndRotation(FVector(GetDefault()->ArbitraryBugPlacementDistance, 0.0f, 0.0f), FRotator::ZeroRotator); + } + else + { + // Under normal circumstances, we place the marker at the point where a laser hits a surface. + this->TraceOriginComponent->SetVisibility(true, true); + this->LaserGlow->SetVisibility(true, true); + + FCollisionQueryParams Params; + Params.bTraceComplex = false; + Params.AddIgnoredActor(this); + + FHitResult TraceHit; + const FVector TraceStart = this->TraceOriginComponent->GetComponentLocation(); + const FVector TraceEnd = TraceStart + (this->TraceOriginComponent->GetForwardVector() * GetDefault()->BugPlacementTraceDistance); + this->bCurrentTraceHit = World->LineTraceSingleByChannel(TraceHit, TraceStart, TraceEnd, ECollisionChannel::ECC_Visibility, Params); + + // Move bug marker to the current pointer position, or behind + // the camera if the pointer is not currently hitting a surface. + if (this->bCurrentTraceHit) + { + this->PlacementMarkerRoot->SetWorldLocationAndRotation(TraceHit.ImpactPoint, FRotationMatrix::MakeFromZ(TraceHit.ImpactNormal).ToQuat()); + this->PlacementMarkerRoot->SetVisibility(true, true); + + this->TraceOriginComponent->SetRelativeScale3D(FVector(1.0f, 1.0f, (TraceHit.ImpactPoint - TraceStart).Length())); + } + else + { + this->PlacementMarkerRoot->SetRelativeLocationAndRotation(FVector::ZeroVector, FRotator::ZeroRotator); + this->PlacementMarkerRoot->SetVisibility(false, true); + + this->TraceOriginComponent->SetRelativeScale3D(FVector(1.0f, 1.0f, (TraceEnd - TraceStart).Length())); + } + + //#if ENABLE_DRAW_DEBUG + // if (bTraceHit && TraceHit.bBlockingHit) + // { + // // Line trace and impact point + // DrawDebugLine(World, TraceStart, TraceHit.ImpactPoint, FColor::Red, false); + // DrawDebugLine(World, TraceHit.ImpactPoint, TraceEnd, FColor::Green, false); + // DrawDebugPoint(World, TraceHit.ImpactPoint, 10.0f, FColor::Red, false); + // + // // Impact normal + // DrawDebugLine(World, TraceHit.ImpactPoint, TraceHit.ImpactPoint + (TraceHit.ImpactNormal * 50.0f), FColor(0, 100, 255, 255), false); + // } + // else + // { + // // Line trace, no impact + // DrawDebugLine(World, TraceStart, TraceEnd, FColor::Red, false); + // } + //#endif + } +} + + +void ABugPlacerPawn::SetArbitraryPlacement(bool bSet) +{ + this->bArbitraryPlacement = bSet; +} + +void ABugPlacerPawn::PlaceBugMarker() +{ + // If there is a surface onto which to place a bug actor, then do so here. + if (this->bArbitraryPlacement || this->bCurrentTraceHit) + { + FActorSpawnParameters SpawnParams; + SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + SpawnParams.bHideFromSceneOutliner = true; + + this->GetWorld()->SpawnActor(this->BugPlacerBlueprintClass.Get(), this->PlacementMarkerRoot->GetComponentTransform(), SpawnParams); + } +} + void ABugPlacerPawn::Activate() { diff --git a/Source/Unrealzilla/Private/UnrealzillaGlobalSettings.cpp b/Source/Unrealzilla/Private/UnrealzillaGlobalSettings.cpp new file mode 100644 index 0000000..c831d0c --- /dev/null +++ b/Source/Unrealzilla/Private/UnrealzillaGlobalSettings.cpp @@ -0,0 +1,26 @@ +// ©2022 Batty Bovine Productions, LLC. All Rights Reserved. + +#include "UnrealzillaGlobalSettings.h" + + +void UUnrealzillaGlobalSettings::PostInitProperties() +{ + Super::PostInitProperties(); +} + +FName UUnrealzillaGlobalSettings::GetCategoryName() const +{ + return FName(TEXT("Plugins")); +} + +#if WITH_EDITOR +void UUnrealzillaGlobalSettings::PostEditChangeProperty(FPropertyChangedEvent &PropertyChangedEvent) +{ + Super::PostEditChangeProperty(PropertyChangedEvent); + + if (PropertyChangedEvent.Property) + { + this->ExportValuesToConsoleVariables(PropertyChangedEvent.Property); + } +} +#endif diff --git a/Source/Unrealzilla/Public/BugMarkerActor.h b/Source/Unrealzilla/Public/BugMarkerActor.h new file mode 100644 index 0000000..ea81e29 --- /dev/null +++ b/Source/Unrealzilla/Public/BugMarkerActor.h @@ -0,0 +1,19 @@ +// ©2022 Batty Bovine Productions, LLC. All Rights Reserved. + +#pragma once + +#include "CoreMinimal.h" + +#include "BugMarkerActor.generated.h" + + +UCLASS() +class UNREALZILLA_API ABugMarkerActor : public AActor +{ + GENERATED_BODY() + +public: + DECLARE_DELEGATE(FMarkerResponse) + FMarkerResponse OnFormSubmit; + FMarkerResponse OnFormCancelled; +}; diff --git a/Source/Unrealzilla/Public/BugPlacerPawn.h b/Source/Unrealzilla/Public/BugPlacerPawn.h index 4223ed8..31c0510 100644 --- a/Source/Unrealzilla/Public/BugPlacerPawn.h +++ b/Source/Unrealzilla/Public/BugPlacerPawn.h @@ -19,6 +19,8 @@ public: virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; + virtual void Tick(float DeltaSeconds) override; + UFUNCTION(BlueprintCallable) void Activate(); @@ -26,15 +28,46 @@ public: void Deactivate(); protected: + UFUNCTION(BlueprintCallable) + void SetArbitraryPlacement(bool bSet); + + UFUNCTION(BlueprintCallable) + void PlaceBugMarker(); + + + // Collision sphere, and root component + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + TObjectPtr SphereComponent; + + // Follows the collision point of a line trace, and indicates where the bug marker will be placed. + UPROPERTY(BlueprintReadOnly, EditAnywhere) + TObjectPtr PlacementMarkerRoot; + + // The glowing end point of the laser, to indicate a surface where a marker can be placed. + UPROPERTY(BlueprintReadOnly, EditDefaultsOnly) + TObjectPtr LaserGlow; + + // The origin of our line trace; line extends from this origin position along the component's + // forward vector a set distance to check for surfaces where a bug marker can be placed. + UPROPERTY(BlueprintReadOnly, EditAnywhere) + TObjectPtr TraceOriginComponent; + + // Basic movement component to allow the bug placer to fly through a level. + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + TObjectPtr PawnMovement; + + + UPROPERTY(BlueprintReadOnly, EditDefaultsOnly) + TSoftClassPtr BugPlacerBlueprintClass; + UPROPERTY(BlueprintReadWrite) float SavedMaxSpeed = 0.0f; private: - UPROPERTY(BlueprintReadOnly, VisibleAnywhere, meta=(AllowPrivateAccess="true")) - TObjectPtr SphereComponent; + uint8 bArbitraryPlacement : 1; - UPROPERTY(BlueprintReadOnly, VisibleAnywhere, meta=(AllowPrivateAccess="true")) - TObjectPtr PawnMovement; + uint8 bCurrentTraceHit : 1; TObjectPtr OriginalPlayer; + TObjectPtr BugMarker; }; diff --git a/Source/Unrealzilla/Public/UnrealzillaGlobalSettings.h b/Source/Unrealzilla/Public/UnrealzillaGlobalSettings.h new file mode 100644 index 0000000..8f409ac --- /dev/null +++ b/Source/Unrealzilla/Public/UnrealzillaGlobalSettings.h @@ -0,0 +1,31 @@ +// ©2022 Batty Bovine Productions, LLC. All Rights Reserved. + +#pragma once + +#include "Engine/DeveloperSettingsBackedByCVars.h" + +#include "UnrealzillaGlobalSettings.generated.h" + + +/** +* Global settings for Unrealzilla classes +*/ +UCLASS(Config=Game, defaultconfig, meta = (DisplayName="Unrealzilla")) +class UNREALZILLA_API UUnrealzillaGlobalSettings : public UDeveloperSettingsBackedByCVars +{ + GENERATED_BODY() + +public: + UPROPERTY(Config, BlueprintReadOnly, EditDefaultsOnly, Category="Unrealzilla") + float BugPlacementTraceDistance = 1000.0f; + UPROPERTY(Config, BlueprintReadOnly, EditDefaultsOnly, Category="Unrealzilla") + float ArbitraryBugPlacementDistance = 250.0f; + +public: + virtual void PostInitProperties() override; + virtual FName GetCategoryName() const override; + +#if WITH_EDITOR + virtual void PostEditChangeProperty(struct FPropertyChangedEvent &PropertyChangedEvent) override; +#endif +}; diff --git a/Source/Unrealzilla/Unrealzilla.Build.cs b/Source/Unrealzilla/Unrealzilla.Build.cs index 1f1123b..787ce70 100644 --- a/Source/Unrealzilla/Unrealzilla.Build.cs +++ b/Source/Unrealzilla/Unrealzilla.Build.cs @@ -31,7 +31,8 @@ namespace UnrealBuildTool.Rules "CoreUObject", "Engine", "InputCore", - } + "DeveloperSettings" + } ); PrivateDependencyModuleNames.AddRange(