Add reworked Worker Enemy AI #3
							
								
								
									
										5
									
								
								Source/Nakatomi/EAIState.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								Source/Nakatomi/EAIState.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
// Fill out your copyright notice in the Description page of Project Settings.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "EAIState.h"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								Source/Nakatomi/EAIState.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Source/Nakatomi/EAIState.h
									
									
									
									
									
										Normal 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"),
 | 
			
		||||
};
 | 
			
		||||
@ -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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user