Added NPC logic
This commit is contained in:
@@ -2,8 +2,12 @@
|
||||
|
||||
|
||||
#include "NPC.h"
|
||||
|
||||
#include "BrainComponent.h"
|
||||
#include "NPCTypeDefinition.h"
|
||||
#include "NPCAIController.h"
|
||||
#include "NPCTargetLocation.h"
|
||||
#include "BehaviorTree/BlackboardComponent.h"
|
||||
#include "Components/SkeletalMeshComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
||||
@@ -58,15 +62,26 @@ void ANPC::ActivateFromPool(const FVector& Location, const FRotator& Rotation)
|
||||
Move->SetComponentTickEnabled(true);
|
||||
Move->SetMovementMode(MOVE_Walking);
|
||||
}
|
||||
|
||||
OnActivatedFromPool();
|
||||
|
||||
if (ANPCAIController* NPCController = Cast<ANPCAIController>(GetController()))
|
||||
{
|
||||
NPCController->RunCustomBehaviorTree();
|
||||
NPCController->GetBlackboardComponent()->SetValueAsBool(TEXT("bHasReacted"), false);
|
||||
}
|
||||
}
|
||||
|
||||
void ANPC::DeactivateToPool()
|
||||
{
|
||||
// Drop any active observation so a pooled-out NPC stops contributing to the player's embarrassment.
|
||||
if (ANPCAIController* NPCController = Cast<ANPCAIController>(GetController()))
|
||||
{
|
||||
NPCController->ClearObservation();
|
||||
if (UBrainComponent* Brain = NPCController->GetBrainComponent())
|
||||
{
|
||||
Brain->StopLogic(TEXT("Moved to pool"));
|
||||
}
|
||||
NPCController->ClearFocus(EAIFocusPriority::Default);
|
||||
}
|
||||
|
||||
if (UCharacterMovementComponent* Move = GetCharacterMovement())
|
||||
{
|
||||
@@ -74,9 +89,12 @@ void ANPC::DeactivateToPool()
|
||||
Move->DisableMovement();
|
||||
Move->SetComponentTickEnabled(false);
|
||||
}
|
||||
|
||||
if (TargetLocationActor)
|
||||
{
|
||||
TargetLocationActor->Release(this);
|
||||
}
|
||||
|
||||
SetActorHiddenInGame(true);
|
||||
SetActorEnableCollision(false);
|
||||
|
||||
OnDeactivatedToPool();
|
||||
}
|
||||
Reference in New Issue
Block a user