Added VerMessageHelper
This commit is contained in:
parent
fe8ee2e867
commit
bac7ff7498
80
Source/ols/Private/Messages/OLSVerbMessageHelpers.cpp
Normal file
80
Source/ols/Private/Messages/OLSVerbMessageHelpers.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Messages/OLSVerbMessageHelpers.h"
|
||||||
|
|
||||||
|
#include "GameplayEffectTypes.h"
|
||||||
|
#include "GameFramework/PlayerState.h"
|
||||||
|
#include "Messages/OLSVerbMessage.h"
|
||||||
|
|
||||||
|
APlayerState* UOLSVerbMessageHelpers::GetPlayerStateFromObject(UObject* object)
|
||||||
|
{
|
||||||
|
if (APlayerController* playerController = Cast<APlayerController>(object))
|
||||||
|
{
|
||||||
|
return playerController->PlayerState;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APlayerState* targetPlayerState = Cast<APlayerState>(object))
|
||||||
|
{
|
||||||
|
return targetPlayerState;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APawn* targetPawn = Cast<APawn>(object))
|
||||||
|
{
|
||||||
|
if (APlayerState* targetPlayerState = targetPawn->GetPlayerState())
|
||||||
|
{
|
||||||
|
return targetPlayerState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
APlayerController* UOLSVerbMessageHelpers::GetPlayerControllerFromObject(UObject* object)
|
||||||
|
{
|
||||||
|
if (APlayerController* playerController = Cast<APlayerController>(object))
|
||||||
|
{
|
||||||
|
return playerController;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APlayerState* targetPlayerState = Cast<APlayerState>(object))
|
||||||
|
{
|
||||||
|
return targetPlayerState->GetPlayerController();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APawn* targetPawn = Cast<APawn>(object))
|
||||||
|
{
|
||||||
|
return Cast<APlayerController>(targetPawn->GetController());
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
FGameplayCueParameters UOLSVerbMessageHelpers::VerbMessageToCueParameters(const FOLSVerbMessage& message)
|
||||||
|
{
|
||||||
|
FGameplayCueParameters Result;
|
||||||
|
|
||||||
|
Result.OriginalTag = message.Verb;
|
||||||
|
Result.Instigator = Cast<AActor>(message.Instigator);
|
||||||
|
Result.EffectCauser = Cast<AActor>(message.Target);
|
||||||
|
Result.AggregatedSourceTags = message.InstigatorTags;
|
||||||
|
Result.AggregatedTargetTags = message.TargetTags;
|
||||||
|
//@TODO: = Message.ContextTags;
|
||||||
|
Result.RawMagnitude = message.Magnitude;
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOLSVerbMessage UOLSVerbMessageHelpers::CueParametersToVerbMessage(const FGameplayCueParameters& params)
|
||||||
|
{
|
||||||
|
FOLSVerbMessage result;
|
||||||
|
|
||||||
|
result.Verb = params.OriginalTag;
|
||||||
|
result.Instigator = params.Instigator.Get();
|
||||||
|
result.Target = params.EffectCauser.Get();
|
||||||
|
result.InstigatorTags = params.AggregatedSourceTags;
|
||||||
|
result.TargetTags = params.AggregatedTargetTags;
|
||||||
|
//@TODO: Result.ContextTags = ???;
|
||||||
|
result.Magnitude = params.RawMagnitude;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
30
Source/ols/Public/Messages/OLSVerbMessageHelpers.h
Normal file
30
Source/ols/Public/Messages/OLSVerbMessageHelpers.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
|
#include "OLSVerbMessageHelpers.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class OLS_API UOLSVerbMessageHelpers : public UBlueprintFunctionLibrary
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Lyra")
|
||||||
|
static class APlayerState* GetPlayerStateFromObject(UObject* object);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Lyra")
|
||||||
|
static class APlayerController* GetPlayerControllerFromObject(UObject* object);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Lyra")
|
||||||
|
static struct FGameplayCueParameters VerbMessageToCueParameters(const struct FOLSVerbMessage& message);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Lyra")
|
||||||
|
static struct FOLSVerbMessage CueParametersToVerbMessage(const FGameplayCueParameters& params);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user