2024-09-24 18:58:13 -04:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2025-01-07 18:46:40 -05:00
|
|
|
#include "Kismet/KismetSystemLibrary.h"
|
|
|
|
|
|
2024-09-24 18:58:13 -04:00
|
|
|
#include "UtilityLibrary.generated.h"
|
|
|
|
|
|
2024-10-15 16:17:44 -04:00
|
|
|
class UEnhancedInputLocalPlayerSubsystem;
|
|
|
|
|
|
2024-09-24 18:58:13 -04:00
|
|
|
/**
|
|
|
|
|
*
|
2024-10-15 16:17:44 -04:00
|
|
|
* UlxUtilityLibrary is for functions that are aren't particularly luprex-specific,
|
|
|
|
|
* but rather, are just generally-useful functionality that could help in any
|
|
|
|
|
* Unreal program.
|
2024-09-24 18:58:13 -04:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
UCLASS()
|
|
|
|
|
class INTEGRATION_API UlxUtilityLibrary : public UObject
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Call a function by name, on any UObject. If the function doesn't exist, calls
|
|
|
|
|
// the fallback function instead. If that isn't found either, returns false.
|
|
|
|
|
//
|
|
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Utility")
|
2024-09-24 22:13:56 -04:00
|
|
|
static void CallFunctionByName(UObject *target, const FString &NamePart1, const FString &NamePart2, const FString &fallback, bool bFailIfNotFound = true);
|
2024-09-24 18:58:13 -04:00
|
|
|
|
|
|
|
|
// Get the axis-aligned bounding box of an actor.
|
|
|
|
|
//
|
|
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Utility")
|
|
|
|
|
static FBox GetActorBounds(const AActor *target, bool bOnlyCollidingComponents = false, bool bIncludeFromChildActors = false);
|
2024-10-15 16:17:44 -04:00
|
|
|
|
|
|
|
|
// Add movement input, using the yaw of the control rotation to find a rightward vector.
|
|
|
|
|
//
|
|
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Pawn|Input")
|
|
|
|
|
static void AddMovementInputRightward(APawn *target, double ScaleValue=1.0, bool Force=false);
|
|
|
|
|
|
|
|
|
|
// Add movement input, using the yaw of the control rotation to find a forward vector.
|
|
|
|
|
//
|
|
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Pawn|Input")
|
|
|
|
|
static void AddMovementInputForward(APawn *target, double ScaleValue=1.0, bool Force=false);
|
|
|
|
|
|
|
|
|
|
// Get the enhanced input local player subsystem from a controller. If the controller
|
|
|
|
|
// is not a player controller, or if it is a player controller but it doesn't have an
|
|
|
|
|
// enhanced input subsystem, return nullptr.
|
|
|
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Player Controller|Local Player Subsystems")
|
|
|
|
|
static UEnhancedInputLocalPlayerSubsystem *GetEnhancedInputLocalPlayerSubsystem(AController *Controller);
|
2025-01-07 18:46:40 -05:00
|
|
|
|
2025-01-14 18:37:31 -05:00
|
|
|
// Do a Line Trace from the camera through a specified pixel.
|
|
|
|
|
//
|
|
|
|
|
// This can be used when you have a crosshair on the screen and you want to
|
|
|
|
|
// determine the object that the crosshairs are pointing at. It can also
|
|
|
|
|
// be used to do a line trace through the mouse.
|
2025-01-07 18:46:40 -05:00
|
|
|
//
|
2025-01-14 18:37:31 -05:00
|
|
|
// Fractional pixels are allowed. Therefore, (0.0, 0.0) is the upper-left corner
|
|
|
|
|
// of the upper-left pixel, whereas (0.5, 0.5) is the center of the upper-left pixel.
|
2025-01-07 18:46:40 -05:00
|
|
|
//
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category="Collision", meta=(AutoCreateRefTerm="ActorsToIgnore", Keywords="raycast"))
|
2025-01-14 18:37:31 -05:00
|
|
|
static bool LineTraceThroughPixel(const APlayerController* PlayerController,
|
|
|
|
|
FVector2D PixelXY, double MaxDistanceFromCamera,
|
2025-01-07 18:46:40 -05:00
|
|
|
ETraceTypeQuery TraceChannel, bool bTraceComplex, EDrawDebugTrace::Type DrawDebugType, bool bIgnorePlayerPawn,
|
2025-01-14 18:37:31 -05:00
|
|
|
const TArray<AActor*>& ActorsToIgnore, FHitResult& HitResult);
|
2024-09-24 18:58:13 -04:00
|
|
|
};
|