Add reworked Worker Enemy AI #3

Closed
baz wants to merge 24 commits from worker-ai into master
4 changed files with 53 additions and 0 deletions
Showing only changes of commit db4d6beb4c - Show all commits

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "EAIState.h"

View File

@ -0,0 +1,18 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
/**
*
*/
UENUM(BlueprintType)
enum class EAIState : uint8
{
PASSIVE UMETA(DisplayName = "Passive"),
ATTACKING UMETA(DisplayName = "Attacking"),
FROZEN UMETA(DisplayName = "Frozen"),
INVESTIGATING UMETA(DisplayName = "Investigating"),
DEAD UMETA(DisplayName = "Dead"),
};

View File

@ -2,6 +2,8 @@
#include "EnemyAIController.h"
#include <Kismet/GameplayStatics.h>
#include "EAIState.h"
#include "NakatomiGameInstance.h"
#include "BehaviorTree/BehaviorTree.h"
#include "BehaviorTree/BlackboardComponent.h"
@ -48,6 +50,8 @@ void AEnemyAIController::OnPossess(APawn* InPawn)
BehaviorTree->StartTree(*behaviourTree);
Blackboard->SetValueAsObject("SelfActor", enemy);
}
Blackboard->SetValueAsEnum("State", static_cast<uint8>(EAIState::PASSIVE));
//ensure(enemy->GetMovementComponent()->UseAccelerationForPathFollowing());
}
@ -179,3 +183,19 @@ bool AEnemyAIController::GetHasAttackToken()
{
return HasAttackToken;
}
void AEnemyAIController::SetState(EAIState state)
{
Blackboard->SetValueAsEnum("State", static_cast<uint8>(state));
}
void AEnemyAIController::SetStateAsPassive()
{
SetState(EAIState::PASSIVE);
}
void AEnemyAIController::SetStateAsAttacking(AActor* target)
{
Blackboard->SetValueAsObject("TargetActor", target);
SetState(EAIState::ATTACKING);
}

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "AIController.h"
#include "EAIState.h"
#include "EnemyCharacter.h"
#include "PlayerCharacter.h"
#include "Perception/AISenseConfig_Sight.h"
@ -59,4 +60,13 @@ public:
UFUNCTION()
bool GetHasAttackToken();
UFUNCTION()
void SetState(EAIState state);
UFUNCTION()
void SetStateAsPassive();
UFUNCTION()
void SetStateAsAttacking(AActor* target);
};