Add reworked Worker Enemy AI #3
|
@ -0,0 +1,5 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "EAIState.h"
|
||||||
|
|
|
@ -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"),
|
||||||
|
};
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "EnemyAIController.h"
|
#include "EnemyAIController.h"
|
||||||
#include <Kismet/GameplayStatics.h>
|
#include <Kismet/GameplayStatics.h>
|
||||||
|
|
||||||
|
#include "EAIState.h"
|
||||||
#include "NakatomiGameInstance.h"
|
#include "NakatomiGameInstance.h"
|
||||||
#include "BehaviorTree/BehaviorTree.h"
|
#include "BehaviorTree/BehaviorTree.h"
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
|
@ -49,6 +51,8 @@ void AEnemyAIController::OnPossess(APawn* InPawn)
|
||||||
Blackboard->SetValueAsObject("SelfActor", enemy);
|
Blackboard->SetValueAsObject("SelfActor", enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Blackboard->SetValueAsEnum("State", static_cast<uint8>(EAIState::PASSIVE));
|
||||||
|
|
||||||
//ensure(enemy->GetMovementComponent()->UseAccelerationForPathFollowing());
|
//ensure(enemy->GetMovementComponent()->UseAccelerationForPathFollowing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,3 +183,19 @@ bool AEnemyAIController::GetHasAttackToken()
|
||||||
{
|
{
|
||||||
return HasAttackToken;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "AIController.h"
|
#include "AIController.h"
|
||||||
|
#include "EAIState.h"
|
||||||
#include "EnemyCharacter.h"
|
#include "EnemyCharacter.h"
|
||||||
#include "PlayerCharacter.h"
|
#include "PlayerCharacter.h"
|
||||||
#include "Perception/AISenseConfig_Sight.h"
|
#include "Perception/AISenseConfig_Sight.h"
|
||||||
|
@ -59,4 +60,13 @@ public:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
bool GetHasAttackToken();
|
bool GetHasAttackToken();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void SetState(EAIState state);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void SetStateAsPassive();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void SetStateAsAttacking(AActor* target);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue