Files
UnrealEngine/Engine/Source/Editor/UnrealEd/Private/Kismet2/WatchedPin.cpp
2025-05-18 13:04:45 +08:00

66 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Kismet2/WatchedPin.h"
#include "EdGraph/EdGraphNode.h"
#include "Misc/AssertionMacros.h"
#include "Templates/UnrealTemplate.h"
FBlueprintWatchedPin::FBlueprintWatchedPin()
{
}
FBlueprintWatchedPin::FBlueprintWatchedPin(const UEdGraphPin* Pin)
{
SetFromPin(Pin);
}
FBlueprintWatchedPin::FBlueprintWatchedPin(const UEdGraphPin* Pin, TArray<FName>&& InPathToProperty)
: PathToProperty(MoveTemp(InPathToProperty))
{
SetFromPin(Pin);
}
UEdGraphPin* FBlueprintWatchedPin::Get() const
{
UEdGraphPin* FoundPin = CachedPinRef.Get();
if (!FoundPin && PinId.IsValid() && OwningNode.IsValid())
{
const UEdGraphNode* Node = OwningNode.Get();
check(Node);
UEdGraphPin* const* FoundPinPtr = Node->Pins.FindByPredicate([PinId = this->PinId](const UEdGraphPin* Pin)
{
return PinId == Pin->PinId;
});
if (FoundPinPtr)
{
FoundPin = *FoundPinPtr;
CachedPinRef = FoundPin;
}
}
return FoundPin;
}
void FBlueprintWatchedPin::SetFromPin(const UEdGraphPin* Pin)
{
if (Pin)
{
PinId = Pin->PinId;
OwningNode = Pin->GetOwningNodeUnchecked();
}
CachedPinRef = Pin;
}
void FBlueprintWatchedPin::SetFromWatchedPin(FBlueprintWatchedPin&& Other)
{
PinId = Other.PinId;
OwningNode = Other.OwningNode;
CachedPinRef = Other.CachedPinRef;
PathToProperty = MoveTemp(Other.PathToProperty);
}