Clean code

This commit is contained in:
Maxime Maurin 2023-10-13 00:16:16 +02:00
parent 0faebb4965
commit 12323d425b
12 changed files with 22 additions and 20 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -26,7 +26,7 @@ void UPwnTriggerRegister::UnregisterTrigger(UPwnTrigger* Trigger) {
RelevantTrigger = nullptr; RelevantTrigger = nullptr;
} }
} }
UE_DISABLE_OPTIMIZATION
void UPwnTriggerRegister::TickComponent(float DeltaTime, ELevelTick TickType, void UPwnTriggerRegister::TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) { FActorComponentTickFunction* ThisTickFunction) {
UPwnTrigger* BestTrigger = nullptr; UPwnTrigger* BestTrigger = nullptr;
@ -34,9 +34,9 @@ void UPwnTriggerRegister::TickComponent(float DeltaTime, ELevelTick TickType,
for (UPwnTrigger* PwnTrigger : Triggers) { for (UPwnTrigger* PwnTrigger : Triggers) {
FVector2D ActorForward = FVector2D(GetOwner()->GetActorForwardVector()); FVector2D ActorForward = FVector2D(GetOwner()->GetActorForwardVector());
FVector2D ActorToTrigger = FVector2D(PwnTrigger->GetVolumeCenter() - GetOwner()->GetActorLocation()).GetSafeNormal(); FVector2D ActorToTrigger = FVector2D(PwnTrigger->GetVolumeCenter() - GetOwner()->GetActorLocation()).GetSafeNormal();
const float Dot = FVector2D::DotProduct(ActorForward, ActorToTrigger);
// Check dot product against lowest dot product and check if the actor is facing the trigger
// Check dot product against lowest dot product and check if the actor is facing the trigger
const float Dot = FVector2D::DotProduct(ActorForward, ActorToTrigger);
if (Dot < LowestDot && (!PwnTrigger->MustFaceCenter || FMath::RadiansToDegrees(FMath::Acos(Dot)) < PwnTrigger->FaceAngle * 0.5f)) { if (Dot < LowestDot && (!PwnTrigger->MustFaceCenter || FMath::RadiansToDegrees(FMath::Acos(Dot)) < PwnTrigger->FaceAngle * 0.5f)) {
LowestDot = Dot; LowestDot = Dot;
BestTrigger = PwnTrigger; BestTrigger = PwnTrigger;
@ -54,4 +54,3 @@ void UPwnTriggerRegister::TickComponent(float DeltaTime, ELevelTick TickType,
} }
} }
} }
UE_ENABLE_OPTIMIZATION

View File

@ -4,7 +4,7 @@
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "PwnGameplayModeLibrary.generated.h" #include "PwnGameplayModeLibrary.generated.h"
UCLASS(DisplayName="Gameplay Mode Library") UCLASS()
class PAWN_API UPwnGameplayModeLibrary : public UBlueprintFunctionLibrary { class PAWN_API UPwnGameplayModeLibrary : public UBlueprintFunctionLibrary {
GENERATED_BODY() GENERATED_BODY()

View File

@ -11,7 +11,7 @@ enum EInteractionType {
Disable, Disable,
}; };
UINTERFACE(BlueprintType, Blueprintable, DisplayName="Interactable") UINTERFACE(BlueprintType, Blueprintable)
class PAWN_API UPwnInteractable : public UInterface { class PAWN_API UPwnInteractable : public UInterface {
GENERATED_BODY() GENERATED_BODY()
}; };

View File

@ -35,7 +35,7 @@ struct FInteractableActions {
UCLASS(ClassGroup="Interaction", UCLASS(ClassGroup="Interaction",
HideCategories=("Cooking", "Replication", "Collision"), HideCategories=("Cooking", "Replication", "Collision"),
meta=(BlueprintSpawnableComponent, DisplayName="Trigger")) meta=(BlueprintSpawnableComponent))
class PAWN_API UPwnTrigger : public UActorComponent, public IPwnInteractable { class PAWN_API UPwnTrigger : public UActorComponent, public IPwnInteractable {
GENERATED_BODY() GENERATED_BODY()

View File

@ -10,7 +10,7 @@ class UPwnTrigger;
UCLASS(ClassGroup="Interaction", UCLASS(ClassGroup="Interaction",
HideCategories=("Activation", "Cooking", "Replication", "Collision"), HideCategories=("Activation", "Cooking", "Replication", "Collision"),
meta=(BlueprintSpawnableComponent, DisplayName="Trigger Register")) meta=(BlueprintSpawnableComponent))
class PAWN_API UPwnTriggerRegister : public UActorComponent { class PAWN_API UPwnTriggerRegister : public UActorComponent {
GENERATED_BODY() GENERATED_BODY()