add static get component methods for quickly accessing grab/touch components
This commit is contained in:
@@ -66,6 +66,18 @@ struct USGGrabComponent::FImpl
|
|||||||
************************/
|
************************/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
USGGrabComponent* USGGrabComponent::GetGrabComponent(const AActor* Actor)
|
||||||
|
{
|
||||||
|
if (ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
USGGrabComponent* GrabComponent = Cast<USGGrabComponent>(
|
||||||
|
Actor->GetComponentByClass(USGGrabComponent::StaticClass()));
|
||||||
|
return GrabComponent;
|
||||||
|
}
|
||||||
|
|
||||||
bool USGGrabComponent::IsGrabbable(const AActor* Actor)
|
bool USGGrabComponent::IsGrabbable(const AActor* Actor)
|
||||||
{
|
{
|
||||||
if (ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
|
if (ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
|
||||||
|
|||||||
@@ -66,6 +66,18 @@ struct USGTouchComponent::FImpl
|
|||||||
************************/
|
************************/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
USGTouchComponent* USGTouchComponent::GetTouchComponent(const AActor* Actor)
|
||||||
|
{
|
||||||
|
if (ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
USGTouchComponent* TouchComponent = Cast<USGTouchComponent>(
|
||||||
|
Actor->GetComponentByClass(USGTouchComponent::StaticClass()));
|
||||||
|
return TouchComponent;
|
||||||
|
}
|
||||||
|
|
||||||
bool USGTouchComponent::IsTouchable(const AActor* Actor)
|
bool USGTouchComponent::IsTouchable(const AActor* Actor)
|
||||||
{
|
{
|
||||||
if (ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
|
if (ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class SENSEGLOVE_API USGGrabComponent : public USceneComponent
|
|||||||
GENERATED_UCLASS_BODY()
|
GENERATED_UCLASS_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static USGGrabComponent* GetGrabComponent(const AActor* Actor);
|
||||||
|
|
||||||
static bool IsGrabbable(const AActor* Actor);
|
static bool IsGrabbable(const AActor* Actor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ class SENSEGLOVE_API USGTouchComponent : public USceneComponent
|
|||||||
GENERATED_UCLASS_BODY()
|
GENERATED_UCLASS_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static USGTouchComponent* GetTouchComponent(const AActor* Actor);
|
||||||
|
|
||||||
static bool IsTouchable(const AActor* Actor);
|
static bool IsTouchable(const AActor* Actor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -39,6 +39,11 @@
|
|||||||
|
|
||||||
#include "SenseGlove/Components/SGGrabComponent.h"
|
#include "SenseGlove/Components/SGGrabComponent.h"
|
||||||
|
|
||||||
|
USGGrabComponent* UGrabComponentKismetLibrary::GetGrabComponent(const AActor* Actor)
|
||||||
|
{
|
||||||
|
return USGGrabComponent::GetGrabComponent(Actor);
|
||||||
|
}
|
||||||
|
|
||||||
bool UGrabComponentKismetLibrary::IsGrabbable(const AActor* Actor)
|
bool UGrabComponentKismetLibrary::IsGrabbable(const AActor* Actor)
|
||||||
{
|
{
|
||||||
return USGGrabComponent::IsGrabbable(Actor);
|
return USGGrabComponent::IsGrabbable(Actor);
|
||||||
|
|||||||
@@ -40,6 +40,11 @@
|
|||||||
|
|
||||||
#include "SenseGlove/Components/SGTouchComponent.h"
|
#include "SenseGlove/Components/SGTouchComponent.h"
|
||||||
|
|
||||||
|
USGTouchComponent* UTouchComponentKismetLibrary::GetTouchComponent(const AActor* Actor)
|
||||||
|
{
|
||||||
|
return USGTouchComponent::GetTouchComponent(Actor);
|
||||||
|
}
|
||||||
|
|
||||||
bool UTouchComponentKismetLibrary::IsTouchable(const AActor* Actor)
|
bool UTouchComponentKismetLibrary::IsTouchable(const AActor* Actor)
|
||||||
{
|
{
|
||||||
return USGTouchComponent::IsTouchable(Actor);
|
return USGTouchComponent::IsTouchable(Actor);
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ class SENSEGLOVEKISMET_API UGrabComponentKismetLibrary final : public USGBluepri
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Grab Component")
|
||||||
|
static USGGrabComponent* GetGrabComponent(const AActor* Actor);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Grab Component")
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Grab Component")
|
||||||
static bool IsGrabbable(const AActor* Actor);
|
static bool IsGrabbable(const AActor* Actor);
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ class SENSEGLOVEKISMET_API UTouchComponentKismetLibrary final : public USGBluepr
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Touch Component")
|
||||||
|
static USGTouchComponent* GetTouchComponent(const AActor* Actor);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Touch Component")
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Touch Component")
|
||||||
static bool IsTouchable(const AActor* Actor);
|
static bool IsTouchable(const AActor* Actor);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user