Weird flow in blueprint into c++?

Hi, how does this flow works? It’s like three nested if’s and suddenly getting back to the first one? How do you achieve something like this in c++? (Green pencil - from branch to branch)

Extract the segment out into a function and just call the function when you get to the loop.

I tried to do it for a while but im stuck. There is no really a loop there:


There is a gate as open enter exit and custom events. How would you aproach it? That’s the whole blue print:

I have implemented custom gate in C++ like this:

USTRUCT(BlueprintType)
struct FGate
{
	GENERATED_USTRUCT_BODY()

public:
	FORCEINLINE FGate();
	explicit FORCEINLINE FGate(bool bStartClosed);
	FORCEINLINE void Open() { bGateOpen = true; }
	FORCEINLINE void Close() { bGateOpen = false; }
	FORCEINLINE void Toggle() { bGateOpen = !bGateOpen; }
	FORCEINLINE bool IsOpen() const { return bGateOpen; }

private:
	UPROPERTY(VisibleAnywhere)
	bool bGateOpen;
};

FORCEINLINE FGate::FGate() : bGateOpen(false){}
FORCEINLINE FGate::FGate(const bool bStartClosed) : bGateOpen(!bStartClosed){}

This blueprint is bit overwhelming me ;D

As I think i should put a while loop comparing the times at the end, so i will try to do that and i will post a result :wink:

Is that correct?

void AGridPathFinding::FindPathWithDelay()
{
	Gate.Open();
	LoopStartTime = UKismetMathLibrary::Now();

	do
	{
		if (DiscoveredTileIndexes.Num() > 0)
		{
			if (AnalyseNextDiscoveredTile())
			{
				const TArray<FIntPoint> Path = GeneratePath();
				OnPathFindingCompleted.Execute(Path);
			}
		}
		else
		{
			const TArray<FIntPoint> Path = bReturnReachableTiles ? AnalysedTileIndexes : TArray<FIntPoint>();
			OnPathFindingCompleted.Execute(Path);
		}
	}
	while (MaxMsPerFrame > 0.f and UKismetMathLibrary::GetTotalMilliseconds((UKismetMathLibrary::Now() - LoopStartTime))
		< MaxMsPerFrame);

	FLatentActionInfo LatentInfo;
	LatentInfo.Linkage = 0;
	LatentInfo.UUID = GetUniqueID();
	LatentInfo.CallbackTarget = this;
	LatentInfo.ExecutionFunction = "FindPathWithDelay";

	UKismetSystemLibrary::RetriggerableDelay(GetWorld(), DelayBetweenIterations, LatentInfo);
}