Skip to content

Commit

Permalink
UE 5.2 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
midgen committed May 27, 2023
1 parent 2ed7fc7 commit 002db5d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 42 deletions.
58 changes: 19 additions & 39 deletions Source/UESVON/Private/BTTask_SVONMoveTo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ UBTTask_SVONMoveTo::UBTTask_SVONMoveTo(const FObjectInitializer& ObjectInitializ
: Super(ObjectInitializer)
{
NodeName = "SVON Move To";
bUseGameplayTasks = GET_AI_CONFIG_VAR(bEnableBTAITasks);
bNotifyTick = !bUseGameplayTasks;
bNotifyTick = ~bUseGameplayTasks;
bNotifyTaskFinished = true;

AcceptableRadius = GET_AI_CONFIG_VAR(AcceptanceRadius);
Expand Down Expand Up @@ -314,54 +313,35 @@ EBTNodeResult::Type UBTTask_SVONMoveTo::PerformMoveTask(UBehaviorTreeComponent&

if (MoveReq.IsValid())
{
if (GET_AI_CONFIG_VAR(bEnableBTAITasks))
UAITask_SVONMoveTo* MoveTask = MyMemory->Task.Get();
const bool bReuseExistingTask = (MoveTask != nullptr);

MoveTask = PrepareMoveTask(OwnerComp, MoveTask, MoveReq);
if (MoveTask)
{
UAITask_SVONMoveTo* MoveTask = MyMemory->Task.Get();
const bool bReuseExistingTask = (MoveTask != nullptr);
MyMemory->bObserverCanFinishTask = false;

MoveTask = PrepareMoveTask(OwnerComp, MoveTask, MoveReq);
if (MoveTask)
if (bReuseExistingTask)
{
MyMemory->bObserverCanFinishTask = false;

if (bReuseExistingTask)
if (MoveTask->IsActive())
{
if (MoveTask->IsActive())
{
UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s"), *GetNodeName(), *MoveTask->GetName());
MoveTask->ConditionalPerformMove();
}
else
{
UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s, but task is not active - handing over move performing to task mechanics"), *GetNodeName(), *MoveTask->GetName());
}
UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s"), *GetNodeName(), *MoveTask->GetName());
MoveTask->ConditionalPerformMove();
}
else
{
MyMemory->Task = MoveTask;
UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' task implementing move with task %s"), *GetNodeName(), *MoveTask->GetName());
MoveTask->ReadyForActivation();
UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' reusing AITask %s, but task is not active - handing over move performing to task mechanics"), *GetNodeName(), *MoveTask->GetName());
}

MyMemory->bObserverCanFinishTask = true;
NodeResult = (MoveTask->GetState() != EGameplayTaskState::Finished) ? EBTNodeResult::InProgress : MoveTask->WasMoveSuccessful() ? EBTNodeResult::Succeeded : EBTNodeResult::Failed;
}
}
else
{
FPathFollowingRequestResult RequestResult = MyController->MoveTo(MoveReq);
if (RequestResult.Code == EPathFollowingRequestResult::RequestSuccessful)
{
MyMemory->MoveRequestID = RequestResult.MoveId;
WaitForMessage(OwnerComp, UBrainComponent::AIMessage_MoveFinished, RequestResult.MoveId);
WaitForMessage(OwnerComp, UBrainComponent::AIMessage_RepathFailed);

NodeResult = EBTNodeResult::InProgress;
}
else if (RequestResult.Code == EPathFollowingRequestResult::AlreadyAtGoal)
else
{
NodeResult = EBTNodeResult::Succeeded;
MyMemory->Task = MoveTask;
UE_VLOG(MyController, LogBehaviorTree, Verbose, TEXT("\'%s\' task implementing move with task %s"), *GetNodeName(), *MoveTask->GetName());
MoveTask->ReadyForActivation();
}

MyMemory->bObserverCanFinishTask = true;
NodeResult = (MoveTask->GetState() != EGameplayTaskState::Finished) ? EBTNodeResult::InProgress : MoveTask->WasMoveSuccessful() ? EBTNodeResult::Succeeded : EBTNodeResult::Failed;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/UESVON/Private/SVONVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void ASVONVolume::Serialize(FArchive& Ar)

float ASVONVolume::GetVoxelSize(layerindex_t aLayer) const
{
return (myExtent.X / FMath::Pow(2, myVoxelPower)) * (FMath::Pow(2.0f, aLayer + 1));
return (myExtent.X / FMath::Pow(2.f, myVoxelPower)) * (FMath::Pow(2.0f, aLayer + 1));
}

bool ASVONVolume::IsReadyForNavigation() const
Expand All @@ -429,12 +429,12 @@ bool ASVONVolume::IsReadyForNavigation() const

int32 ASVONVolume::GetNumNodesInLayer(layerindex_t aLayer) const
{
return FMath::Pow(FMath::Pow(2, (myVoxelPower - (aLayer))), 3);
return FMath::Pow(FMath::Pow(2.f, (myVoxelPower - (aLayer))), 3);
}

int32 ASVONVolume::GetNumNodesPerSide(layerindex_t aLayer) const
{
return FMath::Pow(2, (myVoxelPower - (aLayer)));
return FMath::Pow(2.f, (myVoxelPower - (aLayer)));
}

void ASVONVolume::BeginPlay()
Expand Down

0 comments on commit 002db5d

Please sign in to comment.