// Copyright Epic Games, Inc. All Rights Reserved. #include "LyraVerbMessageHelpers.h" #include "GameFramework/PlayerState.h" #include "GameFramework/PlayerController.h" #include "GameFramework/Pawn.h" ////////////////////////////////////////////////////////////////////// // FLyraVerbMessage FString FLyraVerbMessage::ToString() const { FString HumanReadableMessage; FLyraVerbMessage::StaticStruct()->ExportText(/*out*/ HumanReadableMessage, this, /*Defaults=*/ nullptr, /*OwnerObject=*/ nullptr, PPF_None, /*ExportRootScope=*/ nullptr); return HumanReadableMessage; } ////////////////////////////////////////////////////////////////////// // APlayerState* ULyraVerbMessageHelpers::GetPlayerStateFromObject(UObject* Object) { if (APlayerController* PC = Cast(Object)) { return PC->PlayerState; } if (APlayerState* TargetPS = Cast(Object)) { return TargetPS; } if (APawn* TargetPawn = Cast(Object)) { if (APlayerState* TargetPS = TargetPawn->GetPlayerState()) { return TargetPS; } } return nullptr; } APlayerController* ULyraVerbMessageHelpers::GetPlayerControllerFromObject(UObject* Object) { if (APlayerController* PC = Cast(Object)) { return PC; } if (APlayerState* TargetPS = Cast(Object)) { return TargetPS->GetPlayerController(); } if (APawn* TargetPawn = Cast(Object)) { return Cast(TargetPawn->GetController()); } return nullptr; } FGameplayCueParameters ULyraVerbMessageHelpers::VerbMessageToCueParameters(const FLyraVerbMessage& Message) { FGameplayCueParameters Result; Result.OriginalTag = Message.Verb; Result.Instigator = Cast(Message.Instigator); Result.EffectCauser = Cast(Message.Target); Result.AggregatedSourceTags = Message.InstigatorTags; Result.AggregatedTargetTags = Message.TargetTags; //@TODO: = Message.ContextTags; Result.RawMagnitude = Message.Magnitude; return Result; } FLyraVerbMessage ULyraVerbMessageHelpers::CueParametersToVerbMessage(const FGameplayCueParameters& Params) { FLyraVerbMessage 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; }